From 0f7dc708940563eaa245ae2e67a3f5ff1f869a3b Mon Sep 17 00:00:00 2001 From: avinashkethineedi Date: Tue, 1 Oct 2024 18:33:36 +0000 Subject: [PATCH] make MPI_Init and MPI_Finalize independent of the test fixtures --- tests/unit_tests/shmem_gtest.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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; }