-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathrunners.hpp
More file actions
46 lines (37 loc) · 1.83 KB
/
runners.hpp
File metadata and controls
46 lines (37 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <gtest/gtest.h>
#include <memory>
#include <utility>
namespace ppc::core {
/// @brief GTest event listener that checks for unread MPI messages after each test.
/// @note Used to detect unexpected inter-process communication leftovers.
class UnreadMessagesDetector : public ::testing::EmptyTestEventListener {
public:
UnreadMessagesDetector() = default;
/// @brief Called by GTest after a test ends. Checks for unread messages.
void OnTestEnd(const ::testing::TestInfo& /*test_info*/) override;
private:
};
/// @brief GTest event listener that prints additional information on test failures in worker processes.
/// @details Includes MPI rank info in failure output for debugging.
class WorkerTestFailurePrinter : public ::testing::EmptyTestEventListener {
public:
/// @brief Constructs the listener with a base listener for delegation.
/// @param base A shared pointer to another GTest event listener.
explicit WorkerTestFailurePrinter(std::shared_ptr<::testing::TestEventListener> base) : base_(std::move(base)) {}
/// @brief Called after a test ends. Passes call to base listener and prints failures with rank.
void OnTestEnd(const ::testing::TestInfo& test_info) override;
/// @brief Called when a test part fails. Prints MPI rank info along with the failure.
void OnTestPartResult(const ::testing::TestPartResult& test_part_result) override;
private:
/// @brief Prints the MPI rank of the current process to stderr.
static void PrintProcessRank();
std::shared_ptr<::testing::TestEventListener> base_;
};
/// @brief Initializes the testing environment (e.g., MPI, logging).
/// @param argc Argument count.
/// @param argv Argument vector.
/// @return Exit code from RUN_ALL_TESTS or MPI error code if initialization/
/// finalization fails.
int Init(int argc, char** argv);
} // namespace ppc::core