Skip to content

Commit

Permalink
DAOS-14594 test: fix dfs_parallel xml generation (#13312)
Browse files Browse the repository at this point in the history
Since cmocka is not MPI-aware, force all ranks other than rank 0 to write to stdout to avoid race conditions with the XML file.

Signed-off-by: Dalton Bohning <[email protected]>
  • Loading branch information
daltonbohning authored Jan 16, 2024
1 parent 0e08ed0 commit 8ca9d22
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/tests/suite/dfs_test.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2019-2022 Intel Corporation.
* (C) Copyright 2019-2024 Intel Corporation.
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -81,16 +81,17 @@ run_specified_tests(const char *tests, int rank, int size,
int
main(int argc, char **argv)
{
test_arg_t *arg;
char tests[64];
char *exclude_str = NULL;
int ntests = 0;
int nr_failed = 0;
int nr_total_failed = 0;
int opt = 0, index = 0;
int rank;
int size;
int rc;
test_arg_t *arg;
char tests[64];
char *exclude_str = NULL;
char *cmocka_message_output = NULL;
int ntests = 0;
int nr_failed = 0;
int nr_total_failed = 0;
int opt = 0, index = 0;
int rank;
int size;
int rc;

d_register_alt_assert(mock_assert);

Expand Down Expand Up @@ -166,6 +167,16 @@ main(int argc, char **argv)
tests[new_idx] = '\0';
}

/** if writing XML, force all ranks other than rank 0 to use stdout to avoid conflicts */
cmocka_message_output = getenv("CMOCKA_MESSAGE_OUTPUT");
if (rank != 0 && cmocka_message_output && strcasecmp(cmocka_message_output, "xml") == 0) {
rc = d_setenv("CMOCKA_MESSAGE_OUTPUT", "stdout", 1);
if (rc) {
print_message("d_setenv() failed with %d\n", rc);
return -1;
}
}

nr_failed = run_specified_tests(tests, rank, size, NULL, 0);

exit:
Expand Down

0 comments on commit 8ca9d22

Please sign in to comment.