diff --git a/tests/unit_tests/shmem_gtest.cpp b/tests/unit_tests/shmem_gtest.cpp index 3115ef5e52..d5a982f4c7 100644 --- a/tests/unit_tests/shmem_gtest.cpp +++ b/tests/unit_tests/shmem_gtest.cpp @@ -21,8 +21,24 @@ *****************************************************************************/ #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); + } + + int ret_val = RUN_ALL_TESTS(); + + int finalized{0}; + MPI_Finalized(&finalized); + if (!finalized) { + MPI_Finalize(); + } + return ret_val; }