Skip to content

Commit 13ee0e8

Browse files
committed
Format all tests using clang-formatter in default mode
1 parent a606a1a commit 13ee0e8

File tree

177 files changed

+8395
-9198
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+8395
-9198
lines changed

src/MPI/dall2all.t.cpp

Lines changed: 65 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -20,128 +20,106 @@
2020
#include <gtest/gtest.h>
2121
#include <mpi.h>
2222

23-
2423
using namespace lpf::mpi;
2524

26-
extern "C" const int LPF_MPI_AUTO_INITIALIZE=0;
27-
25+
extern "C" const int LPF_MPI_AUTO_INITIALIZE = 0;
2826

29-
/**
27+
/**
3028
* \pre P >= 1
3129
* \pre P <= 2
3230
*/
3331
class DenseAll2AllTests : public testing::Test {
3432

35-
protected:
36-
37-
static void SetUpTestSuite() {
38-
39-
MPI_Init(NULL, NULL);
40-
Lib::instance();
33+
protected:
34+
static void SetUpTestSuite() {
4135

42-
MPI_Comm_rank( MPI_COMM_WORLD, &my_pid );
43-
MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
36+
MPI_Init(NULL, NULL);
37+
Lib::instance();
4438

45-
}
39+
MPI_Comm_rank(MPI_COMM_WORLD, &my_pid);
40+
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
41+
}
4642

47-
static void TearDownTestSuite() {
48-
MPI_Finalize();
49-
}
43+
static void TearDownTestSuite() { MPI_Finalize(); }
5044

51-
static int my_pid;
52-
static int nprocs;
45+
static int my_pid;
46+
static int nprocs;
5347
};
5448

5549
int DenseAll2AllTests::my_pid = -1;
5650
int DenseAll2AllTests::nprocs = -1;
5751

58-
TEST_F( DenseAll2AllTests, Create )
59-
{
60-
DenseAllToAll x(9, 10);
61-
}
52+
TEST_F(DenseAll2AllTests, Create) { DenseAllToAll x(9, 10); }
6253

63-
TEST_F( DenseAll2AllTests, Reserve )
64-
{
65-
DenseAllToAll x( 4,10);
66-
x.reserve( 50 , 100);
54+
TEST_F(DenseAll2AllTests, Reserve) {
55+
DenseAllToAll x(4, 10);
56+
x.reserve(50, 100);
6757
}
6858

69-
TEST_F( DenseAll2AllTests, Send )
70-
{
59+
TEST_F(DenseAll2AllTests, Send) {
7160

72-
DenseAllToAll x( my_pid, nprocs );
73-
x.reserve( nprocs , sizeof(int));
74-
for (int i = 0; i <= my_pid ; ++i)
75-
x.send( (my_pid + 1) % nprocs, &i, sizeof(int) );
61+
DenseAllToAll x(my_pid, nprocs);
62+
x.reserve(nprocs, sizeof(int));
63+
for (int i = 0; i <= my_pid; ++i)
64+
x.send((my_pid + 1) % nprocs, &i, sizeof(int));
7665

77-
bool prerandomize = true;
78-
int error = x.exchange( Lib::instance().world(), prerandomize, NULL);
79-
EXPECT_TRUE( !error );
66+
bool prerandomize = true;
67+
int error = x.exchange(Lib::instance().world(), prerandomize, NULL);
68+
EXPECT_TRUE(!error);
8069
}
8170

82-
TEST_F( DenseAll2AllTests, Ring )
83-
{
84-
DenseAllToAll x(my_pid, nprocs);
85-
x.reserve( nprocs , sizeof(int));
86-
x.send( (my_pid + 1) % nprocs, &my_pid, sizeof(my_pid) );
71+
TEST_F(DenseAll2AllTests, Ring) {
72+
DenseAllToAll x(my_pid, nprocs);
73+
x.reserve(nprocs, sizeof(int));
74+
x.send((my_pid + 1) % nprocs, &my_pid, sizeof(my_pid));
8775

88-
EXPECT_FALSE( x.empty() );
76+
EXPECT_FALSE(x.empty());
8977

90-
bool prerandomize = true;
91-
int error = x.exchange( Lib::instance().world(), prerandomize, NULL);
92-
EXPECT_TRUE( !error );
78+
bool prerandomize = true;
79+
int error = x.exchange(Lib::instance().world(), prerandomize, NULL);
80+
EXPECT_TRUE(!error);
9381

94-
EXPECT_FALSE( x.empty() );
95-
96-
int y = -1;
97-
x.recv( &y, sizeof(y));
98-
EXPECT_EQ( (my_pid + nprocs -1) % nprocs, y );
82+
EXPECT_FALSE(x.empty());
9983

100-
EXPECT_TRUE( x.empty() );
84+
int y = -1;
85+
x.recv(&y, sizeof(y));
86+
EXPECT_EQ((my_pid + nprocs - 1) % nprocs, y);
10187

88+
EXPECT_TRUE(x.empty());
10289
}
10390

91+
TEST_F(DenseAll2AllTests, ManyMsgs) {
92+
DenseAllToAll x(my_pid, nprocs);
93+
const int nMsgs = 10000;
94+
x.reserve(nMsgs, sizeof(int));
95+
96+
for (int j = 0; j < 10; ++j) {
97+
x.clear();
10498

105-
TEST_F( DenseAll2AllTests, ManyMsgs )
106-
{
107-
DenseAllToAll x(my_pid, nprocs );
108-
const int nMsgs = 10000;
109-
x.reserve( nMsgs , sizeof(int));
110-
111-
for (int j = 0; j < 10 ; ++j) {
112-
x.clear();
113-
114-
for (int i = 0; i < nMsgs; ++i)
115-
{
116-
x.send( (my_pid + i) % nprocs, & i, sizeof(i) );
117-
}
118-
119-
bool prerandomize = true;
120-
int trials = 5;
121-
int error = x.exchange( Lib::instance().world(), prerandomize,
122-
NULL, trials);
123-
EXPECT_FALSE( error );
124-
125-
for (int i = 0; i < nMsgs; ++i)
126-
{
127-
EXPECT_FALSE( x.empty() );
128-
int k = -1;
129-
x.recv( &k, sizeof(k));
130-
EXPECT_GE( k, 0 );
131-
EXPECT_LT( k, nMsgs );
132-
}
133-
EXPECT_TRUE( x.empty() );
99+
for (int i = 0; i < nMsgs; ++i) {
100+
x.send((my_pid + i) % nprocs, &i, sizeof(i));
134101
}
135-
}
136102

137-
TEST_F( DenseAll2AllTests, LargeSend )
138-
{
139-
DenseAllToAll x( my_pid, nprocs );
103+
bool prerandomize = true;
104+
int trials = 5;
105+
int error = x.exchange(Lib::instance().world(), prerandomize, NULL, trials);
106+
EXPECT_FALSE(error);
107+
108+
for (int i = 0; i < nMsgs; ++i) {
109+
EXPECT_FALSE(x.empty());
110+
int k = -1;
111+
x.recv(&k, sizeof(k));
112+
EXPECT_GE(k, 0);
113+
EXPECT_LT(k, nMsgs);
114+
}
115+
EXPECT_TRUE(x.empty());
116+
}
117+
}
140118

141-
size_t bigNum = size_t(std::numeric_limits<int>::max()) + 10u ;
119+
TEST_F(DenseAll2AllTests, LargeSend) {
120+
DenseAllToAll x(my_pid, nprocs);
142121

143-
EXPECT_THROW( x.reserve( 1 , bigNum ), std::bad_alloc );
122+
size_t bigNum = size_t(std::numeric_limits<int>::max()) + 10u;
144123

124+
EXPECT_THROW(x.reserve(1, bigNum), std::bad_alloc);
145125
}
146-
147-

src/MPI/dynamichook.t.cpp

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,41 @@
1515
* limitations under the License.
1616
*/
1717

18+
#include "assert.hpp"
1819
#include "dynamichook.hpp"
1920
#include "time.hpp"
20-
#include "assert.hpp"
2121
#include <gtest/gtest.h>
2222

2323
#include <mpi.h>
2424

2525
#include <iostream>
2626

27-
extern "C" const int LPF_MPI_AUTO_INITIALIZE=0;
27+
extern "C" const int LPF_MPI_AUTO_INITIALIZE = 0;
2828
int myArgc;
2929
char **myArgv;
3030

31-
/**
31+
/**
3232
* \pre P >= 1
3333
* \pre P <= 1
3434
* \return Exit code: 1
3535
*/
3636

37-
int main(int argc, char ** argv)
38-
{
39-
myArgc = argc;
40-
myArgv = argv;
41-
::testing::InitGoogleTest(&argc, argv);
42-
return RUN_ALL_TESTS();
43-
37+
int main(int argc, char **argv) {
38+
myArgc = argc;
39+
myArgv = argv;
40+
::testing::InitGoogleTest(&argc, argv);
41+
return RUN_ALL_TESTS();
4442
}
4543

46-
TEST(API, dynamicHook)
47-
{
44+
TEST(API, dynamicHook) {
4845

4946
/**
5047
* This test is run via following options via
5148
* ./dynamichook.t <server> <port> <pid> <nprocs> <timeout>
5249
* Being run "as is" without all these 5 arguments will lead it
5350
* to fail (which is the normal Google Test case, so we expect exit code 1)
54-
* However, when run via custom add_test tests with correct 5 arguments, it shall work
51+
* However, when run via custom add_test tests with correct 5 arguments, it
52+
* shall work
5553
*/
5654
ASSERT_GE(myArgc, 6);
5755
MPI_Init(&myArgc, &myArgv);
@@ -61,28 +59,24 @@ TEST(API, dynamicHook)
6159
int nprocs = atoi(myArgv[4]);
6260
int timeout = atoi(myArgv[5]);
6361

64-
6562
MPI_Comm comm = MPI_COMM_NULL;
6663

6764
try {
68-
comm = lpf::mpi::dynamicHook( server, port, pid, nprocs,
69-
lpf::Time::fromSeconds( timeout / 1000.0 ) );
70-
}
71-
catch( std::runtime_error & e)
72-
{
65+
comm = lpf::mpi::dynamicHook(server, port, pid, nprocs,
66+
lpf::Time::fromSeconds(timeout / 1000.0));
67+
} catch (std::runtime_error &e) {
7368
ADD_FAILURE() << "hookup failed. Fatal!: " << e.what() << "\n";
7469
_exit(EXIT_FAILURE);
7570
}
7671

7772
int mpiPid = -1, mpiNprocs = -1;
78-
MPI_Comm_rank( comm, &mpiPid);
79-
MPI_Comm_size( comm, &mpiNprocs );
73+
MPI_Comm_rank(comm, &mpiPid);
74+
MPI_Comm_size(comm, &mpiNprocs);
8075

81-
EXPECT_EQ( pid, mpiPid );
82-
EXPECT_EQ( nprocs, mpiNprocs );
76+
EXPECT_EQ(pid, mpiPid);
77+
EXPECT_EQ(nprocs, mpiNprocs);
8378

8479
MPI_Comm_free(&comm);
8580

8681
MPI_Finalize();
8782
}
88-

0 commit comments

Comments
 (0)