17static char const *
expected_msg =
"ERROR(dummy): the expected message";
21static void utest_maybe_abort(
int do_abort,
char const * msg) {
23 if (do_abort)
yac_abort(MPI_COMM_WORLD, msg, __FILE__, __LINE__);
26static void utest_check(
int test_failed,
char const * test_name) {
28 if (test_failed)
PUT_ERR_F(
"ERROR in %s", test_name);
35 int comm_rank, comm_size;
36 MPI_Comm_rank(MPI_COMM_WORLD, &comm_rank);
37 MPI_Comm_size(MPI_COMM_WORLD, &comm_size);
40 PUT_ERR(
"ERROR: wrong number of processes (has to be 2)");
54 utest_check(test_failed,
"SERIAL without abort");
62 utest_check(test_failed,
"SERIAL with abort");
70 utest_check(test_failed,
"SERIAL with unexpected message");
78 utest_check(test_failed,
"SERIAL without substring");
85 int volatile statement_was_executed = 0;
88 statement_was_executed = 1, utest_maybe_abort(1,
expected_msg));
89 utest_check(test_failed,
"SERIAL with comma");
90#if YAC_TEST_ABORT_UNHAPPY_PATH_ENABLED
91 if (!statement_was_executed)
92 PUT_ERR(
"ERROR in SERIAL with comma: statement was not executed");
94 if (statement_was_executed)
95 PUT_ERR(
"ERROR in SERIAL with comma: statement was executed");
101 PUT_ERR(
"ERROR: abort handler was not restored");
108 utest_check(test_failed,
"PAR_ANY without abort");
113 utest_check(test_failed,
"PAR_ALL without abort");
121 utest_check(test_failed,
"PAR_ANY with all aborting");
126 utest_check(test_failed,
"PAR_ALL with all aborting");
134 utest_check(test_failed,
"PAR_ANY with one aborting");
140 utest_check(test_failed,
"PAR_ALL with one aborting");
149 utest_check(test_failed,
"PAR_ANY with mixed messages");
154 utest_check(test_failed,
"PAR_ALL with mixed messages");
163 int volatile statement_was_executed = 0;
166 statement_was_executed = 1, utest_maybe_abort(1,
expected_msg));
167 utest_check(test_failed,
"PAR_ALL unhappy path");
168#if YAC_TEST_ABORT_UNHAPPY_PATH_ENABLED
169 if (!statement_was_executed)
170 PUT_ERR(
"ERROR in PAR_ALL unhappy path: statement was not executed");
172 if (statement_was_executed)
173 PUT_ERR(
"ERROR in PAR_ALL unhappy path: statement was executed");
176 statement_was_executed = 0;
179 statement_was_executed = 1, utest_maybe_abort(0,
expected_msg));
180 utest_check(test_failed,
"PAR_ALL happy path");
181 if (!statement_was_executed)
182 PUT_ERR(
"ERROR in PAR_ALL happy path: statement was not executed");
188 "NOTE: the following two ERROR lines are part of the test\n", stderr);
193#if YAC_TEST_ABORT_UNHAPPY_PATH_ENABLED
195 PUT_ERR(
"ERROR: undetected mismatch (expected abort, got none)");
199 PUT_ERR(
"ERROR: mismatch reported for a skipped statement");
206 PUT_ERR(
"ERROR: undetected mismatch (expected no abort, got one)");
210 PUT_ERR(
"ERROR: abort handler was not restored");
static char const * expected_substr
static char const * expected_msg
static char const * unexpected_msg
Macros for testing code paths that are expected to abort.
#define YAC_TEST_EXPECT_ABORT_PAR_ALL( test_failed, expected_result, expected_substr, comm,...)
#define YAC_TEST_EXPECT_ABORT_PAR_ANY( test_failed, expected_result, expected_substr, comm,...)
#define YAC_TEST_EXPECT_ABORT_SERIAL( test_failed, expected_result, expected_substr,...)
@ YAC_TEST_ABORT_EXPECTED
abort was called with expected message
@ YAC_TEST_ABORT_UNEXPECTED
abort was called with unexpected message
@ YAC_TEST_ABORT_NO_CALL
abort handler was never invoked
#define PUT_ERR_F(fmt,...)
yac_abort_func yac_get_abort_handler(void)
void(* yac_abort_func)(MPI_Comm comm, const char *msg, const char *source, int line) __attribute__((noreturn))
void yac_abort(MPI_Comm comm, const char *msg, const char *source, int line) __attribute__((noreturn))