Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDSPLITTER / Test / TestParaMEDSPLITTER.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "ParaMEDSPLITTERTest.hxx"
20
21 // --- Registers the fixture into the 'registry'
22
23 CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDSPLITTERTest );
24
25 // ============================================================================
26 /*!
27  *  Main program source for Unit Tests with cppunit package does not depend
28  *  on actual tests, so we use the same for all partial unit tests.
29  */
30 // ============================================================================
31
32 int main(int argc, char* argv[])
33 {
34   MPI_Init(&argc,&argv);
35   int rank;
36   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
37   
38   // --- Create the event manager and test controller
39   CPPUNIT_NS::TestResult controller;
40
41   // ---  Add a listener that colllects test result
42   CPPUNIT_NS::TestResultCollector result;
43   controller.addListener( &result );        
44
45   // ---  Add a listener that print dots as test run.
46 #ifdef WIN32
47   CPPUNIT_NS::TextTestProgressListener progress;
48 #else
49   CPPUNIT_NS::BriefTestProgressListener progress;
50 #endif
51   controller.addListener( &progress );      
52
53   // ---  Get the top level suite from the registry
54
55   CPPUNIT_NS::Test *suite =
56     CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
57
58   // ---  Adds the test to the list of test to run
59
60   CPPUNIT_NS::TestRunner runner;
61   runner.addTest( suite );
62   runner.run( controller);
63
64   // ---  Print test in a compiler compatible format.
65
66   std::ostringstream testFileName;
67   testFileName<<"UnitTestsResult"<<rank;
68   std::ofstream testFile;
69   testFile.open(testFileName.str().c_str(), std::ios::out |  std::ios::trunc);
70   //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
71   CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
72   outputter.write(); 
73
74   // ---  Run the tests.
75
76   bool wasSucessful = result.wasSuccessful();
77   testFile.close();
78
79   // ---  Return error code 1 if the one of test failed.
80
81   MPI_Finalize();
82   
83   return wasSucessful ? 0 : 1;
84 }