diff --git a/test/API/H5_api_dataset_test.c b/test/API/H5_api_dataset_test.c index 359c374b9c6..d3c873411c0 100644 --- a/test/API/H5_api_dataset_test.c +++ b/test/API/H5_api_dataset_test.c @@ -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]) diff --git a/test/h5test.h b/test/h5test.h index 123dc952b73..0a4b79f7091 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -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. @@ -134,68 +138,89 @@ 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) /* @@ -203,9 +228,11 @@ extern pthread_key_t thread_info_key_g; */ #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) /* @@ -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)