diff --git a/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp b/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp index 3115ef5e52..8536ca638a 100644 --- a/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp +++ b/projects/rocshmem/tests/unit_tests/shmem_gtest.cpp @@ -21,8 +21,27 @@ *****************************************************************************/ #include "gtest/gtest.h" +#include int main(int argc, char **argv) { ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + + int initialized; + MPI_Initialized(&initialized); + if (!initialized) { + int provided; + MPI_Init_thread(nullptr, nullptr, MPI_THREAD_MULTIPLE, &provided); + if (provided != MPI_THREAD_MULTIPLE) { + std::cerr << "MPI_THREAD_MULTIPLE support disabled.\n"; + } + } + + int ret_val = RUN_ALL_TESTS(); + + int finalized{0}; + MPI_Finalized(&finalized); + if (!finalized) { + MPI_Finalize(); + } + return ret_val; }