il_test dumps the right xml output
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 2 Feb 2005 17:23:01 +0000 (17:23 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 2 Feb 2005 17:23:01 +0000 (17:23 +0000)
org.glite.lb.common/Makefile
org.glite.lb.common/test/il_test.cpp

index d24a031..1b14264 100644 (file)
@@ -97,6 +97,8 @@ THRSTATICLIB:=libglite_lb_common_${thrflavour}.a
 LTLIB:=libglite_lb_common_${nothrflavour}.la
 THRLTLIB:=libglite_lb_common_${thrflavour}.la
 
+REPORTS:=${top_srcdir}/reports
+
 default: all
 
 all compile: check_version ${STATICLIB} ${LTLIB} ${THRSTATICLIB} ${THRLTLIB}
@@ -125,7 +127,10 @@ ${THRLTLIB}: ${THROBJS}
 stage: compile
        $(MAKE) install PREFIX=${stagedir} DOSTAGE=yes
 
-check: compile check.parse check.gss check.il
+check: compile mkreports check.parse check.gss check.il
+
+mkreports:
+       -mkdir ${REPORTS}
 
 check.parse: test_parse
        echo "XXX: nyk -> fixed build interrupt :)"
@@ -140,7 +145,7 @@ check.gss: test_gss
        echo test_gss not run automatically util we have got some credentials
 
 check.il: il_test
-       ./il_test
+       ./il_test ${REPORTS}/il.xml
 
 test_gss: test_gss.o
        ${LINKXX} -o $@ test_gss.o ${LTLIB} ${TEST_LIBS} ${EXT_LIBS}
index 794c0a0..37ccd79 100644 (file)
@@ -1,15 +1,46 @@
+#include <assert.h>
+#include <libgen.h>
+
+#include <fstream>
+
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TextTestRunner.h>
+// #include <cppunit/ui/text/TextTestRunner.h>
 
+#include <cppunit/XmlOutputter.h>
+#include <cppunit/TestRunner.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
 
 int main(int argc, char *argv[])
 {
        CppUnit::Test  *suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
+
+#if 0
        CppUnit::TextTestRunner runner;
 
        runner.addTest(suite);
        runner.setOutputter(CppUnit::CompilerOutputter::defaultOutputter(&runner.result(), std::cerr));
 
        return runner.run() ? 0 : 1;
+#endif
+
+       assert(argc == 2);
+
+       std::ofstream   xml(argv[1]);
+       
+       CppUnit::TestResult controller;
+       CppUnit::TestResultCollector result;
+       controller.addListener( &result );
+
+       CppUnit::TestRunner     runner;
+       runner.addTest(suite);
+       runner.run(controller);
+
+       CppUnit::XmlOutputter xout( &result, xml );
+       CppUnit::CompilerOutputter tout( &result, std::cout);
+       xout.write();
+       tout.write();
+
+       return result.wasSuccessful() ? 0 : 1 ;
 }