Back to index

salome-med  6.5.0
TestParaMEDSPLITTER.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 #include "ParaMEDSPLITTERTest.hxx"
00020 
00021 // --- Registers the fixture into the 'registry'
00022 
00023 CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDSPLITTERTest );
00024 
00025 // ============================================================================
00030 // ============================================================================
00031 
00032 int main(int argc, char* argv[])
00033 {
00034   MPI_Init(&argc,&argv);
00035   int rank;
00036   MPI_Comm_rank(MPI_COMM_WORLD,&rank);
00037   
00038   // --- Create the event manager and test controller
00039   CPPUNIT_NS::TestResult controller;
00040 
00041   // ---  Add a listener that colllects test result
00042   CPPUNIT_NS::TestResultCollector result;
00043   controller.addListener( &result );        
00044 
00045   // ---  Add a listener that print dots as test run.
00046 #ifdef WIN32
00047   CPPUNIT_NS::TextTestProgressListener progress;
00048 #else
00049   CPPUNIT_NS::BriefTestProgressListener progress;
00050 #endif
00051   controller.addListener( &progress );      
00052 
00053   // ---  Get the top level suite from the registry
00054 
00055   CPPUNIT_NS::Test *suite =
00056     CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
00057 
00058   // ---  Adds the test to the list of test to run
00059 
00060   CPPUNIT_NS::TestRunner runner;
00061   runner.addTest( suite );
00062   runner.run( controller);
00063 
00064   // ---  Print test in a compiler compatible format.
00065 
00066   std::ostringstream testFileName;
00067   testFileName<<"UnitTestsResult"<<rank;
00068   std::ofstream testFile;
00069   testFile.open(testFileName.str().c_str(), std::ios::out |  std::ios::trunc);
00070   //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
00071   CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
00072   outputter.write(); 
00073 
00074   // ---  Run the tests.
00075 
00076   bool wasSucessful = result.wasSuccessful();
00077   testFile.close();
00078 
00079   // ---  Return error code 1 if the one of test failed.
00080 
00081   MPI_Finalize();
00082   
00083   return wasSucessful ? 0 : 1;
00084 }