File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
39
39
// / @brief Initializes the testing environment (e.g., MPI, logging).
40
40
// / @param argc Argument count.
41
41
// / @param argv Argument vector.
42
- // / @return Exit code: 0 for success, non-zero for failure.
42
+ // / @return Exit code from RUN_ALL_TESTS or MPI error code if initialization/
43
+ // / finalization fails.
43
44
int Init (int argc, char ** argv);
44
45
45
46
} // namespace ppc::core
Original file line number Diff line number Diff line change @@ -62,7 +62,12 @@ void WorkerTestFailurePrinter::PrintProcessRank() {
62
62
}
63
63
64
64
int Init (int argc, char ** argv) {
65
- MPI_Init (&argc, &argv);
65
+ const int init_res = MPI_Init (&argc, &argv);
66
+ if (init_res != MPI_SUCCESS) {
67
+ std::cerr << std::format (" [ ERROR ] MPI_Init failed with code {}" , init_res) << ' \n ' ;
68
+ MPI_Abort (MPI_COMM_WORLD, init_res);
69
+ return init_res;
70
+ }
66
71
67
72
// Limit the number of threads in TBB
68
73
tbb::global_control control (tbb::global_control::max_allowed_parallelism, ppc::util::GetNumThreads ());
@@ -79,7 +84,12 @@ int Init(int argc, char** argv) {
79
84
listeners.Append (new ppc::core::UnreadMessagesDetector ());
80
85
auto status = RUN_ALL_TESTS ();
81
86
82
- MPI_Finalize ();
87
+ const int finalize_res = MPI_Finalize ();
88
+ if (finalize_res != MPI_SUCCESS) {
89
+ std::cerr << std::format (" [ ERROR ] MPI_Finalize failed with code {}" , finalize_res) << ' \n ' ;
90
+ MPI_Abort (MPI_COMM_WORLD, finalize_res);
91
+ return finalize_res;
92
+ }
83
93
return status;
84
94
}
85
95
You can’t perform that action at this time.
0 commit comments