1 // Copyright (C) 2007-2023 CEA, EDF
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "ParaMEDMEMTest.hxx"
21 #include <cppunit/TestAssert.h>
22 #include "CommInterface.hxx"
23 #include "ProcessorGroup.hxx"
24 #include "ByStringMPIProcessorGroup.hxx"
28 // use this define to enable lines, execution of which leads to Segmentation Fault
31 // use this define to enable CPPUNIT asserts and fails, showing bugs
32 #define ENABLE_FORCED_FAILURES
36 using namespace MEDCoupling;
39 * Check methods defined in MPPIProcessorGroup.hxx
41 (+) ByStringMPIProcessorGroup(const CommInterface& interface);
42 (+) ByStringMPIProcessorGroup(const CommInterface& interface, std::string& codeTag, const MPI_Comm& world_comm );
43 (+) ByStringMPIProcessorGroup(ByStringMPIProcessorGroup& other );
46 void ParaMEDMEMTest::testByStringMPIProcessorGroup_constructor()
48 CommInterface comm_interface;
49 ByStringMPIProcessorGroup* group = new ByStringMPIProcessorGroup(comm_interface);
51 MPI_Comm_size(MPI_COMM_WORLD, &size);
52 CPPUNIT_ASSERT_EQUAL(size,group->size());
54 const MPI_Comm* communicator=group->getComm();
55 MPI_Comm_size(*communicator, &size2);
56 CPPUNIT_ASSERT_EQUAL(size,size2);
60 void ParaMEDMEMTest::testByStringMPIProcessorGroup_stringconstructor()
63 MPI_Comm_size(MPI_COMM_WORLD, &size);
64 MPI_Comm_rank(MPI_COMM_WORLD, &rankId);
70 if ( rankId == 0 || rankId == 2 )
75 CommInterface comm_interface;
76 ByStringMPIProcessorGroup * group = new ByStringMPIProcessorGroup(comm_interface,myTag,MPI_COMM_WORLD);
77 ByStringMPIProcessorGroup * copygroup = new ByStringMPIProcessorGroup(*group);
78 CPPUNIT_ASSERT(group);
79 CPPUNIT_ASSERT(copygroup);
81 std::set<int> ranksInGroup = group->getProcIDs();
82 std::set<int> ranksInCopiedGroup = group->getProcIDs();
83 if ( rankId == 0 || rankId == 2 )
85 CPPUNIT_ASSERT_EQUAL( (int)ranksInGroup.size(), 2 );
86 CPPUNIT_ASSERT_EQUAL( (int)ranksInCopiedGroup.size(), 2 );
90 CPPUNIT_ASSERT_EQUAL( (int)ranksInGroup.size(), 1 );
91 CPPUNIT_ASSERT_EQUAL( (int)ranksInCopiedGroup.size(), 1 );
93 CPPUNIT_ASSERT( group->contains(rankId) );
94 CPPUNIT_ASSERT( copygroup->contains(rankId) );