Skip to content

Commit cca2a2d

Browse files
committed
Fix: error related to MPI in InputParaTest
1 parent 2136cdf commit cca2a2d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

source/module_io/test/read_input_ptest.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,8 @@ TEST_F(InputParaTest, Check)
456456
emptyfile << "stru_file ./support/STRU \n";
457457
emptyfile.close();
458458
}
459+
MPI_Barrier(MPI_COMM_WORLD);
460+
459461
ModuleIO::ReadInput::check_mode = true;
460462
ModuleIO::ReadInput readinput(GlobalV::MY_RANK);
461463
Parameter param;
@@ -469,15 +471,18 @@ TEST_F(InputParaTest, Check)
469471

470472
} catch (const std::exception& e) {
471473
// if exit with error, then the test is failed
472-
FAIL() << "read_parameters threw an exception: " << e.what();
474+
std::cerr << "Rank " << GlobalV::MY_RANK << " error: " << e.what() << std::endl;
475+
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
473476
} catch (...) {
474477
// if exit with unknown error, then the test is failed
475-
FAIL() << "read_parameters threw an unknown exception.";
478+
std::cerr << "Rank " << GlobalV::MY_RANK << " unknown error." << std::endl;
479+
MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE);
476480
}
477481
// Note : the EXPECT_EXIT is not working with MPI, so we use try-catch to test the exit
478482
// EXPECT_EXIT(readinput.read_parameters(param, "./empty_INPUT"), ::testing::ExitedWithCode(0), "");
479483
// std::string output = testing::internal::GetCapturedStdout();
480484
// EXPECT_THAT(output, testing::HasSubstr("INPUT parameters have been successfully checked!"));
485+
MPI_Barrier(MPI_COMM_WORLD);
481486
if (GlobalV::MY_RANK == 0)
482487
{
483488
EXPECT_TRUE(std::remove("./empty_INPUT") == 0);

0 commit comments

Comments
 (0)