Skip to content

Commit

Permalink
WIP: Merge API/Non-api h5test macros
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjala committed Nov 1, 2024
1 parent 85eda92 commit 1163feb
Show file tree
Hide file tree
Showing 12 changed files with 10,837 additions and 10,866 deletions.
486 changes: 243 additions & 243 deletions test/API/H5_api_async_test.c

Large diffs are not rendered by default.

3,548 changes: 1,774 additions & 1,774 deletions test/API/H5_api_attribute_test.c

Large diffs are not rendered by default.

2,250 changes: 1,125 additions & 1,125 deletions test/API/H5_api_dataset_test.c

Large diffs are not rendered by default.

726 changes: 363 additions & 363 deletions test/API/H5_api_datatype_test.c

Large diffs are not rendered by default.

708 changes: 354 additions & 354 deletions test/API/H5_api_file_test.c

Large diffs are not rendered by default.

650 changes: 325 additions & 325 deletions test/API/H5_api_group_test.c

Large diffs are not rendered by default.

10,714 changes: 5,357 additions & 5,357 deletions test/API/H5_api_link_test.c

Large diffs are not rendered by default.

284 changes: 142 additions & 142 deletions test/API/H5_api_misc_test.c

Large diffs are not rendered by default.

2,206 changes: 1,103 additions & 1,103 deletions test/API/H5_api_object_test.c

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions test/API/H5_api_test_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,13 @@ generate_random_datatype_string(H5T_class_t H5_ATTR_UNUSED parent_class, hbool_t
else {

if ((datatype = H5Tcreate(H5T_STRING, H5T_VARIABLE)) < 0) {
H5_FAILED_API();
H5_FAILED();
printf(" couldn't create variable-length string datatype\n");
goto done;
}

if (H5Tset_strpad(datatype, H5T_STR_NULLTERM) < 0) {
H5_FAILED_API();
H5_FAILED();
printf(" couldn't set H5T_STR_NULLTERM for variable-length string type\n");
goto done;
}
Expand Down Expand Up @@ -478,7 +478,7 @@ generate_random_datatype_reference(H5T_class_t H5_ATTR_UNUSED parent_class, hboo
}
else {
if ((datatype = H5Tcopy(H5T_STD_REF_DSETREG)) < 0) {
H5_FAILED_API();
H5_FAILED();
printf(" couldn't copy region reference datatype\n");
goto done;
}
Expand Down
7 changes: 7 additions & 0 deletions test/h5test.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,17 @@ const char *LIBVER_NAMES[] = {"earliest", /* H5F_LIBVER_EARLIEST = 0 */
static H5E_auto2_t err_func = NULL;

/* Global variables for testing */
#ifdef H5_HAVE_MULTITHREAD
_Atomic size_t n_tests_run_g = 0;
_Atomic size_t n_tests_passed_g = 0;
_Atomic size_t n_tests_failed_g = 0;
_Atomic size_t n_tests_skipped_g = 0;
#else
size_t n_tests_run_g = 0;
size_t n_tests_passed_g = 0;
size_t n_tests_failed_g = 0;
size_t n_tests_skipped_g = 0;
#endif /* H5_HAVE_MULTITHREAD */

/* Value of currently registered optional dynamic VOL operation */
int reg_opt_curr_op_val = 0;
Expand Down
118 changes: 41 additions & 77 deletions test/h5test.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
#include "H5private.h"
#include "H5Eprivate.h"

#ifdef H5_HAVE_MULTITHREAD
#include <stdatomic.h>
#endif

/*
* Predefined test verbosity levels.
*
Expand Down Expand Up @@ -112,6 +116,28 @@ extern pthread_key_t thread_info_key_g;
printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__); \
} while (0)

/*
* Muli-thread-compatible testing macros for use in API tests
*/
#ifdef H5_HAVE_MULTITHREAD

/* Increment global atomic testing variable. Used for MT testing by
* tests that don't define threadlocal test information */
#define INCR_TEST_STAT_GLOBAL(field_name) atomic_fetch_add(&field_name, 1);

#define INCR_TEST_STAT(field_name) \
do { \
if (pthread_getspecific(thread_info_key_g) != NULL) {\
((thread_info_t*)pthread_getspecific(thread_info_key_g))->field_name++;\
} else {\
/* Use global value instead of TL */\
INCR_TEST_STAT_GLOBAL(field_name);\
}\
} while (0)

#else
#define INCR_TEST_STAT(field_name) field_name++
#endif

/*
* The name of the test is printed by saying TESTING("something") which will
Expand All @@ -126,31 +152,25 @@ extern pthread_key_t thread_info_key_g;
do { \
printf("Testing %-62s", WHAT); \
fflush(stdout); \
n_tests_run_g++; \
INCR_TEST_STAT(n_tests_run_g); \
} while (0)
#define TESTING_2(WHAT) \
do { \
printf(" Testing %-60s", WHAT); \
fflush(stdout); \
n_tests_run_g++; \
INCR_TEST_STAT(n_tests_run_g); \
} while (0)
#define PASSED() \
do { \
HDputs(" PASSED"); \
fflush(stdout); \
n_tests_passed_g++; \
INCR_TEST_STAT(n_tests_passed_g); \
} while (0)
#define H5_FAILED() \
do { \
HDputs("*FAILED*"); \
fflush(stdout); \
n_tests_failed_g++; \
} while (0)
#define H5_FAILED_API() \
do { \
HDputs("*FAILED*"); \
fflush(stdout); \
INCR_TEST_STAT(n_tests_failed_g); \
INCR_TEST_STAT(n_tests_failed_g); \
} while (0)
#define H5_WARNING() \
do { \
Expand All @@ -161,7 +181,7 @@ extern pthread_key_t thread_info_key_g;
do { \
HDputs(" -SKIP-"); \
fflush(stdout); \
n_tests_skipped_g++; \
INCR_TEST_STAT(n_tests_skipped_g); \
} while (0)
#define PUTS_ERROR(s) \
do { \
Expand Down Expand Up @@ -232,7 +252,7 @@ extern pthread_key_t thread_info_key_g;
part_##part_name##_end:
#define PART_ERROR(part_name) \
do { \
n_tests_failed_g++; \
INCR_TEST_STAT(n_tests_failed_g); \
part_nerrors++; \
goto part_##part_name##_end; \
} while (0)
Expand All @@ -253,70 +273,6 @@ extern pthread_key_t thread_info_key_g;
goto part_##part_name##_end; \
} while (0)

/*
* Muli-thread-compatible testing macros for use in API tests
*/
#ifdef H5_HAVE_MULTITHREAD
#define INCR_TEST_STAT(field_name) \
do { \
if (pthread_getspecific(thread_info_key_g) != NULL) \
((thread_info_t*)pthread_getspecific(thread_info_key_g))->field_name++;\
} while (0)
#else
#define INCR_TEST_STAT(field_name) field_name++
#endif

#define TESTING_API(WHAT) \
do { \
printf("Testing %-62s", WHAT); \
fflush(stdout); \
INCR_TEST_STAT(n_tests_run_g); \
} while (0)
#define TESTING_2_API(WHAT) \
do { \
printf(" Testing %-60s", WHAT); \
fflush(stdout); \
INCR_TEST_STAT(n_tests_run_g); \
} while (0)
#define PASSED_API() \
do { \
HDputs(" PASSED"); \
fflush(stdout); \
INCR_TEST_STAT(n_tests_passed_g); \
} while (0)
#define SKIPPED_API() \
do { \
HDputs(" -SKIP-"); \
fflush(stdout); \
INCR_TEST_STAT(n_tests_skipped_g); \
} while (0)
#define TEST_ERROR_API \
do { \
H5_FAILED_API(); \
AT(); \
goto error; \
} while (0)
#define FAIL_PUTS_ERROR_API(s) \
do { \
H5_FAILED_API(); \
AT(); \
HDputs(s); \
goto error; \
} while (0)
#define PART_ERROR_API(part_name) \
do { \
INCR_TEST_STAT(n_tests_failed_g); \
part_nerrors++; \
goto part_##part_name##_end; \
} while (0)
#define PART_TEST_ERROR_API(part_name) \
do { \
H5_FAILED_API(); \
AT(); \
part_nerrors++; \
goto part_##part_name##_end; \
} while (0)


/* Number of seconds to wait before killing a test (requires alarm(2)) */
#define H5_ALARM_SEC 1200 /* default is 20 minutes */
Expand Down Expand Up @@ -441,10 +397,18 @@ H5TEST_DLL char *getenv_all(MPI_Comm comm, int root, const char *name);
/* Extern global variables */
H5TEST_DLLVAR int TestVerbosity;
/* Global variables for testing */
#ifdef H5_HAVE_MULTITHREAD
H5TEST_DLLVAR _Atomic size_t n_tests_run_g;
H5TEST_DLLVAR _Atomic size_t n_tests_passed_g;
H5TEST_DLLVAR _Atomic size_t n_tests_failed_g;
H5TEST_DLLVAR _Atomic size_t n_tests_skipped_g;
#else
H5TEST_DLLVAR size_t n_tests_run_g;
H5TEST_DLLVAR size_t n_tests_passed_g;
H5TEST_DLLVAR size_t n_tests_failed_g;
H5TEST_DLLVAR size_t n_tests_skipped_g;
#endif

H5TEST_DLLVAR uint64_t vol_cap_flags_g;

H5TEST_DLL void h5_send_message(const char *file, const char *arg1, const char *arg2);
Expand All @@ -465,4 +429,4 @@ H5TEST_DLLVAR int reg_opt_curr_op_val;
#ifdef __cplusplus
}
#endif
#endif
#endif

0 comments on commit 1163feb

Please sign in to comment.