add xml output (--xml=<filename>) program option
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Mon, 20 Aug 2012 19:56:08 +0000 (12:56 -0700)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Mon, 20 Aug 2012 19:56:08 +0000 (12:56 -0700)
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
src/Makefile.am
src/efl/Makefile.am
src/efl/application.cpp
src/testmain.cpp

index ad71517..b767106 100644 (file)
@@ -11,7 +11,8 @@ CXXFLAGS =                    \
 LDFLAGS =                      \
        $(CAIRO_LIBS)           \
        $(WAYLAND_LIBS)         \
-       @CHECK_LIBS@
+       @CHECK_LIBS@            \
+       -lboost_program_options
 
 bin_PROGRAMS = $(TESTS)
 
index 3e2c93c..9c2eb23 100644 (file)
@@ -20,7 +20,8 @@ LDFLAGS +=                    \
        @EFL_LIBS@              \
        @CHECK_LIBS@            \
        -lboost_system          \
-       -lboost_filesystem
+       -lboost_filesystem      \
+       -lboost_program_options
 
 bin_PROGRAMS = $(TESTS)
 
index f05c92b..768cac2 100644 (file)
@@ -45,6 +45,3 @@ void Application::yield(const unsigned time)
        usleep(time);
 }
 
-
-// only one instance per test binary
-// BOOST_GLOBAL_FIXTURE(Application);
index 139a21f..d8ba151 100644 (file)
@@ -1,12 +1,52 @@
+#include <iostream>
+#include <boost/program_options.hpp>
 #include "test.h"
 
+namespace po = boost::program_options;
+
+po::variables_map parseArgs(int argc, char** argv)
+{
+       po::options_description options("optional arguments");
+       options.add_options()
+               ("help", "display this help message")
+               ("xml", po::value<std::string>(), "send results to XML file")
+       ;
+
+       po::variables_map args;
+       try
+       {
+               po::store(po::parse_command_line(argc, argv, options), args);
+               po::notify(args);
+       }
+       catch (po::error& e)
+       {
+               std::cerr << e.what() << std::endl;
+               std::cout << options << std::endl;
+               exit(EXIT_FAILURE);
+       }
+
+       if(args.count("help"))
+       {
+               std::cout << options << std::endl;
+               exit(EXIT_SUCCESS);
+       }
+       
+       return args;
+}
+
 int main(int argc, char** argv)
 {
+       po::variables_map args(parseArgs(argc, argv));
+
        TheGlobalTestSuite::instance().argc = argc;
        TheGlobalTestSuite::instance().argv = argv;
 
        SRunner* sr = srunner_create (TheGlobalTestSuite::instance());
-       //   srunner_set_xml(sr, "results.xml");
+
+       if (args.count("xml"))
+       {
+               srunner_set_xml(sr, args["xml"].as<std::string>().c_str());
+       }
        srunner_run_all (sr, CK_ENV);
 
        int n = srunner_ntests_failed(sr);