Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _MPIMAINTEST_HXX_
00021 #define _MPIMAINTEST_HXX_
00022
00023 #include <cppunit/CompilerOutputter.h>
00024 #include <cppunit/TestResult.h>
00025 #include <cppunit/TestResultCollector.h>
00026 #include <cppunit/TextTestProgressListener.h>
00027 #include <cppunit/BriefTestProgressListener.h>
00028 #include <cppunit/extensions/TestFactoryRegistry.h>
00029 #include <cppunit/TestRunner.h>
00030 #include <stdexcept>
00031
00032 #include <mpi.h>
00033
00034 #include <iostream>
00035 #include <fstream>
00036 #ifndef WIN32
00037 #include <fpu_control.h>
00038 #endif
00039
00040
00045
00046
00047 int main(int argc, char* argv[])
00048 {
00049 #ifndef WIN32
00050 fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM);
00051 _FPU_SETCW(cw);
00052 #endif
00053 MPI_Init(&argc,&argv);
00054 int rank;
00055 MPI_Comm_rank(MPI_COMM_WORLD,&rank);
00056
00057
00058 CPPUNIT_NS::TestResult controller;
00059
00060
00061 CPPUNIT_NS::TestResultCollector result;
00062 controller.addListener( &result );
00063
00064
00065 #ifdef WIN32
00066 CPPUNIT_NS::TextTestProgressListener progress;
00067 #else
00068 CPPUNIT_NS::BriefTestProgressListener progress;
00069 #endif
00070 controller.addListener( &progress );
00071
00072
00073
00074 CPPUNIT_NS::Test *suite =
00075 CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
00076
00077
00078
00079 CPPUNIT_NS::TestRunner runner;
00080 runner.addTest( suite );
00081 runner.run( controller);
00082
00083
00084
00085 std::ostringstream testFileName;
00086 testFileName<<"UnitTestResult"<<rank;
00087 std::ofstream testFile;
00088 testFile.open(testFileName.str().c_str(), std::ios::out | std::ios::trunc);
00089
00090 CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
00091 outputter.write();
00092
00093
00094
00095 bool wasSucessful = result.wasSuccessful();
00096 testFile.close();
00097
00098
00099
00100 MPI_Finalize();
00101
00102 return wasSucessful ? 0 : 1;
00103 }
00104
00105 #endif