Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct Reporting of Multi-Threaded Test Outcomes #15

Merged
merged 14 commits into from
Jan 16, 2025
Merged
2 changes: 2 additions & 0 deletions src/H5public.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ extern "C" {

#define H5_ATOMIC_STORE(dst, value) atomic_store(&dst, value)
#define H5_ATOMIC_LOAD(src) atomic_load(&src)
#define H5_ATOMIC_ADD(dst, value) atomic_fetch_add(&dst, value)

#else
#define H5_ATOMIC(type) type
Expand All @@ -427,6 +428,7 @@ extern "C" {

#define H5_ATOMIC_STORE(dst, value) (dst = value)
#define H5_ATOMIC_LOAD(src) (src)
#define H5_ATOMIC_ADD(dst, value) (dst += value)
#endif


Expand Down
52 changes: 31 additions & 21 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -3129,9 +3129,11 @@ test_create_many_dataset(void H5_ATTR_UNUSED *params)
goto error;
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < DATASET_NUMB; i++) {
printf("\r %u/%u", i + 1, DATASET_NUMB);
if (IS_MAIN_TEST_THREAD)
printf("\r %u/%u", i + 1, DATASET_NUMB);
snprintf(dset_name, sizeof(dset_name), "dset_%02u", i);
data = i % 256;

Expand Down Expand Up @@ -5258,7 +5260,7 @@ test_dataset_io_point_selections(void H5_ATTR_UNUSED *params)
/* Perform with and without chunking */
for (do_chunk = false;; do_chunk = true) {
if (do_chunk) {
TESTING("point selection I/O with all selection in memory and points in file with chunking");
TESTING_2("point selection I/O with all selection in memory and points in file with chunking");

/* Create chunked dataset */
if ((dset_id = H5Dcreate2(group_id, DATASET_IO_POINT_DSET_NAME_CHUNK, H5T_NATIVE_INT, fspace_id,
Expand Down Expand Up @@ -5339,9 +5341,9 @@ test_dataset_io_point_selections(void H5_ATTR_UNUSED *params)
PASSED();

if (do_chunk)
TESTING("point selection I/O with points in memory and file (same shape) with chunking");
TESTING_2("point selection I/O with points in memory and file (same shape) with chunking");
else
TESTING("point selection I/O with points in memory and file (same shape)");
TESTING_2("point selection I/O with points in memory and file (same shape)");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -5405,9 +5407,9 @@ test_dataset_io_point_selections(void H5_ATTR_UNUSED *params)
PASSED();

if (do_chunk)
TESTING("point selection I/O with points in memory and file (different shape) with chunking");
TESTING_2("point selection I/O with points in memory and file (different shape) with chunking");
else
TESTING("point selection I/O with points in memory and file (different shape)");
TESTING_2("point selection I/O with points in memory and file (different shape)");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -5478,9 +5480,9 @@ test_dataset_io_point_selections(void H5_ATTR_UNUSED *params)
PASSED();

if (do_chunk)
TESTING("point selection I/O with hyperslab in memory and points in file with chunking");
TESTING_2("point selection I/O with hyperslab in memory and points in file with chunking");
else
TESTING("point selection I/O with hyperslab in memory and points in file");
TESTING_2("point selection I/O with hyperslab in memory and points in file");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -5551,9 +5553,9 @@ test_dataset_io_point_selections(void H5_ATTR_UNUSED *params)
PASSED();

if (do_chunk)
TESTING("point selection I/O with points in memory and hyperslab in file with chunking");
TESTING_2("point selection I/O with points in memory and hyperslab in file with chunking");
else
TESTING("point selection I/O with points in memory and hyperslab in file");
TESTING_2("point selection I/O with points in memory and hyperslab in file");

/* Generate points to read */
DATASET_IO_POINT_GEN_POINTS(points, i, j);
Expand Down Expand Up @@ -8342,7 +8344,6 @@ test_dataset_string_encodings(void H5_ATTR_UNUSED *params)
}
PART_END(UTF8_cset);

PASSED();
}
END_MULTIPART;

Expand Down Expand Up @@ -12855,11 +12856,13 @@ test_write_multi_chunk_dataset_diff_shape_read(void H5_ATTR_UNUSED *params)
/*
* 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;

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_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down Expand Up @@ -13081,7 +13084,8 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void H5_ATTR_UNUSED *params)
count[i] = chunk_dims[i];
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (niter = 0; niter < DATASET_MULTI_CHUNK_OVERWRITE_SAME_SPACE_READ_TEST_NITERS; niter++) {
memset(write_buf, 0, data_size);

Expand Down Expand Up @@ -13190,7 +13194,8 @@ test_overwrite_multi_chunk_dataset_same_shape_read(void H5_ATTR_UNUSED *params)
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_OVERWRITE_SAME_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down Expand Up @@ -13425,7 +13430,8 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void H5_ATTR_UNUSED *params)
count[i] = chunk_dims[i];
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (niter = 0; niter < DATASET_MULTI_CHUNK_OVERWRITE_DIFF_SPACE_READ_TEST_NITERS; niter++) {
memset(write_buf, 0, data_size);

Expand Down Expand Up @@ -13534,7 +13540,8 @@ test_overwrite_multi_chunk_dataset_diff_shape_read(void H5_ATTR_UNUSED *params)
for (i = 0; i < data_size / chunk_size; i++) {
size_t j;

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

for (j = 0; j < DATASET_MULTI_CHUNK_OVERWRITE_DIFF_SPACE_READ_TEST_DSET_SPACE_RANK; j++) {
if (dims[j] == chunk_dims[j])
Expand Down Expand Up @@ -13945,7 +13952,8 @@ test_read_partial_chunk_hyperslab_selection(void H5_ATTR_UNUSED *params)
/*
* Write and read each chunk in the dataset.
*/
printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < FIXED_NCHUNKS; i++) {
hsize_t start[DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_SPACE_RANK];
hsize_t count[DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_SPACE_RANK];
Expand Down Expand Up @@ -14009,7 +14017,8 @@ test_read_partial_chunk_hyperslab_selection(void H5_ATTR_UNUSED *params)
goto error;
}

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

if (H5Dwrite(dset_id, DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_DTYPE, mspace_id, fspace_id,
H5P_DEFAULT, write_buf) < 0) {
Expand Down Expand Up @@ -14044,7 +14053,8 @@ test_read_partial_chunk_hyperslab_selection(void H5_ATTR_UNUSED *params)
goto error;
}

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

if (H5Dread(dset_id, DATASET_PARTIAL_CHUNK_READ_HYPER_SEL_TEST_DSET_DTYPE, mspace_id, fspace_id,
H5P_DEFAULT, read_buf) < 0) {
Expand Down
6 changes: 6 additions & 0 deletions test/API/H5_api_datatype_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,13 +755,19 @@ test_create_committed_datatype_empty_types(void H5_ATTR_UNUSED *params)
}
END_MULTIPART;

TESTING_2("test cleanup");

if (H5Gclose(group_id) < 0)
TEST_ERROR;
if (H5Gclose(container_group) < 0)
TEST_ERROR;
if (H5Fclose(file_id) < 0)
TEST_ERROR;

PASSED();

return;

error:
H5E_BEGIN_TRY
{
Expand Down
37 changes: 22 additions & 15 deletions test/API/H5_api_file_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,13 @@ test_create_file_invalid_params(void H5_ATTR_UNUSED *params)
}
END_MULTIPART;

TESTING_2("test cleanup");

free(prefixed_filename);
prefixed_filename = NULL;

PASSED();

return;

error:
Expand Down Expand Up @@ -404,7 +408,7 @@ test_open_file(void H5_ATTR_UNUSED *params)
* XXX: SWMR open flags
*/
}
END_MULTIPART;
END_MULTIPART_NO_CLEANUP;

return;

Expand Down Expand Up @@ -506,7 +510,7 @@ test_open_file_invalid_params(void H5_ATTR_UNUSED *params)
}
PART_END(H5Fopen_invalid_flags);
}
END_MULTIPART;
END_MULTIPART_NO_CLEANUP;

return;

Expand Down Expand Up @@ -1107,9 +1111,13 @@ test_file_is_accessible(void H5_ATTR_UNUSED *params)
}
END_MULTIPART;

TESTING_2("test cleanup");

free(prefixed_filename);
prefixed_filename = NULL;

PASSED();

return;

error:
Expand Down Expand Up @@ -1572,12 +1580,16 @@ test_get_file_intent(void H5_ATTR_UNUSED *params)
}
END_MULTIPART;

TESTING_2("test cleanup");

if (GetTestCleanup() && H5Fdelete(prefixed_filename, H5P_DEFAULT) < 0)
TEST_ERROR;

free(prefixed_filename);
prefixed_filename = NULL;

PASSED();

return;

error:
Expand Down Expand Up @@ -1627,11 +1639,6 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
return;
}

if (GetTestMaxNumThreads() == 0) {
printf(" Active thread count is invalid\n");
TEST_ERROR;
}

TESTING_2("test setup");

if (prefix_filename(test_path_prefix, GET_OBJ_COUNT_TEST_FILENAME1, &prefixed_filename1) < 0) {
Expand Down Expand Up @@ -1720,7 +1727,7 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
if (check_open_obj_count(obj_count, 2) < 0) {
H5_FAILED();
printf(" number of open files (%ld) did not match %s expected number (2)\n", obj_count,
GetTestMaxNumThreads() > 1 ? "or exceed" : "");
TEST_EXECUTION_CONCURRENT ? "or exceed" : "");
PART_ERROR(H5Fget_obj_count_files);
}

Expand Down Expand Up @@ -1764,7 +1771,7 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
if (check_open_obj_count(obj_count, 1) < 0) {
H5_FAILED();
printf(" number of open groups (%ld) did not match %s expected number (1)\n", obj_count,
GetTestMaxNumThreads() > 1 ? "or exceed" : "");
TEST_EXECUTION_CONCURRENT ? "or exceed" : "");
PART_ERROR(H5Fget_obj_count_types);
}

Expand All @@ -1786,7 +1793,7 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
if (check_open_obj_count(obj_count, 1) < 0) {
H5_FAILED();
printf(" number of open named datatypes (%ld) did not match %s expected number (1)\n", obj_count,
GetTestMaxNumThreads() > 1 ? "or exceed" : "");
TEST_EXECUTION_CONCURRENT ? "or exceed" : "");
PART_ERROR(H5Fget_obj_count_types);
}

Expand All @@ -1808,7 +1815,7 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
if (check_open_obj_count(obj_count, 1) < 0) {
H5_FAILED();
printf(" number of open attributes (%ld) did not match %s expected number (1)\n", obj_count,
GetTestMaxNumThreads() > 1 ? "or exceed" : "");
TEST_EXECUTION_CONCURRENT ? "or exceed" : "");
PART_ERROR(H5Fget_obj_count_attrs);
}

Expand All @@ -1830,7 +1837,7 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
if (check_open_obj_count(obj_count, 1) < 0) {
H5_FAILED();
printf(" number of open datasets (%ld) did not match %s expected number (1)\n", obj_count,
GetTestMaxNumThreads() > 1 ? "or exceed" : "");
TEST_EXECUTION_CONCURRENT ? "or exceed" : "");
PART_ERROR(H5Fget_obj_count_dsets);
}

Expand Down Expand Up @@ -1874,7 +1881,7 @@ test_get_file_obj_count(void H5_ATTR_UNUSED *params)
if (check_open_obj_count(obj_count, 6) < 0) {
H5_FAILED();
printf(" number of open objects (%ld) did not match %s expected number (6)\n", obj_count,
GetTestMaxNumThreads() > 1 ? "or exceed" : "");
TEST_EXECUTION_CONCURRENT ? "or exceed" : "");
PART_ERROR(H5Fget_obj_count_all);
}

Expand Down Expand Up @@ -2559,9 +2566,9 @@ herr_t
check_open_obj_count(ssize_t obj_count, int expected) {
herr_t ret_value = SUCCEED;
/* If multiple threads are concurrently executing tests, then more objects than expected may be open in the library */
if (GetTestMaxNumThreads() > 1 && obj_count < expected) {
if (TEST_EXECUTION_CONCURRENT && obj_count < expected) {
ret_value = FAIL;
} else if (GetTestMaxNumThreads() == 1 && obj_count != expected) { /* Single thread, expect exact count */
} else if (!TEST_EXECUTION_CONCURRENT && obj_count != expected) { /* Single thread, expect exact count */
ret_value = FAIL;
}

Expand Down
13 changes: 9 additions & 4 deletions test/API/H5_api_group_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,13 @@ test_create_many_groups(void H5_ATTR_UNUSED *params)
}

/* Create multiple groups under the parent group */
printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
for (i = 0; i < GROUP_NUMB_MANY; i++) {
printf("\r %u/%u", i + 1, GROUP_NUMB_MANY);
if (IS_MAIN_TEST_THREAD)
printf("\r %u/%u", i + 1, GROUP_NUMB_MANY);
snprintf(group_name, sizeof(group_name), "group %02u", i);

if ((child_group_id =
H5Gcreate2(parent_group_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
Expand Down Expand Up @@ -292,7 +295,8 @@ test_create_deep_groups(void H5_ATTR_UNUSED *params)
goto error;
}

printf("\n");
if (IS_MAIN_TEST_THREAD)
printf("\n");
if (create_group_recursive(group_id, 1) < 0)
TEST_ERROR;

Expand Down Expand Up @@ -328,7 +332,8 @@ create_group_recursive(hid_t parent_gid, unsigned counter)
hid_t child_gid = H5I_INVALID_HID;
char gname[NAME_BUF_SIZE];

printf("\r %u/%u", counter, GROUP_DEPTH);
if (IS_MAIN_TEST_THREAD)
printf("\r %u/%u", counter, GROUP_DEPTH);
if (counter == 1)
snprintf(gname, sizeof(gname), "2nd_child_group");
else if (counter == 2)
Expand Down
Loading
Loading