COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-parallel-environment.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2013 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 //
7 // IMPORTANT:
8 // run it both on 1 and many cores
9 // for example: mpirun -np 4 ./test-parallel-environment --report_level=confirm or --report_level=detailed
10 
11 #define BOOST_TEST_DYN_LINK
12 #define BOOST_TEST_MODULE "Test module for cf3::common 's parallel environment - part of testing the environment."
13 
15 
16 #include <vector>
17 #include <boost/test/unit_test.hpp>
18 
20 
21 #include "common/Log.hpp"
22 #include "common/PE/Comm.hpp"
23 #include "common/PE/debug.hpp"
24 
26 
27 using namespace std;
28 using namespace boost;
29 using namespace cf3;
30 using namespace cf3::common;
31 
33 
34 struct PEFixture
35 {
38  {
39  m_argc = boost::unit_test::framework::master_test_suite().argc;
40  m_argv = boost::unit_test::framework::master_test_suite().argv;
41  }
42 
45  {
46  }
47 
49 
51  int m_argc;
52  char** m_argv;
53 
54 };
55 
57 
58 BOOST_FIXTURE_TEST_SUITE( PESuite, PEFixture )
59 
60 
62 BOOST_AUTO_TEST_CASE( isinit_preinit )
63 {
64  BOOST_CHECK_EQUAL( PE::Comm::instance().is_active() , false );
65 }
66 
67 BOOST_AUTO_TEST_CASE( allrankzero_preinit )
68 {
69  BOOST_CHECK_EQUAL( PE::Comm::instance().rank() , (Uint)0 );
70 }
71 
73 {
74  PE::Comm::instance().init(m_argc,m_argv);
75  BOOST_CHECK_EQUAL( PE::Comm::instance().is_active() , true );
76  PEProcessSortedExecute(-1,CFinfo << "Proccess " << PE::Comm::instance().rank() << "/" << PE::Comm::instance().size() << " reports in." << CFendl;);
77 }
78 
79 BOOST_AUTO_TEST_CASE( rank_and_size )
80 {
81  BOOST_CHECK_LT( PE::Comm::instance().rank() , PE::Comm::instance().size() );
82 }
83 
85 {
86  PEProcessSortedExecute(-1,CFinfo << "Proccess " << PE::Comm::instance().rank() << "/" << PE::Comm::instance().size() << " says good bye." << CFendl;);
87  PE::Comm::instance().finalize();
88  BOOST_CHECK_EQUAL( PE::Comm::instance().is_active() , false );
89 }
90 
92 
93 BOOST_AUTO_TEST_SUITE_END()
94 
95 
#define CFinfo
these are always defined
Definition: Log.hpp:104
external boost library namespace
BOOST_AUTO_TEST_CASE(isinit_preinit)
STL namespace.
#define CFendl
Definition: Log.hpp:109
Top-level namespace for coolfluid.
Definition: Action.cpp:18
unsigned int Uint
typedef for unsigned int
Definition: CF.hpp:90
PEFixture()
common setup for each test case
int m_argc
possibly common functions used on the tests below
~PEFixture()
common tear-down for each test case
Most basic kernel library.
Definition: Action.cpp:19
#define PEProcessSortedExecute(irank, expression)
Definition: debug.hpp:43
Send comments to:
COOLFluiD Web Admin