Skip to content

Commit

Permalink
MPI test harness print statements
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson committed Dec 18, 2023
1 parent 9d2c32f commit 98b2e32
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion unit_tests/test_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,29 @@ int main(int argc, char *argv[]) {
std::cerr << argv[0] << " (KokkosComm " << KOKKOSCOMM_VERSION_MAJOR << "." << KOKKOSCOMM_VERSION_MINOR << "." << KOKKOSCOMM_VERSION_PATCH << ")\n";
}
Kokkos::initialize();
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " did initialize()\n";

// Intialize google test
::testing::InitGoogleTest(&argc, argv);
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " did ::testing::InitGoogleTest()\n";

// Add a test environment, which will initialize a test communicator
// (a duplicate of MPI_COMM_WORLD)
::testing::AddGlobalTestEnvironment(new gtest_mpi::MPITestEnvironment());
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " did testing::AddGlobalTestEnvironment()\n";

auto& test_listeners = ::testing::UnitTest::GetInstance()->listeners();
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " did ::testing::UnitTest::GetInstance()->listeners()\n";

// Remove default listener and replace with the custom MPI listener
delete test_listeners.Release(test_listeners.default_result_printer());
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " removed default listener\n";
test_listeners.Append(new gtest_mpi::PrettyMPIUnitTestResultPrinter());
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " added MPI listener\n";

// run tests

auto exit_code = RUN_ALL_TESTS();
if (0 == rank) std::cerr << __FILE__ << ":" << __LINE__ << " ran tests\n";

// Finalize MPI before exiting
Kokkos::finalize();
Expand Down

0 comments on commit 98b2e32

Please sign in to comment.