summaryrefslogtreecommitdiff
path: root/i/marvin/src/tester
diff options
context:
space:
mode:
Diffstat (limited to 'i/marvin/src/tester')
-rw-r--r--i/marvin/src/tester/test_tester.cc2
-rw-r--r--i/marvin/src/tester/tester.cc24
2 files changed, 22 insertions, 4 deletions
diff --git a/i/marvin/src/tester/test_tester.cc b/i/marvin/src/tester/test_tester.cc
index 3075552..8db2a31 100644
--- a/i/marvin/src/tester/test_tester.cc
+++ b/i/marvin/src/tester/test_tester.cc
@@ -72,9 +72,9 @@ class TestTester
int
main (int argc, char **argv)
{
- TestTester tt (argc, argv);
try
{
+ TestTester tt (argc, argv);
return tt.main ();
}
catch (const std::exception &e)
diff --git a/i/marvin/src/tester/tester.cc b/i/marvin/src/tester/tester.cc
index 5b93fd8..2ded27f 100644
--- a/i/marvin/src/tester/tester.cc
+++ b/i/marvin/src/tester/tester.cc
@@ -27,6 +27,8 @@
#include <unistd.h> // getopt
#include <exception> // std::exception
#include <cstdlib> // std::exit
+#include <fstream> // std::ifstream
+#include <sstream> // std::stringstream
/// Constructor.
Tester::Tester (int argc, char **argv)
@@ -39,11 +41,13 @@ Tester::Tester (int argc, char **argv)
/// Getopt command line.
/// Supported arguemnts :
/// - -c "commands list"
+/// - -f <file>
void
Tester::getOpt (int argc, char **argv)
{
- char *optstring = "c:";
+ char *optstring = "c:f:";
int option;
+ std::ifstream file;
// Check number of args
if (argc < 2)
@@ -63,6 +67,18 @@ Tester::getOpt (int argc, char **argv)
case 'c':
commands_.append (optarg);
break;
+ case 'f':
+ file.open (optarg);
+ if (file.is_open ())
+ {
+ std::stringstream buffer_tmp;
+ buffer_tmp << file.rdbuf();
+ commands_.append (buffer_tmp.str ());
+ file.close ();
+ }
+ else
+ throw std::runtime_error ("File not found : " + std::string (optarg));
+ break;
case '?':
default:
usage ();
@@ -76,8 +92,10 @@ Tester::getOpt (int argc, char **argv)
void
Tester::usage (void) const
{
- std::cout << "Usage: " << program_ << " [-c <commands list>]" <<
- std::endl;
+ std::cout << "Usage: " << program_
+ << " [-c <commands list>]"
+ << " [-f <file_with_commands>]"
+ << std::endl;
}