Skip to content

Commit

Permalink
Suppress test output from non-main threads
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Nov 11, 2024
1 parent 71679ab commit f33b00c
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 32 deletions.
6 changes: 4 additions & 2 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -12593,11 +12593,13 @@ test_write_multi_chunk_dataset_same_shape_read(void)
/*
* Read every chunk in the dataset, checking the data for each one.
*/
printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < data_size / chunk_size; i++) {
size_t j, k;

printf("\r Reading chunk %zu", i);
if (IS_MAIN_TEST_THREAD)
printf("\r Reading chunk %zu", i);

for (j = 0; j < DATASET_MULTI_CHUNK_WRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down
89 changes: 59 additions & 30 deletions test/h5test.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ typedef struct thread_info_t {

#ifdef H5_HAVE_MULTITHREAD
extern pthread_key_t thread_info_key_g;
#endif

#define IS_MAIN_TEST_THREAD ((pthread_getspecific(thread_info_key_g)) && (((thread_info_t*)pthread_getspecific(thread_info_key_g))->thread_idx == 0))
#else
#define IS_MAIN_THREAD_THREAD true
#endif /* H5_HAVE_MULTITHREAD */

/*
* Print the current location on the standard output stream.
Expand Down Expand Up @@ -134,78 +138,101 @@ extern pthread_key_t thread_info_key_g;
*/
#define TESTING(WHAT) \
do { \
printf("Testing %-62s", WHAT); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
printf("Testing %-62s", WHAT); \
fflush(stdout); \
} \
INCR_TEST_STAT(n_tests_run_g); \
} while (0)
#define TESTING_2(WHAT) \
do { \
printf(" Testing %-60s", WHAT); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
printf(" Testing %-60s", WHAT); \
fflush(stdout); \
} \
INCR_TEST_STAT(n_tests_run_g); \
} while (0)
#define PASSED() \
do { \
HDputs(" PASSED"); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
HDputs(" PASSED"); \
fflush(stdout); \
} \
INCR_TEST_STAT(n_tests_passed_g); \
} while (0)
#define H5_FAILED() \
do { \
TestErrPrintf("*FAILED*\n"); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
HDputs("*FAILED*"); \
fflush(stdout); \
} \
INCR_TEST_STAT(n_tests_failed_g); \
} while (0)
#define H5_WARNING() \
do { \
HDputs("*WARNING*"); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
HDputs("*WARNING*"); \
fflush(stdout); \
} \
} while (0)
#define SKIPPED() \
do { \
HDputs(" -SKIP-"); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
HDputs(" -SKIP-"); \
fflush(stdout); \
} \
INCR_TEST_STAT(n_tests_skipped_g); \
} while (0)
#define PUTS_ERROR(s) \
do { \
HDputs(s); \
AT(); \
if (IS_MAIN_TEST_THREAD) { \
HDputs(s); \
AT(); \
} \
goto error; \
} while (0)
#define TEST_ERROR \
do { \
H5_FAILED(); \
AT(); \
if (IS_MAIN_TEST_THREAD) { \
H5_FAILED(); \
AT(); \
} \
goto error; \
} while (0)
#define STACK_ERROR \
do { \
H5Eprint2(H5E_DEFAULT, stdout); \
do { \
if (IS_MAIN_TEST_THREAD) \
H5Eprint2(H5E_DEFAULT, stdout); \
goto error; \
} while (0)
#define FAIL_STACK_ERROR \
do { \
H5_FAILED(); \
AT(); \
H5Eprint2(H5E_DEFAULT, stdout); \
if (IS_MAIN_TEST_THREAD) { \
H5_FAILED(); \
AT(); \
H5Eprint2(H5E_DEFAULT, stdout); \
} \
goto error; \
} while (0)
#define FAIL_PUTS_ERROR(s) \
do { \
H5_FAILED(); \
AT(); \
HDputs(s); \
if (IS_MAIN_TEST_THREAD) { \
H5_FAILED(); \
AT(); \
HDputs(s); \
} \
goto error; \
} while (0)
/*
* Testing macros used for multi-part tests.
*/
#define TESTING_MULTIPART(WHAT) \
do { \
printf("Testing %-62s", WHAT); \
HDputs(""); \
fflush(stdout); \
if (IS_MAIN_TEST_THREAD) { \
printf("Testing %-62s", WHAT); \
HDputs(""); \
fflush(stdout); \
} \
} while (0)

/*
Expand Down Expand Up @@ -242,8 +269,10 @@ extern pthread_key_t thread_info_key_g;
} while (0)
#define PART_TEST_ERROR(part_name) \
do { \
H5_FAILED(); \
AT(); \
if (IS_MAIN_TEST_THREAD) { \
H5_FAILED(); \
AT(); \
} \
part_nerrors++; \
goto part_##part_name##_end; \
} while (0)
Expand Down

0 comments on commit f33b00c

Please sign in to comment.