diff --git a/src/H5public.h b/src/H5public.h index 35a4ecc5a4b..89021de1bc0 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -416,12 +416,17 @@ extern "C" { #define H5_ATOMIC(type) _Atomic type #define H5_ATOMIC_SPECIFIER(type) _Atomic(type) #define H5_ATOMIC_VAR_INIT(value) ATOMIC_VAR_INIT(value) + +#define H5_ATOMIC_STORE(dst, value) atomic_store(&dst, value) +#define H5_ATOMIC_LOAD(src) atomic_load(&src) #else #define H5_ATOMIC(type) type #define H5_ATOMIC_SPECIFIER(type) type #define H5_ATOMIC_VAR_INIT(value) value -#endif +#define H5_ATOMIC_STORE(dst, value) dst = value +#define H5_ATOMIC_LOAD(src) src +#endif /* Functions in H5.c */ /** diff --git a/test/API/H5_api_async_test.c b/test/API/H5_api_async_test.c index e0723427ab2..fd2f6aae6e7 100644 --- a/test/API/H5_api_async_test.c +++ b/test/API/H5_api_async_test.c @@ -2692,28 +2692,33 @@ test_file_cleanup(void) void H5_api_async_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_async_test_header", print_async_test_header, NULL, "Prints header for async tests", NULL, 0); - AddTest("test_one_dataset_io", test_one_dataset_io, NULL, "single dataset I/O", NULL, 0); - AddTest("test_multi_dataset_io", test_multi_dataset_io, NULL, "multi dataset I/O", NULL, 0); - AddTest("test_multi_file_dataset_io", test_multi_file_dataset_io, NULL, "multi file dataset I/O", NULL, 0); + AddTest("test_one_dataset_io", test_one_dataset_io, NULL, "single dataset I/O", NULL, testframe_flags); + AddTest("test_multi_dataset_io", test_multi_dataset_io, NULL, "multi dataset I/O", NULL, testframe_flags); + AddTest("test_multi_file_dataset_io", test_multi_file_dataset_io, NULL, "multi file dataset I/O", NULL, testframe_flags); AddTest("test_multi_file_grp_dset_io", test_multi_file_grp_dset_io, NULL, - "multi file dataset I/O with groups", NULL, 0); - AddTest("test_set_extent", test_set_extent, NULL, "H5Dset_extent() and H5Dget_space()", NULL, 0); - AddTest("test_attribute_exists", test_attribute_exists, NULL, "H5Aexists()", NULL, 0); - AddTest("test_attribute_io", test_attribute_io, NULL, "attribute I/O", NULL, 0); + "multi file dataset I/O with groups", NULL, testframe_flags); + AddTest("test_set_extent", test_set_extent, NULL, "H5Dset_extent() and H5Dget_space()", NULL, testframe_flags); + AddTest("test_attribute_exists", test_attribute_exists, NULL, "H5Aexists()", NULL, testframe_flags); + AddTest("test_attribute_io", test_attribute_io, NULL, "attribute I/O", NULL, testframe_flags); AddTest("test_attribute_io_tconv", test_attribute_io_tconv, NULL, "attribute I/O with type conversion", - NULL, 0); + NULL, testframe_flags); AddTest("test_attribute_io_compound", test_attribute_io_compound, NULL, - "attribute I/O with compound type conversion", NULL, 0); - AddTest("test_group", test_group, NULL, "group operations", NULL, 0); - AddTest("test_link", test_link, NULL, "link operations", NULL, 0); - AddTest("test_ocopy_orefresh", test_ocopy_orefresh, NULL, "H5Ocopy() and H5Orefresh()", NULL, 0); - AddTest("test_file_reopen", test_file_reopen, NULL, "H5Freopen()", NULL, 0); + "attribute I/O with compound type conversion", NULL, testframe_flags); + AddTest("test_group", test_group, NULL, "group operations", NULL, testframe_flags); + AddTest("test_link", test_link, NULL, "link operations", NULL, testframe_flags); + AddTest("test_ocopy_orefresh", test_ocopy_orefresh, NULL, "H5Ocopy() and H5Orefresh()", NULL, testframe_flags); + AddTest("test_file_reopen", test_file_reopen, NULL, "H5Freopen()", NULL, testframe_flags); /* Add a fake test to cleanup test files due to current test interdependencies */ - AddTest("test_file_cleanup", test_file_cleanup, NULL, "cleanup test files", NULL, 0); + AddTest("test_file_cleanup", test_file_cleanup, NULL, "cleanup test files", NULL, testframe_flags); } #else /* H5_API_TEST_HAVE_ASYNC */ @@ -2721,6 +2726,11 @@ H5_api_async_test_add(void) void H5_api_async_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_async_test_header", print_async_test_header, NULL, "Prints header for async tests", NULL, 0); } diff --git a/test/API/H5_api_attribute_test.c b/test/API/H5_api_attribute_test.c index e82d45d7c8f..c627ab34d3e 100644 --- a/test/API/H5_api_attribute_test.c +++ b/test/API/H5_api_attribute_test.c @@ -63,48 +63,6 @@ static void test_attribute_duplicate_id(void); static void test_get_number_attributes(void); static void test_attr_shared_dtype(void); -MULTI_DECLARE(test_create_attribute_on_root) -MULTI_DECLARE(test_create_attribute_on_dataset) -MULTI_DECLARE(test_create_attribute_on_datatype) -MULTI_DECLARE(test_create_attribute_with_null_space) -MULTI_DECLARE(test_create_attribute_with_scalar_space) -MULTI_DECLARE(test_create_attribute_with_space_in_name) -MULTI_DECLARE(test_create_attribute_invalid_params) -MULTI_DECLARE(test_open_attribute) -MULTI_DECLARE(test_open_attribute_invalid_params) -MULTI_DECLARE(test_write_attribute) -MULTI_DECLARE(test_write_attribute_invalid_params) -MULTI_DECLARE(test_read_attribute) -MULTI_DECLARE(test_read_attribute_invalid_params) -MULTI_DECLARE(test_read_empty_attribute) -MULTI_DECLARE(test_close_attribute_invalid_id) -MULTI_DECLARE(test_get_attribute_space_and_type) -MULTI_DECLARE(test_get_attribute_space_and_type_invalid_params) -MULTI_DECLARE(test_attribute_property_lists) -MULTI_DECLARE(test_get_attribute_name) -MULTI_DECLARE(test_get_attribute_name_invalid_params) -MULTI_DECLARE(test_get_attribute_storage_size) -MULTI_DECLARE(test_get_attribute_info) -MULTI_DECLARE(test_get_attribute_info_invalid_params) -MULTI_DECLARE(test_rename_attribute) -MULTI_DECLARE(test_rename_attribute_invalid_params) -MULTI_DECLARE(test_attribute_iterate_group) -MULTI_DECLARE(test_attribute_iterate_dataset) -MULTI_DECLARE(test_attribute_iterate_datatype) -MULTI_DECLARE(test_attribute_iterate_index_saving) -MULTI_DECLARE(test_attribute_iterate_invalid_params) -MULTI_DECLARE(test_attribute_iterate_0_attributes) -MULTI_DECLARE(test_attribute_compound_subset) -MULTI_DECLARE(test_attribute_string_encodings) -MULTI_DECLARE(test_delete_attribute) -MULTI_DECLARE(test_delete_attribute_invalid_params) -MULTI_DECLARE(test_attribute_exists) -MULTI_DECLARE(test_attribute_exists_invalid_params) -MULTI_DECLARE(test_attribute_many) -MULTI_DECLARE(test_attribute_duplicate_id) -MULTI_DECLARE(test_get_number_attributes) -MULTI_DECLARE(test_attr_shared_dtype) - static herr_t attr_iter_callback1(hid_t location_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data); static herr_t attr_iter_callback2(hid_t location_id, const char *attr_name, const H5A_info_t *ainfo, @@ -11596,82 +11554,86 @@ attr_iter_callback2(hid_t location_id, const char *attr_name, const H5A_info_t * void H5_api_attribute_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ - // TODO AddTest("print_attribute_test_header", print_attribute_test_header, NULL, "Prints header for attribute tests", NULL, 0); AddTest("test_create_attribute_on_root", MT_API_TEST_FUNC_OUTER(test_create_attribute_on_root), NULL, - "attribute creation on the root group", NULL, 0); + "attribute creation on the root group", NULL, testframe_flags); AddTest("test_create_attribute_on_dataset", MT_API_TEST_FUNC_OUTER(test_create_attribute_on_dataset), NULL, - "attribute creation on a dataset", NULL, 0); + "attribute creation on a dataset", NULL, testframe_flags); AddTest("test_create_attribute_on_datatype", MT_API_TEST_FUNC_OUTER(test_create_attribute_on_datatype), NULL, - "attribute creation on a committed datatype", NULL, 0); + "attribute creation on a committed datatype", NULL, testframe_flags); AddTest("test_create_attribute_with_null_space", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_null_space), NULL, - "attribute creation with a NULL dataspace", NULL, 0); + "attribute creation with a NULL dataspace", NULL, testframe_flags); AddTest("test_create_attribute_with_scalar_space", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_scalar_space), NULL, - "attribute creation with a SCALAR dataspace", NULL, 0); + "attribute creation with a SCALAR dataspace", NULL, testframe_flags); AddTest("test_create_attribute_with_space_in_name", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_space_in_name), NULL, - "attribute creation with a space in attribute's name", NULL, 0); + "attribute creation with a space in attribute's name", NULL, testframe_flags); AddTest("test_create_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_attribute_invalid_params), NULL, - "attribute creation with invalid parameters", NULL, 0); - AddTest("test_open_attribute", MT_API_TEST_FUNC_OUTER(test_open_attribute), NULL, "attribute opening", NULL, 0); + "attribute creation with invalid parameters", NULL, testframe_flags); + AddTest("test_open_attribute", MT_API_TEST_FUNC_OUTER(test_open_attribute), NULL, "attribute opening", NULL, testframe_flags); AddTest("test_open_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_attribute_invalid_params), NULL, - "attribute opening with invalid parameters", NULL, 0); - AddTest("test_write_attribute", MT_API_TEST_FUNC_OUTER(test_write_attribute), NULL, "H5Awrite", NULL, 0); + "attribute opening with invalid parameters", NULL, testframe_flags); + AddTest("test_write_attribute", MT_API_TEST_FUNC_OUTER(test_write_attribute), NULL, "H5Awrite", NULL, testframe_flags); AddTest("test_write_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_write_attribute_invalid_params), NULL, - "H5Awrite with invalid parameters", NULL, 0); - AddTest("test_read_attribute", MT_API_TEST_FUNC_OUTER(test_read_attribute), NULL, "H5Aread", NULL, 0); + "H5Awrite with invalid parameters", NULL, testframe_flags); + AddTest("test_read_attribute", MT_API_TEST_FUNC_OUTER(test_read_attribute), NULL, "H5Aread", NULL, testframe_flags); AddTest("test_read_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_read_attribute_invalid_params), NULL, - "H5Aread with invalid parameters", NULL, 0); - AddTest("test_read_empty_attribute", MT_API_TEST_FUNC_OUTER(test_read_empty_attribute), NULL, "reading an empty attribute", NULL, 0); + "H5Aread with invalid parameters", NULL, testframe_flags); + AddTest("test_read_empty_attribute", MT_API_TEST_FUNC_OUTER(test_read_empty_attribute), NULL, "reading an empty attribute", NULL, testframe_flags); AddTest("test_close_attribute_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_attribute_invalid_id), NULL, - "H5Aclose with an invalid attribute ID", NULL, 0); + "H5Aclose with an invalid attribute ID", NULL, testframe_flags); AddTest("test_get_attribute_space_and_type", MT_API_TEST_FUNC_OUTER(test_get_attribute_space_and_type), NULL, - "retrieval of an attribute's dataspace and datatype", NULL, 0); + "retrieval of an attribute's dataspace and datatype", NULL, testframe_flags); AddTest("test_get_attribute_space_and_type_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_attribute_space_and_type_invalid_params), NULL, - "H5Aget_type/H5Aget_space with invalid parameters", NULL, 0); + "H5Aget_type/H5Aget_space with invalid parameters", NULL, testframe_flags); AddTest("test_attribute_property_lists", MT_API_TEST_FUNC_OUTER(test_attribute_property_lists), NULL, - "attribute property list operations", NULL, 0); + "attribute property list operations", NULL, testframe_flags); AddTest("test_get_attribute_name", MT_API_TEST_FUNC_OUTER(test_get_attribute_name), NULL, "retrieval of an attribute's name", - NULL, 0); + NULL, testframe_flags); AddTest("test_get_attribute_name_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_attribute_name_invalid_params), NULL, - "retrieval of an attribute's name with invalid parameters", NULL, 0); + "retrieval of an attribute's name with invalid parameters", NULL, testframe_flags); AddTest("test_get_attribute_storage_size", MT_API_TEST_FUNC_OUTER(test_get_attribute_storage_size), NULL, "H5Aget_storage_size", - NULL, 0); - AddTest("test_get_attribute_info", MT_API_TEST_FUNC_OUTER(test_get_attribute_info), NULL, "retrieval of attribute info", NULL, 0); + NULL, testframe_flags); + AddTest("test_get_attribute_info", MT_API_TEST_FUNC_OUTER(test_get_attribute_info), NULL, "retrieval of attribute info", NULL, testframe_flags); AddTest("test_get_attribute_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_attribute_info_invalid_params), NULL, - "retrieval of attribute info with invalid parameters", NULL, 0); - AddTest("test_rename_attribute", MT_API_TEST_FUNC_OUTER(test_rename_attribute), NULL, "attribute renaming", NULL, 0); + "retrieval of attribute info with invalid parameters", NULL, testframe_flags); + AddTest("test_rename_attribute", MT_API_TEST_FUNC_OUTER(test_rename_attribute), NULL, "attribute renaming", NULL, testframe_flags); AddTest("test_rename_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_rename_attribute_invalid_params), NULL, - "attribute renaming with invalid parameters", NULL, 0); + "attribute renaming with invalid parameters", NULL, testframe_flags); AddTest("test_attribute_iterate_group", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_group), NULL, - "attribute iteration on a group", NULL, 0); + "attribute iteration on a group", NULL, testframe_flags); AddTest("test_attribute_iterate_dataset", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_dataset), NULL, - "attribute iteration on a dataset", NULL, 0); + "attribute iteration on a dataset", NULL, testframe_flags); AddTest("test_attribute_iterate_datatype", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_datatype), NULL, - "attribute iteration on a committed datatype", NULL, 0); + "attribute iteration on a committed datatype", NULL, testframe_flags); AddTest("test_attribute_iterate_index_saving", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_index_saving), NULL, - "attribute iteration index saving capability", NULL, 0); + "attribute iteration index saving capability", NULL, testframe_flags); AddTest("test_attribute_iterate_invalid_params", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_invalid_params), NULL, - "attribute iteration with invalid parameters", NULL, 0); + "attribute iteration with invalid parameters", NULL, testframe_flags); AddTest("test_attribute_iterate_0_attributes", MT_API_TEST_FUNC_OUTER(test_attribute_iterate_0_attributes), NULL, - "attribute iteration on object with 0 attributes", NULL, 0); + "attribute iteration on object with 0 attributes", NULL, testframe_flags); AddTest("test_attribute_compound_subset", MT_API_TEST_FUNC_OUTER(test_attribute_compound_subset), NULL, - "verification of attribute data using H5Awrite then H5Aread with compound type subsets", NULL, 0); + "verification of attribute data using H5Awrite then H5Aread with compound type subsets", NULL, testframe_flags); AddTest("test_attribute_string_encodings", MT_API_TEST_FUNC_OUTER(test_attribute_string_encodings), NULL, - "string encoding read/write correctness on attributes", NULL, 0); - AddTest("test_delete_attribute", MT_API_TEST_FUNC_OUTER(test_delete_attribute), NULL, "attribute deletion", NULL, 0); + "string encoding read/write correctness on attributes", NULL, testframe_flags); + AddTest("test_delete_attribute", MT_API_TEST_FUNC_OUTER(test_delete_attribute), NULL, "attribute deletion", NULL, testframe_flags); AddTest("test_delete_attribute_invalid_params", MT_API_TEST_FUNC_OUTER(test_delete_attribute_invalid_params), NULL, - "attribute deletion with invalid parameters", NULL, 0); - AddTest("test_attribute_exists", MT_API_TEST_FUNC_OUTER(test_attribute_exists), NULL, "attribute existence", NULL, 0); + "attribute deletion with invalid parameters", NULL, testframe_flags); + AddTest("test_attribute_exists", MT_API_TEST_FUNC_OUTER(test_attribute_exists), NULL, "attribute existence", NULL, testframe_flags); AddTest("test_attribute_exists_invalid_params", MT_API_TEST_FUNC_OUTER(test_attribute_exists_invalid_params), NULL, - "attribute existence with invalid parameters", NULL, 0); + "attribute existence with invalid parameters", NULL, testframe_flags); AddTest("test_attribute_duplicate_id", MT_API_TEST_FUNC_OUTER(test_attribute_duplicate_id), NULL, - "duplicated IDs for an attribute", NULL, 0); - AddTest("test_attribute_many", MT_API_TEST_FUNC_OUTER(test_attribute_many), NULL, "creating many attributes", NULL, 0); + "duplicated IDs for an attribute", NULL, testframe_flags); + AddTest("test_attribute_many", MT_API_TEST_FUNC_OUTER(test_attribute_many), NULL, "creating many attributes", NULL, testframe_flags); AddTest("test_get_number_attributes", MT_API_TEST_FUNC_OUTER(test_get_number_attributes), NULL, - "retrieval of the number of attributes on an object", NULL, 0); - AddTest("test_attr_shared_dtype", MT_API_TEST_FUNC_OUTER(test_attr_shared_dtype), NULL, "shared datatype for attributes", NULL, 0); + "retrieval of the number of attributes on an object", NULL, testframe_flags); + AddTest("test_attr_shared_dtype", MT_API_TEST_FUNC_OUTER(test_attr_shared_dtype), NULL, "shared datatype for attributes", NULL, testframe_flags); } diff --git a/test/API/H5_api_dataset_test.c b/test/API/H5_api_dataset_test.c index 84de0b5c1cb..cd0bf3f6cb6 100644 --- a/test/API/H5_api_dataset_test.c +++ b/test/API/H5_api_dataset_test.c @@ -95,81 +95,6 @@ static void test_read_partial_chunk_point_selection(void); static void test_get_vlen_buf_size(void); -MULTI_DECLARE(test_create_dataset_under_root) -MULTI_DECLARE(test_create_dataset_under_existing_group) -MULTI_DECLARE(test_create_dataset_invalid_params) -MULTI_DECLARE(test_create_anonymous_dataset) -MULTI_DECLARE(test_create_anonymous_dataset_invalid_params) -MULTI_DECLARE(test_create_dataset_null_space) -MULTI_DECLARE(test_create_dataset_scalar_space) -MULTI_DECLARE(test_create_zero_dim_dset) -MULTI_DECLARE(test_create_dataset_random_shapes) -MULTI_DECLARE(test_create_dataset_predefined_types) -MULTI_DECLARE(test_create_dataset_string_types) -MULTI_DECLARE(test_create_dataset_compound_types) -MULTI_DECLARE(test_create_dataset_enum_types) -MULTI_DECLARE(test_create_dataset_array_types) -MULTI_DECLARE(test_create_dataset_creation_properties) -MULTI_DECLARE(test_create_many_dataset) -MULTI_DECLARE(test_open_dataset) -MULTI_DECLARE(test_open_dataset_invalid_params) -MULTI_DECLARE(test_close_dataset_invalid_params) -MULTI_DECLARE(test_get_dataset_space_and_type) -MULTI_DECLARE(test_get_dataset_space_and_type_invalid_params) -MULTI_DECLARE(test_get_dataset_space_status) -MULTI_DECLARE(test_get_dataset_space_status_invalid_params) -MULTI_DECLARE(test_dataset_property_lists) -MULTI_DECLARE(test_get_dataset_storage_size) -MULTI_DECLARE(test_get_dataset_storage_size_invalid_params) -MULTI_DECLARE(test_get_dataset_chunk_storage_size) -MULTI_DECLARE(test_get_dataset_chunk_storage_size_invalid_params) -MULTI_DECLARE(test_get_dataset_offset) -MULTI_DECLARE(test_get_dataset_offset_invalid_params) -MULTI_DECLARE(test_read_dataset_small_all) -MULTI_DECLARE(test_read_dataset_small_hyperslab) -MULTI_DECLARE(test_read_dataset_small_point_selection) -MULTI_DECLARE(test_read_multi_dataset_small_all) -MULTI_DECLARE(test_read_multi_dataset_small_hyperslab) -MULTI_DECLARE(test_read_multi_dataset_small_point_selection) -MULTI_DECLARE(test_dataset_io_point_selections) -MULTI_DECLARE(test_read_dataset_invalid_params) -MULTI_DECLARE(test_write_dataset_small_all) -MULTI_DECLARE(test_write_dataset_small_hyperslab) -MULTI_DECLARE(test_write_dataset_small_point_selection) -MULTI_DECLARE(test_write_dataset_data_verification) -MULTI_DECLARE(test_write_multi_dataset_small_all) -MULTI_DECLARE(test_write_multi_dataset_small_hyperslab) -MULTI_DECLARE(test_write_multi_dataset_small_point_selection) -MULTI_DECLARE(test_write_multi_dataset_data_verification) -MULTI_DECLARE(test_write_dataset_invalid_params) -MULTI_DECLARE(test_dataset_string_encodings) -MULTI_DECLARE(test_dataset_builtin_type_conversion) -MULTI_DECLARE(test_dataset_real_to_int_conversion) -MULTI_DECLARE(test_dataset_compound_partial_io) -MULTI_DECLARE(test_dataset_vlen_io) -MULTI_DECLARE(test_dataset_set_extent_chunked_unlimited) -MULTI_DECLARE(test_dataset_set_extent_chunked_fixed) -MULTI_DECLARE(test_dataset_set_extent_data) -MULTI_DECLARE(test_dataset_set_extent_double_handles) -MULTI_DECLARE(test_dataset_set_extent_invalid_params) -MULTI_DECLARE(test_flush_dataset) -MULTI_DECLARE(test_flush_dataset_invalid_params) -MULTI_DECLARE(test_refresh_dataset) -MULTI_DECLARE(test_refresh_dataset_invalid_params) - -MULTI_DECLARE(test_create_single_chunk_dataset) -MULTI_DECLARE(test_write_single_chunk_dataset) -MULTI_DECLARE(test_create_multi_chunk_dataset) -MULTI_DECLARE(test_write_multi_chunk_dataset_same_shape_read) -MULTI_DECLARE(test_write_multi_chunk_dataset_diff_shape_read) -MULTI_DECLARE(test_overwrite_multi_chunk_dataset_same_shape_read) -MULTI_DECLARE(test_overwrite_multi_chunk_dataset_diff_shape_read) -MULTI_DECLARE(test_read_partial_chunk_all_selection) -MULTI_DECLARE(test_read_partial_chunk_hyperslab_selection) -MULTI_DECLARE(test_read_partial_chunk_point_selection) - -MULTI_DECLARE(test_get_vlen_buf_size) - static size_t filter(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, const unsigned int H5_ATTR_UNUSED cd_values[], size_t nbytes, size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf); @@ -14334,151 +14259,156 @@ test_get_vlen_buf_size(void) void H5_api_dataset_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_dataset_test_header", print_dataset_test_header, NULL, "Prints header for dataset tests", NULL, 0); AddTest("test_create_dataset_under_root", MT_API_TEST_FUNC_OUTER(test_create_dataset_under_root), NULL, - "dataset creation under root group", NULL, 0); + "dataset creation under root group", NULL, testframe_flags); AddTest("test_create_dataset_under_existing_group", MT_API_TEST_FUNC_OUTER(test_create_dataset_under_existing_group), NULL, - "dataset creation under an existing group", NULL, 0); + "dataset creation under an existing group", NULL, testframe_flags); AddTest("test_create_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_dataset_invalid_params), NULL, - "H5Dcreate with invalid parameters", NULL, 0); + "H5Dcreate with invalid parameters", NULL, testframe_flags); AddTest("test_create_anonymous_dataset", MT_API_TEST_FUNC_OUTER(test_create_anonymous_dataset), NULL, - "anonymous dataset creation", NULL, 0); + "anonymous dataset creation", NULL, testframe_flags); AddTest("test_create_anonymous_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_anonymous_dataset_invalid_params), - NULL, "anonymous dataset creation with invalid parameters", NULL, 0); + NULL, "anonymous dataset creation with invalid parameters", NULL, testframe_flags); AddTest("test_create_dataset_null_space", MT_API_TEST_FUNC_OUTER(test_create_dataset_null_space), NULL, - "dataset creation with a NULL dataspace", NULL, 0); + "dataset creation with a NULL dataspace", NULL, testframe_flags); AddTest("test_create_dataset_scalar_space", MT_API_TEST_FUNC_OUTER(test_create_dataset_scalar_space), NULL, - "dataset creation with a SCALAR dataspace", NULL, 0); + "dataset creation with a SCALAR dataspace", NULL, testframe_flags); AddTest("test_create_zero_dim_dset", MT_API_TEST_FUNC_OUTER(test_create_zero_dim_dset), NULL, "creation of 0-sized dataset", - NULL, 0); + NULL, testframe_flags); AddTest("test_create_dataset_random_shapes", MT_API_TEST_FUNC_OUTER(test_create_dataset_random_shapes), NULL, - "dataset creation with random dimension sizes", NULL, 0); + "dataset creation with random dimension sizes", NULL, testframe_flags); AddTest("test_create_dataset_predefined_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_predefined_types), NULL, - "dataset creation with predefined datatypes", NULL, 0); + "dataset creation with predefined datatypes", NULL, testframe_flags); AddTest("test_create_dataset_string_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_string_types), NULL, - "dataset creation with string types", NULL, 0); + "dataset creation with string types", NULL, testframe_flags); AddTest("test_create_dataset_compound_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_compound_types), NULL, - "dataset creation with compound datatypes", NULL, 0); + "dataset creation with compound datatypes", NULL, testframe_flags); AddTest("test_create_dataset_enum_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_enum_types), NULL, - "dataset creation with enum types", NULL, 0); + "dataset creation with enum types", NULL, testframe_flags); AddTest("test_create_dataset_array_types", MT_API_TEST_FUNC_OUTER(test_create_dataset_array_types), NULL, - "dataset creation with array types", NULL, 0); + "dataset creation with array types", NULL, testframe_flags); AddTest("test_create_dataset_creation_properties", MT_API_TEST_FUNC_OUTER(test_create_dataset_creation_properties), NULL, - "dataset creation properties", NULL, 0); - AddTest("test_create_many_dataset", MT_API_TEST_FUNC_OUTER(test_create_many_dataset), NULL, "creating many datasets", NULL, 0); - AddTest("test_open_dataset", MT_API_TEST_FUNC_OUTER(test_open_dataset), NULL, "H5Dopen", NULL, 0); + "dataset creation properties", NULL, testframe_flags); + AddTest("test_create_many_dataset", MT_API_TEST_FUNC_OUTER(test_create_many_dataset), NULL, "creating many datasets", NULL, testframe_flags); + AddTest("test_open_dataset", MT_API_TEST_FUNC_OUTER(test_open_dataset), NULL, "H5Dopen", NULL, testframe_flags); AddTest("test_open_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_dataset_invalid_params), NULL, - "H5Dopen with invalid parameters", NULL, 0); + "H5Dopen with invalid parameters", NULL, testframe_flags); AddTest("test_close_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_close_dataset_invalid_params), NULL, - "H5Dclose with an invalid dataset ID", NULL, 0); + "H5Dclose with an invalid dataset ID", NULL, testframe_flags); AddTest("test_get_dataset_space_and_type", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_and_type), NULL, - "retrieval of a dataset's dataspace and datatype", NULL, 0); + "retrieval of a dataset's dataspace and datatype", NULL, testframe_flags); AddTest("test_get_dataset_space_and_type_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_and_type_invalid_params), - NULL, "H5Dget_type/H5Dget_space with invalid parameters", NULL, 0); + NULL, "H5Dget_type/H5Dget_space with invalid parameters", NULL, testframe_flags); AddTest("test_get_dataset_space_status", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_status), NULL, "H5Dget_space_status", - NULL, 0); + NULL, testframe_flags); AddTest("test_get_dataset_space_status_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_space_status_invalid_params), - NULL, "H5Dget_space_status with invalid parameters", NULL, 0); + NULL, "H5Dget_space_status with invalid parameters", NULL, testframe_flags); AddTest("test_dataset_property_lists", MT_API_TEST_FUNC_OUTER(test_dataset_property_lists), NULL, - "dataset property list operations", NULL, 0); + "dataset property list operations", NULL, testframe_flags); AddTest("test_get_dataset_storage_size", MT_API_TEST_FUNC_OUTER(test_get_dataset_storage_size), NULL, "H5Dget_storage_size", - NULL, 0); + NULL, testframe_flags); AddTest("test_get_dataset_storage_size_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_storage_size_invalid_params), - NULL, "H5Dget_storage_size with invalid parameters", NULL, 0); + NULL, "H5Dget_storage_size with invalid parameters", NULL, testframe_flags); AddTest("test_get_dataset_chunk_storage_size", MT_API_TEST_FUNC_OUTER(test_get_dataset_chunk_storage_size), NULL, - "H5Dget_chunk_storage_size", NULL, 0); + "H5Dget_chunk_storage_size", NULL, testframe_flags); AddTest("test_get_dataset_chunk_storage_size_invalid_params", test_get_dataset_chunk_storage_size_invalid_params, NULL, - "H5Dget_chunk_storage_size with invalid parameters", NULL, 0); - AddTest("test_get_dataset_offset", MT_API_TEST_FUNC_OUTER(test_get_dataset_offset), NULL, "H5Dget_offset", NULL, 0); + "H5Dget_chunk_storage_size with invalid parameters", NULL, testframe_flags); + AddTest("test_get_dataset_offset", MT_API_TEST_FUNC_OUTER(test_get_dataset_offset), NULL, "H5Dget_offset", NULL, testframe_flags); AddTest("test_get_dataset_offset_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_dataset_offset_invalid_params), NULL, - "H5Dget_offset with invalid parameters", NULL, 0); + "H5Dget_offset with invalid parameters", NULL, testframe_flags); AddTest("test_read_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_read_dataset_small_all), NULL, - "small read from dataset with H5S_ALL", NULL, 0); + "small read from dataset with H5S_ALL", NULL, testframe_flags); AddTest("test_read_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_read_dataset_small_hyperslab), NULL, - "small read from dataset with a hyperslab selection", NULL, 0); + "small read from dataset with a hyperslab selection", NULL, testframe_flags); AddTest("test_read_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_read_dataset_small_point_selection), NULL, - "small read from dataset with a point selection", NULL, 0); + "small read from dataset with a point selection", NULL, testframe_flags); AddTest("test_read_multi_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_read_multi_dataset_small_all), NULL, - "small multi read from datasets with H5S_ALL", NULL, 0); + "small multi read from datasets with H5S_ALL", NULL, testframe_flags); AddTest("test_read_multi_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_read_multi_dataset_small_hyperslab), NULL, - "small multi read from datasets with a hyperslab selection", NULL, 0); + "small multi read from datasets with a hyperslab selection", NULL, testframe_flags); AddTest("test_read_multi_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_read_multi_dataset_small_point_selection), - NULL, "small multi read from datasets with point selections", NULL, 0); + NULL, "small multi read from datasets with point selections", NULL, testframe_flags); AddTest("test_dataset_io_point_selections", MT_API_TEST_FUNC_OUTER(test_dataset_io_point_selections), NULL, - "point selection I/O with all selection in memory and points in file", NULL, 0); + "point selection I/O with all selection in memory and points in file", NULL, testframe_flags); AddTest("test_read_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_read_dataset_invalid_params), NULL, - "H5Dread with invalid parameters", NULL, 0); + "H5Dread with invalid parameters", NULL, testframe_flags); AddTest("test_dataset_string_encodings", MT_API_TEST_FUNC_OUTER(test_dataset_string_encodings), NULL, - "string encoding read/write correctness on datasets", NULL, 0); + "string encoding read/write correctness on datasets", NULL, testframe_flags); AddTest("test_write_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_write_dataset_small_all), NULL, - "small write to dataset with H5S_ALL", NULL, 0); + "small write to dataset with H5S_ALL", NULL, testframe_flags); AddTest("test_write_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_write_dataset_small_hyperslab), NULL, - "small write to dataset with a hyperslab selection", NULL, 0); + "small write to dataset with a hyperslab selection", NULL, testframe_flags); AddTest("test_write_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_write_dataset_small_point_selection), NULL, - "small write to dataset with a point selection", NULL, 0); + "small write to dataset with a point selection", NULL, testframe_flags); AddTest("test_write_dataset_data_verification", MT_API_TEST_FUNC_OUTER(test_write_dataset_data_verification), NULL, - "verification of dataset data using H5Dwrite then H5Dread", NULL, 0); + "verification of dataset data using H5Dwrite then H5Dread", NULL, testframe_flags); AddTest("test_write_multi_dataset_small_all", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_small_all), NULL, - "small multi write to datasets with H5S_ALL", NULL, 0); + "small multi write to datasets with H5S_ALL", NULL, testframe_flags); AddTest("test_write_multi_dataset_small_hyperslab", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_small_hyperslab), NULL, - "small multi write to datasets with hyperslab selections", NULL, 0); + "small multi write to datasets with hyperslab selections", NULL, testframe_flags); AddTest("test_write_multi_dataset_small_point_selection", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_small_point_selection), - NULL, "small multi write to datasets with point selections", NULL, 0); + NULL, "small multi write to datasets with point selections", NULL, testframe_flags); AddTest("test_write_multi_dataset_data_verification", MT_API_TEST_FUNC_OUTER(test_write_multi_dataset_data_verification), NULL, - "verification of datasets' data using H5Dwrite_multi then H5Dread_multi", NULL, 0); + "verification of datasets' data using H5Dwrite_multi then H5Dread_multi", NULL, testframe_flags); AddTest("test_write_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_write_dataset_invalid_params), NULL, - "H5Dwrite with invalid parameters", NULL, 0); + "H5Dwrite with invalid parameters", NULL, testframe_flags); AddTest("test_dataset_builtin_type_conversion", MT_API_TEST_FUNC_OUTER(test_dataset_builtin_type_conversion), NULL, "verification of dataset data using H5Dwrite then H5Dread with type conversion of builtin types", - NULL, 0); + NULL, testframe_flags); AddTest("test_dataset_real_to_int_conversion", MT_API_TEST_FUNC_OUTER(test_dataset_real_to_int_conversion), NULL, "verification of dataset data using H5Dwrite then H5Dread with real <-> integer type conversion", - NULL, 0); + NULL, testframe_flags); AddTest("test_dataset_compound_partial_io", MT_API_TEST_FUNC_OUTER(test_dataset_compound_partial_io), NULL, "verification of dataset data using H5Dwrite then H5Dread with partial element compound type I/O", - NULL, 0); + NULL, testframe_flags); AddTest("test_dataset_vlen_io", MT_API_TEST_FUNC_OUTER(test_dataset_vlen_io), NULL, "verification of dataset data with H5Dwrite and then H5D read with variable length sequence data", - NULL, 0); + NULL, testframe_flags); AddTest("test_dataset_set_extent_chunked_unlimited", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_chunked_unlimited), NULL, - "H5Dset_extent on chunked dataset with unlimited dimensions", NULL, 0); + "H5Dset_extent on chunked dataset with unlimited dimensions", NULL, testframe_flags); AddTest("test_dataset_set_extent_chunked_fixed", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_chunked_fixed), NULL, - "H5Dset_extent on chunked dataset with fixed dimensions", NULL, 0); + "H5Dset_extent on chunked dataset with fixed dimensions", NULL, testframe_flags); AddTest("test_dataset_set_extent_data", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_data), NULL, - "H5Dset_extent on data correctness", NULL, 0); + "H5Dset_extent on data correctness", NULL, testframe_flags); AddTest("test_dataset_set_extent_double_handles", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_double_handles), NULL, - "H5Dset_extent on double dataset handles", NULL, 0); + "H5Dset_extent on double dataset handles", NULL, testframe_flags); AddTest("test_dataset_set_extent_invalid_params", MT_API_TEST_FUNC_OUTER(test_dataset_set_extent_invalid_params), NULL, - "H5Dset_extent with invalid parameters", NULL, 0); - AddTest("test_flush_dataset", MT_API_TEST_FUNC_OUTER(test_flush_dataset), NULL, "H5Dflush", NULL, 0); + "H5Dset_extent with invalid parameters", NULL, testframe_flags); + AddTest("test_flush_dataset", MT_API_TEST_FUNC_OUTER(test_flush_dataset), NULL, "H5Dflush", NULL, testframe_flags); AddTest("test_flush_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_dataset_invalid_params), NULL, - "H5Dflush with invalid parameters", NULL, 0); - AddTest("test_refresh_dataset", MT_API_TEST_FUNC_OUTER(test_refresh_dataset), NULL, "H5Drefresh", NULL, 0); + "H5Dflush with invalid parameters", NULL, testframe_flags); + AddTest("test_refresh_dataset", MT_API_TEST_FUNC_OUTER(test_refresh_dataset), NULL, "H5Drefresh", NULL, testframe_flags); AddTest("test_refresh_dataset_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_dataset_invalid_params), NULL, - "H5Drefresh with invalid parameters", NULL, 0); + "H5Drefresh with invalid parameters", NULL, testframe_flags); AddTest("test_create_single_chunk_dataset", MT_API_TEST_FUNC_OUTER(test_create_single_chunk_dataset), NULL, - "creation of dataset with single chunk", NULL, 0); + "creation of dataset with single chunk", NULL, testframe_flags); AddTest("test_write_single_chunk_dataset", MT_API_TEST_FUNC_OUTER(test_write_single_chunk_dataset), NULL, - "write to dataset with single chunk", NULL, 0); + "write to dataset with single chunk", NULL, testframe_flags); AddTest("test_create_multi_chunk_dataset", MT_API_TEST_FUNC_OUTER(test_create_multi_chunk_dataset), NULL, - "creation of dataset with multiple chunks", NULL, 0); + "creation of dataset with multiple chunks", NULL, testframe_flags); AddTest("test_write_multi_chunk_dataset_same_shape_read", MT_API_TEST_FUNC_OUTER(test_write_multi_chunk_dataset_same_shape_read), - NULL, "write to dataset with multiple chunks using same shaped dataspaces", NULL, 0); + NULL, "write to dataset with multiple chunks using same shaped dataspaces", NULL, testframe_flags); AddTest("test_write_multi_chunk_dataset_diff_shape_read", MT_API_TEST_FUNC_OUTER(test_write_multi_chunk_dataset_diff_shape_read), - NULL, "write to dataset with multiple chunks using differently shaped dataspaces", NULL, 0); + NULL, "write to dataset with multiple chunks using differently shaped dataspaces", NULL, testframe_flags); AddTest("test_overwrite_multi_chunk_dataset_same_shape_read", MT_API_TEST_FUNC_OUTER(test_overwrite_multi_chunk_dataset_same_shape_read), NULL, - "several overwrites to dataset with multiple chunks using same shaped dataspaces", NULL, 0); + "several overwrites to dataset with multiple chunks using same shaped dataspaces", NULL, testframe_flags); AddTest("test_overwrite_multi_chunk_dataset_diff_shape_read", MT_API_TEST_FUNC_OUTER(test_overwrite_multi_chunk_dataset_diff_shape_read), NULL, - "several overwrites to dataset with multiple chunks using differently shaped dataspaces", NULL, 0); + "several overwrites to dataset with multiple chunks using differently shaped dataspaces", NULL, testframe_flags); AddTest("test_read_partial_chunk_all_selection", MT_API_TEST_FUNC_OUTER(test_read_partial_chunk_all_selection), NULL, - "reading a partial chunk using H5S_ALL for file dataspace", NULL, 0); + "reading a partial chunk using H5S_ALL for file dataspace", NULL, testframe_flags); AddTest("test_read_partial_chunk_hyperslab_selection", MT_API_TEST_FUNC_OUTER(test_read_partial_chunk_hyperslab_selection), NULL, - "reading a partial chunk using a hyperslab selection in file dataspace", NULL, 0); + "reading a partial chunk using a hyperslab selection in file dataspace", NULL, testframe_flags); AddTest("test_read_partial_chunk_point_selection", MT_API_TEST_FUNC_OUTER(test_read_partial_chunk_point_selection), NULL, - "reading a partial chunk using a point selection in file dataspace", NULL, 0); - AddTest("test_get_vlen_buf_size", MT_API_TEST_FUNC_OUTER(test_get_vlen_buf_size), NULL, "H5Dvlen_get_buf_size", NULL, 0); + "reading a partial chunk using a point selection in file dataspace", NULL, testframe_flags); + AddTest("test_get_vlen_buf_size", MT_API_TEST_FUNC_OUTER(test_get_vlen_buf_size), NULL, "H5Dvlen_get_buf_size", NULL, testframe_flags); } diff --git a/test/API/H5_api_datatype_test.c b/test/API/H5_api_datatype_test.c index 87feefab5ca..9eaf32bbd5b 100644 --- a/test/API/H5_api_datatype_test.c +++ b/test/API/H5_api_datatype_test.c @@ -44,32 +44,6 @@ static void test_cant_commit_predefined(void); #endif static void test_cant_modify_committed_type(void); -MULTI_DECLARE(test_create_committed_datatype) -MULTI_DECLARE(test_create_committed_datatype_invalid_params) -MULTI_DECLARE(test_create_anonymous_committed_datatype) -MULTI_DECLARE(test_create_anonymous_committed_datatype_invalid_params) -#ifndef PROBLEMATIC_TESTS -MULTI_DECLARE(test_create_committed_datatype_empty_types) -#endif -MULTI_DECLARE(test_recommit_committed_type) -MULTI_DECLARE(test_open_committed_datatype) -MULTI_DECLARE(test_open_committed_datatype_invalid_params) -MULTI_DECLARE(test_reopen_committed_datatype_indirect) -MULTI_DECLARE(test_close_committed_datatype_invalid_id) -MULTI_DECLARE(test_datatype_property_lists) -MULTI_DECLARE(test_create_dataset_with_committed_type) -MULTI_DECLARE(test_create_attribute_with_committed_type) -MULTI_DECLARE(test_delete_committed_type) -MULTI_DECLARE(test_resurrect_datatype) -MULTI_DECLARE(test_flush_committed_datatype) -MULTI_DECLARE(test_flush_committed_datatype_invalid_params) -MULTI_DECLARE(test_refresh_committed_datatype) -MULTI_DECLARE(test_refresh_committed_datatype_invalid_params) -#ifndef PROBLEMATIC_TESTS -MULTI_DECLARE(test_cant_commit_predefined) -#endif -MULTI_DECLARE(test_cant_modify_committed_type) - static void print_datatype_test_header(void) { @@ -2668,56 +2642,61 @@ test_cant_modify_committed_type(void) void H5_api_datatype_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_datatype_test_header", print_datatype_test_header, NULL, "Prints header for datatype tests", NULL, 0); AddTest("test_create_committed_datatype", MT_API_TEST_FUNC_OUTER(test_create_committed_datatype), NULL, - "creation of a committed datatype", NULL, 0); + "creation of a committed datatype", NULL, testframe_flags); AddTest("test_create_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_committed_datatype_invalid_params), - NULL, "H5Tcommit2 with invalid parameters", NULL, 0); + NULL, "H5Tcommit2 with invalid parameters", NULL, testframe_flags); AddTest("test_create_anonymous_committed_datatype", MT_API_TEST_FUNC_OUTER(test_create_anonymous_committed_datatype), NULL, - "creation of anonymous committed datatype", NULL, 0); + "creation of anonymous committed datatype", NULL, testframe_flags); AddTest("test_create_anonymous_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_anonymous_committed_datatype_invalid_params), NULL, - "H5Tcommit_anon with invalid parameters", NULL, 0); + "H5Tcommit_anon with invalid parameters", NULL, testframe_flags); #ifndef PROBLEMATIC_TESTS AddTest("test_create_committed_datatype_empty_types", MT_API_TEST_FUNC_OUTER(test_create_committed_datatype_empty_types), NULL, - "creation of committed datatype with empty types", NULL, 0); + "creation of committed datatype with empty types", NULL, testframe_flags); #endif AddTest("test_recommit_committed_type", MT_API_TEST_FUNC_OUTER(test_recommit_committed_type), NULL, - "inability to re-commit a committed datatype", NULL, 0); - AddTest("test_open_committed_datatype", MT_API_TEST_FUNC_OUTER(test_open_committed_datatype), NULL, "H5Topen2", NULL, 0); + "inability to re-commit a committed datatype", NULL, testframe_flags); + AddTest("test_open_committed_datatype", MT_API_TEST_FUNC_OUTER(test_open_committed_datatype), NULL, "H5Topen2", NULL, testframe_flags); AddTest("test_open_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_committed_datatype_invalid_params), NULL, - "H5Topen2 with invalid parameters", NULL, 0); + "H5Topen2 with invalid parameters", NULL, testframe_flags); AddTest("test_reopen_committed_datatype_indirect", MT_API_TEST_FUNC_OUTER(test_reopen_committed_datatype_indirect), NULL, - "reopening open committed datatypes using H5Dget_type", NULL, 0); + "reopening open committed datatypes using H5Dget_type", NULL, testframe_flags); AddTest("test_close_committed_datatype_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_committed_datatype_invalid_id), NULL, - "H5Tclose with an invalid committed datatype ID", NULL, 0); + "H5Tclose with an invalid committed datatype ID", NULL, testframe_flags); AddTest("test_datatype_property_lists", MT_API_TEST_FUNC_OUTER(test_datatype_property_lists), NULL, - "datatype property list operations", NULL, 0); + "datatype property list operations", NULL, testframe_flags); AddTest("test_create_dataset_with_committed_type", MT_API_TEST_FUNC_OUTER(test_create_dataset_with_committed_type), NULL, - "dataset creation with a committed datatype", NULL, 0); + "dataset creation with a committed datatype", NULL, testframe_flags); AddTest("test_create_attribute_with_committed_type", MT_API_TEST_FUNC_OUTER(test_create_attribute_with_committed_type), NULL, - "attribute creation with a committed datatype", NULL, 0); + "attribute creation with a committed datatype", NULL, testframe_flags); AddTest("test_delete_committed_type", MT_API_TEST_FUNC_OUTER(test_delete_committed_type), NULL, "committed datatype deletion", - NULL, 0); + NULL, testframe_flags); AddTest("test_resurrect_datatype", MT_API_TEST_FUNC_OUTER(test_resurrect_datatype), NULL, "resurrecting datatype after deletion", - NULL, 0); - AddTest("test_flush_committed_datatype", MT_API_TEST_FUNC_OUTER(test_flush_committed_datatype), NULL, "H5Tflush", NULL, 0); + NULL, testframe_flags); + AddTest("test_flush_committed_datatype", MT_API_TEST_FUNC_OUTER(test_flush_committed_datatype), NULL, "H5Tflush", NULL, testframe_flags); AddTest("test_flush_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_committed_datatype_invalid_params), - NULL, "H5Tflush with invalid parameters", NULL, 0); - AddTest("test_refresh_committed_datatype", MT_API_TEST_FUNC_OUTER(test_refresh_committed_datatype), NULL, "H5Trefresh", NULL, 0); + NULL, "H5Tflush with invalid parameters", NULL, testframe_flags); + AddTest("test_refresh_committed_datatype", MT_API_TEST_FUNC_OUTER(test_refresh_committed_datatype), NULL, "H5Trefresh", NULL, testframe_flags); AddTest("test_refresh_committed_datatype_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_committed_datatype_invalid_params), - NULL, "H5Trefresh with invalid parameters", NULL, 0); + NULL, "H5Trefresh with invalid parameters", NULL, testframe_flags); #ifndef PROBLEMATIC_TESTS AddTest("test_cant_commit_predefined", MT_API_TEST_FUNC_OUTER(test_cant_commit_predefined), NULL, - "inability to commit predefined types directly", NULL, 0); + "inability to commit predefined types directly", NULL, testframe_flags); #endif AddTest("test_cant_modify_committed_type", MT_API_TEST_FUNC_OUTER(test_cant_modify_committed_type), NULL, - "inability to modify a committed datatype", NULL, 0); + "inability to modify a committed datatype", NULL, testframe_flags); } diff --git a/test/API/H5_api_file_test.c b/test/API/H5_api_file_test.c index ddfc22a95cd..4696885f0d8 100644 --- a/test/API/H5_api_file_test.c +++ b/test/API/H5_api_file_test.c @@ -32,24 +32,6 @@ static void test_file_mounts(void); static void test_get_file_name(void); static herr_t check_open_obj_count(ssize_t obj_count, int expected); -MULTI_DECLARE(test_create_file) -MULTI_DECLARE(test_create_file_invalid_params) -MULTI_DECLARE(test_create_file_excl) -MULTI_DECLARE(test_open_file) -MULTI_DECLARE(test_open_file_invalid_params) -MULTI_DECLARE(test_open_nonexistent_file) -MULTI_DECLARE(test_file_open_overlap) -MULTI_DECLARE(test_file_permission) -MULTI_DECLARE(test_reopen_file) -MULTI_DECLARE(test_close_file_invalid_id) -MULTI_DECLARE(test_flush_file) -MULTI_DECLARE(test_file_is_accessible) -MULTI_DECLARE(test_file_property_lists) -MULTI_DECLARE(test_get_file_intent) -MULTI_DECLARE(test_get_file_obj_count) -MULTI_DECLARE(test_file_mounts) -MULTI_DECLARE(test_get_file_name) - static void print_file_test_header(void) { @@ -79,7 +61,7 @@ test_create_file(void) return; } - if (prefix_filename(test_path_prefix, FILE_CREATE_TEST_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_CREATE_TEST_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -135,7 +117,7 @@ test_create_file_invalid_params(void) return; } - if (prefix_filename(test_path_prefix, FILE_CREATE_INVALID_PARAMS_FILE_NAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_CREATE_INVALID_PARAMS_FILE_NAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -287,7 +269,7 @@ test_create_file_excl(void) return; } - if (prefix_filename(test_path_prefix, FILE_CREATE_EXCL_FILE_NAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_CREATE_EXCL_FILE_NAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -554,7 +536,7 @@ test_open_nonexistent_file(void) return; } - if (prefix_filename(test_path_prefix, NONEXISTENT_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, NONEXISTENT_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -628,7 +610,7 @@ test_file_permission(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, FILE_PERMISSION_TEST_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_PERMISSION_TEST_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -950,7 +932,7 @@ test_flush_file(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, FILE_FLUSH_TEST_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_FLUSH_TEST_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -1067,7 +1049,7 @@ test_file_is_accessible(void) return; } - if (prefix_filename(test_path_prefix, fake_filename, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, fake_filename, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -1165,12 +1147,12 @@ test_file_property_lists(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, FILE_PROPERTY_LIST_TEST_FNAME1, &prefixed_filename1) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_PROPERTY_LIST_TEST_FNAME1, &prefixed_filename1) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; } - if (prefix_filename(test_path_prefix, FILE_PROPERTY_LIST_TEST_FNAME2, &prefixed_filename2) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_PROPERTY_LIST_TEST_FNAME2, &prefixed_filename2) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -1465,7 +1447,7 @@ test_get_file_intent(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, FILE_INTENT_TEST_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_INTENT_TEST_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -1645,12 +1627,12 @@ test_get_file_obj_count(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, GET_OBJ_COUNT_TEST_FILENAME1, &prefixed_filename1) < 0) { + if (prefix_filename(test_path_prefix_g, GET_OBJ_COUNT_TEST_FILENAME1, &prefixed_filename1) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; } - if (prefix_filename(test_path_prefix, GET_OBJ_COUNT_TEST_FILENAME2, &prefixed_filename2) < 0) { + if (prefix_filename(test_path_prefix_g, GET_OBJ_COUNT_TEST_FILENAME2, &prefixed_filename2) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -1993,7 +1975,7 @@ test_file_open_overlap(void) return; } - if (prefix_filename(test_path_prefix, OVERLAPPING_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, OVERLAPPING_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -2131,7 +2113,7 @@ test_file_mounts(void) return; } - if (prefix_filename(test_path_prefix, FILE_MOUNT_TEST_FILENAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, FILE_MOUNT_TEST_FILENAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -2232,7 +2214,7 @@ test_get_file_name(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, GET_FILE_NAME_TEST_FNAME, &prefixed_filename) < 0) { + if (prefix_filename(test_path_prefix_g, GET_FILE_NAME_TEST_FNAME, &prefixed_filename) < 0) { H5_FAILED(); printf(" couldn't prefix filename\n"); goto error; @@ -2577,33 +2559,38 @@ check_open_obj_count(ssize_t obj_count, int expected) { void H5_api_file_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_file_test_header", print_file_test_header, NULL, "Prints header for file tests", NULL, 0); - AddTest("test_create_file", MT_API_TEST_FUNC_OUTER(test_create_file), NULL, "H5Fcreate", NULL, 0); + AddTest("test_create_file", MT_API_TEST_FUNC_OUTER(test_create_file), NULL, "H5Fcreate", NULL, testframe_flags); AddTest("test_create_file_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_file_invalid_params), NULL, - "H5Fcreate with invalid parameters", NULL, 0); + "H5Fcreate with invalid parameters", NULL, testframe_flags); AddTest("test_create_file_excl", MT_API_TEST_FUNC_OUTER(test_create_file_excl), NULL, - "H5Fcreate with H5F_ACC_EXCL/H5F_ACC_TRUNC flag", NULL, 0); - AddTest("test_open_file", MT_API_TEST_FUNC_OUTER(test_open_file), NULL, "H5Fopen", NULL, 0); + "H5Fcreate with H5F_ACC_EXCL/H5F_ACC_TRUNC flag", NULL, testframe_flags); + AddTest("test_open_file", MT_API_TEST_FUNC_OUTER(test_open_file), NULL, "H5Fopen", NULL, testframe_flags); AddTest("test_open_file_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_file_invalid_params), NULL, - "H5Fopen with invalid parameters", NULL, 0); + "H5Fopen with invalid parameters", NULL, testframe_flags); AddTest("test_open_nonexistent_file", MT_API_TEST_FUNC_OUTER(test_open_nonexistent_file), NULL, - "for invalid opening of a non-existent file", NULL, 0); - AddTest("test_file_open_overlap", MT_API_TEST_FUNC_OUTER(test_file_open_overlap), NULL, "overlapping file opens", NULL, 0); + "for invalid opening of a non-existent file", NULL, testframe_flags); + AddTest("test_file_open_overlap", MT_API_TEST_FUNC_OUTER(test_file_open_overlap), NULL, "overlapping file opens", NULL, testframe_flags); AddTest("test_file_permission", MT_API_TEST_FUNC_OUTER(test_file_permission), NULL, - "file permissions (invalid creation of objects in read-only file)", NULL, 0); - AddTest("test_reopen_file", MT_API_TEST_FUNC_OUTER(test_reopen_file), NULL, "re-open of a file with H5Freopen", NULL, 0); + "file permissions (invalid creation of objects in read-only file)", NULL, testframe_flags); + AddTest("test_reopen_file", MT_API_TEST_FUNC_OUTER(test_reopen_file), NULL, "re-open of a file with H5Freopen", NULL, testframe_flags); AddTest("test_close_file_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_file_invalid_id), NULL, "H5Fclose with an invalid ID", - NULL, 0); - AddTest("test_flush_file", MT_API_TEST_FUNC_OUTER(test_flush_file), NULL, "H5Fflush", NULL, 0); - AddTest("test_file_is_accessible", MT_API_TEST_FUNC_OUTER(test_file_is_accessible), NULL, "H5Fis_accessible", NULL, 0); + NULL, testframe_flags); + AddTest("test_flush_file", MT_API_TEST_FUNC_OUTER(test_flush_file), NULL, "H5Fflush", NULL, testframe_flags); + AddTest("test_file_is_accessible", MT_API_TEST_FUNC_OUTER(test_file_is_accessible), NULL, "H5Fis_accessible", NULL, testframe_flags); AddTest("test_file_property_lists", MT_API_TEST_FUNC_OUTER(test_file_property_lists), NULL, "file property list operations", - NULL, 0); + NULL, testframe_flags); AddTest("test_get_file_intent", MT_API_TEST_FUNC_OUTER(test_get_file_intent), NULL, "retrieval of file intent with H5Fget_intent", - NULL, 0); + NULL, testframe_flags); AddTest("test_get_file_obj_count", MT_API_TEST_FUNC_OUTER(test_get_file_obj_count), NULL, - "retrieval of open object number and IDs", NULL, 0); - AddTest("test_file_mounts", MT_API_TEST_FUNC_OUTER(test_file_mounts), NULL, "file mounting/unmounting", NULL, 0); - AddTest("test_get_file_name", MT_API_TEST_FUNC_OUTER(test_get_file_name), NULL, "retrieval of file name", NULL, 0); + "retrieval of open object number and IDs", NULL, testframe_flags); + AddTest("test_file_mounts", MT_API_TEST_FUNC_OUTER(test_file_mounts), NULL, "file mounting/unmounting", NULL, testframe_flags); + AddTest("test_get_file_name", MT_API_TEST_FUNC_OUTER(test_get_file_name), NULL, "retrieval of file name", NULL, testframe_flags); } diff --git a/test/API/H5_api_group_test.c b/test/API/H5_api_group_test.c index db9992ddcb6..25da5cb18a1 100644 --- a/test/API/H5_api_group_test.c +++ b/test/API/H5_api_group_test.c @@ -33,25 +33,6 @@ static void test_refresh_group(void); static void test_refresh_group_invalid_params(void); static int create_group_recursive(hid_t parent_gid, unsigned counter); -MULTI_DECLARE(test_create_group_under_root) -MULTI_DECLARE(test_create_group_under_existing_group) -MULTI_DECLARE(test_create_many_groups) -MULTI_DECLARE(test_create_deep_groups) -MULTI_DECLARE(test_create_intermediate_group) -MULTI_DECLARE(test_create_group_invalid_params) -MULTI_DECLARE(test_create_anonymous_group) -MULTI_DECLARE(test_create_anonymous_group_invalid_params) -MULTI_DECLARE(test_open_nonexistent_group) -MULTI_DECLARE(test_open_group_invalid_params) -MULTI_DECLARE(test_close_group_invalid_id) -MULTI_DECLARE(test_group_property_lists) -MULTI_DECLARE(test_get_group_info) -MULTI_DECLARE(test_get_group_info_invalid_params) -MULTI_DECLARE(test_flush_group) -MULTI_DECLARE(test_flush_group_invalid_params) -MULTI_DECLARE(test_refresh_group) -MULTI_DECLARE(test_refresh_group_invalid_params) - static void print_group_test_header(void) { @@ -2392,39 +2373,44 @@ test_refresh_group_invalid_params(void) void H5_api_group_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_group_test_header", print_group_test_header, NULL, "Prints header for group tests", NULL, 0); AddTest("test_create_group_under_root", MT_API_TEST_FUNC_OUTER(test_create_group_under_root), NULL, - "creation of group under the root group", NULL, 0); + "creation of group under the root group", NULL, testframe_flags); AddTest("test_create_group_under_existing_group", MT_API_TEST_FUNC_OUTER(test_create_group_under_existing_group), NULL, - "creation of group under existing group using a relative path", NULL, 0); - AddTest("test_create_many_groups", MT_API_TEST_FUNC_OUTER(test_create_many_groups), NULL, "H5Gcreate many groups", NULL, 0); + "creation of group under existing group using a relative path", NULL, testframe_flags); + AddTest("test_create_many_groups", MT_API_TEST_FUNC_OUTER(test_create_many_groups), NULL, "H5Gcreate many groups", NULL, testframe_flags); AddTest("test_create_deep_groups", MT_API_TEST_FUNC_OUTER(test_create_deep_groups), NULL, "H5Gcreate groups of great depths", - NULL, 0); + NULL, testframe_flags); AddTest("test_create_intermediate_group", MT_API_TEST_FUNC_OUTER(test_create_intermediate_group), NULL, - "H5Gcreate group with intermediate group creation", NULL, 0); + "H5Gcreate group with intermediate group creation", NULL, testframe_flags); AddTest("test_create_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_group_invalid_params), NULL, - "H5Gcreate with invalid parameters", NULL, 0); + "H5Gcreate with invalid parameters", NULL, testframe_flags); AddTest("test_create_anonymous_group", MT_API_TEST_FUNC_OUTER(test_create_anonymous_group), NULL, "creation of anonymous group", - NULL, 0); + NULL, testframe_flags); AddTest("test_create_anonymous_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_anonymous_group_invalid_params), NULL, - "H5Gcreate_anon with invalid parameters", NULL, 0); + "H5Gcreate_anon with invalid parameters", NULL, testframe_flags); AddTest("test_open_nonexistent_group", MT_API_TEST_FUNC_OUTER(test_open_nonexistent_group), NULL, - "for invalid opening of a nonexistent group", NULL, 0); + "for invalid opening of a nonexistent group", NULL, testframe_flags); AddTest("test_open_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_group_invalid_params), NULL, - "H5Gopen with invalid parameters", NULL, 0); + "H5Gopen with invalid parameters", NULL, testframe_flags); AddTest("test_close_group_invalid_id", MT_API_TEST_FUNC_OUTER(test_close_group_invalid_id), NULL, - "H5Gclose with an invalid group ID", NULL, 0); + "H5Gclose with an invalid group ID", NULL, testframe_flags); AddTest("test_group_property_lists", MT_API_TEST_FUNC_OUTER(test_group_property_lists), NULL, "group property list operations", - NULL, 0); - AddTest("test_get_group_info", MT_API_TEST_FUNC_OUTER(test_get_group_info), NULL, "retrieval of group info", NULL, 0); + NULL, testframe_flags); + AddTest("test_get_group_info", MT_API_TEST_FUNC_OUTER(test_get_group_info), NULL, "retrieval of group info", NULL, testframe_flags); AddTest("test_get_group_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_group_info_invalid_params), NULL, - "retrieval of group info with invalid parameters", NULL, 0); - AddTest("test_flush_group", MT_API_TEST_FUNC_OUTER(test_flush_group), NULL, "H5Gflush", NULL, 0); + "retrieval of group info with invalid parameters", NULL, testframe_flags); + AddTest("test_flush_group", MT_API_TEST_FUNC_OUTER(test_flush_group), NULL, "H5Gflush", NULL, testframe_flags); AddTest("test_flush_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_group_invalid_params), NULL, - "H5Gflush with invalid parameters", NULL, 0); - AddTest("test_refresh_group", MT_API_TEST_FUNC_OUTER(test_refresh_group), NULL, "H5Grefresh", NULL, 0); + "H5Gflush with invalid parameters", NULL, testframe_flags); + AddTest("test_refresh_group", MT_API_TEST_FUNC_OUTER(test_refresh_group), NULL, "H5Grefresh", NULL, testframe_flags); AddTest("test_refresh_group_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_group_invalid_params), NULL, - "H5Grefresh with invalid parameters", NULL, 0); + "H5Grefresh with invalid parameters", NULL, testframe_flags); } diff --git a/test/API/H5_api_link_test.c b/test/API/H5_api_link_test.c index b393c7c4b00..1e96f14db7d 100644 --- a/test/API/H5_api_link_test.c +++ b/test/API/H5_api_link_test.c @@ -74,63 +74,6 @@ static void test_link_visit_mixed_links_cycles(void); static void test_link_visit_invalid_params(void); static void test_link_visit_0_links(void); -MULTI_DECLARE(test_create_hard_link) -MULTI_DECLARE(test_create_hard_link_long_name) -MULTI_DECLARE(test_create_hard_link_many) -MULTI_DECLARE(test_create_hard_link_same_loc) -MULTI_DECLARE(test_create_hard_link_invalid_params) -MULTI_DECLARE(test_create_soft_link_existing_relative) -MULTI_DECLARE(test_create_soft_link_existing_absolute) -MULTI_DECLARE(test_create_soft_link_dangling_relative) -MULTI_DECLARE(test_create_soft_link_dangling_absolute) -MULTI_DECLARE(test_create_soft_link_long_name) -MULTI_DECLARE(test_create_soft_link_many) -MULTI_DECLARE(test_create_soft_link_invalid_params) -MULTI_DECLARE(test_create_external_link) -MULTI_DECLARE(test_create_external_link_dangling) -MULTI_DECLARE(test_create_external_link_multi) -MULTI_DECLARE(test_create_external_link_ping_pong) -MULTI_DECLARE(test_create_external_link_invalid_params) -MULTI_DECLARE(test_create_user_defined_link) -MULTI_DECLARE(test_create_user_defined_link_invalid_params) -MULTI_DECLARE(test_delete_link) -MULTI_DECLARE(test_delete_link_reset_grp_max_crt_order) -MULTI_DECLARE(test_delete_link_invalid_params) -MULTI_DECLARE(test_copy_link) -MULTI_DECLARE(test_copy_links_into_group_with_links) -MULTI_DECLARE(test_copy_link_across_files) -MULTI_DECLARE(test_copy_link_invalid_params) -MULTI_DECLARE(test_move_link) -MULTI_DECLARE(test_move_links_into_group_with_links) -MULTI_DECLARE(test_move_link_across_files) -MULTI_DECLARE(test_move_link_reset_grp_max_crt_order) -MULTI_DECLARE(test_move_link_invalid_params) -MULTI_DECLARE(test_get_link_val) -MULTI_DECLARE(test_get_link_val_invalid_params) -MULTI_DECLARE(test_get_link_info) -MULTI_DECLARE(test_get_link_info_invalid_params) -MULTI_DECLARE(test_get_link_name) -MULTI_DECLARE(test_get_link_name_invalid_params) -MULTI_DECLARE(test_link_iterate_hard_links) -MULTI_DECLARE(test_link_iterate_soft_links) -MULTI_DECLARE(test_link_iterate_external_links) -MULTI_DECLARE(test_link_iterate_ud_links) -MULTI_DECLARE(test_link_iterate_mixed_links) -MULTI_DECLARE(test_link_iterate_invalid_params) -MULTI_DECLARE(test_link_iterate_0_links) -MULTI_DECLARE(test_link_visit_hard_links_no_cycles) -MULTI_DECLARE(test_link_visit_soft_links_no_cycles) -MULTI_DECLARE(test_link_visit_external_links_no_cycles) -MULTI_DECLARE(test_link_visit_ud_links_no_cycles) -MULTI_DECLARE(test_link_visit_mixed_links_no_cycles) -MULTI_DECLARE(test_link_visit_hard_links_cycles) -MULTI_DECLARE(test_link_visit_soft_links_cycles) -MULTI_DECLARE(test_link_visit_external_links_cycles) -MULTI_DECLARE(test_link_visit_ud_links_cycles) -MULTI_DECLARE(test_link_visit_mixed_links_cycles) -MULTI_DECLARE(test_link_visit_invalid_params) -MULTI_DECLARE(test_link_visit_0_links) - static herr_t link_iter_hard_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void *op_data); static herr_t link_iter_soft_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, @@ -740,7 +683,7 @@ test_create_hard_link_invalid_params(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link test file name\n"); goto error; @@ -2038,7 +1981,7 @@ test_create_external_link(void) return; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -2155,7 +2098,7 @@ test_create_external_link_dangling(void) return; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -2304,7 +2247,7 @@ test_create_external_link_multi(void) { TESTING_2("Create the first external file to be pointed to"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename1) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename1) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); PART_ERROR(H5Lcreate_external_first_file); @@ -2368,7 +2311,7 @@ test_create_external_link_multi(void) { TESTING_2("Create the second external file to be pointed to"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME2, &ext_link_filename2) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME2, &ext_link_filename2) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); PART_ERROR(H5Lcreate_external_second_file); @@ -2428,7 +2371,7 @@ test_create_external_link_multi(void) { TESTING_2("Create the third external file to be pointed to"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME3, &ext_link_filename3) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME3, &ext_link_filename3) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); PART_ERROR(H5Lcreate_external_third_file); @@ -2694,13 +2637,13 @@ test_create_external_link_ping_pong(void) return; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_PING_PONG_NAME1, &ext_link_filename1) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_PING_PONG_NAME1, &ext_link_filename1) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_PING_PONG_NAME2, &ext_link_filename2) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_PING_PONG_NAME2, &ext_link_filename2) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -2991,7 +2934,7 @@ test_create_external_link_invalid_params(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME, &ext_link_filename) < + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_INVALID_PARAMS_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create filename for external link test\n"); @@ -3663,7 +3606,7 @@ test_delete_link(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -7708,7 +7651,7 @@ test_copy_link(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link test file name\n"); goto error; @@ -8993,7 +8936,7 @@ test_copy_link_invalid_params(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -9310,7 +9253,7 @@ test_move_link(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -11201,7 +11144,7 @@ test_move_link_invalid_params(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" failed to generate external link filename\n"); goto error; @@ -11573,7 +11516,7 @@ test_get_link_val(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -13975,7 +13918,7 @@ test_get_link_info(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link target filename\n"); goto error; @@ -16944,7 +16887,7 @@ test_get_link_name(void) goto error; } - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -20095,7 +20038,7 @@ test_link_iterate_external_links(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -20533,7 +20476,7 @@ test_link_iterate_mixed_links(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -21075,7 +21018,7 @@ test_link_iterate_invalid_params(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -22510,7 +22453,7 @@ test_link_visit_external_links_no_cycles(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -22946,7 +22889,7 @@ test_link_visit_mixed_links_no_cycles(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -24594,7 +24537,7 @@ test_link_visit_mixed_links_cycles(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -25039,7 +24982,7 @@ test_link_visit_invalid_params(void) TESTING_2("test setup"); - if (prefix_filename(test_path_prefix, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { + if (prefix_filename(test_path_prefix_g, EXTERNAL_LINK_TEST_FILE_NAME, &ext_link_filename) < 0) { H5_FAILED(); printf(" couldn't create external link filename\n"); goto error; @@ -27023,111 +26966,116 @@ link_visit_0_links_cb(hid_t group_id, const char *name, const H5L_info2_t *info, void H5_api_link_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_link_test_header", print_link_test_header, NULL, "Prints header for link tests", NULL, 0); - AddTest("test_create_hard_link", MT_API_TEST_FUNC_OUTER(test_create_hard_link), NULL, "hard link creation", NULL, 0); + AddTest("test_create_hard_link", MT_API_TEST_FUNC_OUTER(test_create_hard_link), NULL, "hard link creation", NULL, testframe_flags); AddTest("test_create_hard_link_long_name", MT_API_TEST_FUNC_OUTER(test_create_hard_link_long_name), NULL, - "hard link creation with a long name", NULL, 0); + "hard link creation with a long name", NULL, testframe_flags); AddTest("test_create_hard_link_many", MT_API_TEST_FUNC_OUTER(test_create_hard_link_many), NULL, - "hard link creation of many links", NULL, 0); + "hard link creation of many links", NULL, testframe_flags); AddTest("test_create_hard_link_same_loc", MT_API_TEST_FUNC_OUTER(test_create_hard_link_same_loc), NULL, - "hard link creation with H5L_SAME_LOC", NULL, 0); + "hard link creation with H5L_SAME_LOC", NULL, testframe_flags); AddTest("test_create_hard_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_hard_link_invalid_params), NULL, - "hard link creation with invalid parameters", NULL, 0); + "hard link creation with invalid parameters", NULL, testframe_flags); AddTest("test_create_soft_link_existing_relative", MT_API_TEST_FUNC_OUTER(test_create_soft_link_existing_relative), NULL, - "soft link creation to existing object by relative path", NULL, 0); + "soft link creation to existing object by relative path", NULL, testframe_flags); AddTest("test_create_soft_link_existing_absolute", MT_API_TEST_FUNC_OUTER(test_create_soft_link_existing_absolute), NULL, - "soft link creation to existing object by absolute path", NULL, 0); + "soft link creation to existing object by absolute path", NULL, testframe_flags); AddTest("test_create_soft_link_dangling_relative", MT_API_TEST_FUNC_OUTER(test_create_soft_link_dangling_relative), NULL, - "dangling soft link creation to object by relative path", NULL, 0); + "dangling soft link creation to object by relative path", NULL, testframe_flags); AddTest("test_create_soft_link_dangling_absolute", MT_API_TEST_FUNC_OUTER(test_create_soft_link_dangling_absolute), NULL, - "dangling soft link creation to object by absolute path", NULL, 0); + "dangling soft link creation to object by absolute path", NULL, testframe_flags); AddTest("test_create_soft_link_long_name", MT_API_TEST_FUNC_OUTER(test_create_soft_link_long_name), NULL, - "soft link creation with a long name", NULL, 0); + "soft link creation with a long name", NULL, testframe_flags); AddTest("test_create_soft_link_many", MT_API_TEST_FUNC_OUTER(test_create_soft_link_many), NULL, - "soft link creation of many links", NULL, 0); + "soft link creation of many links", NULL, testframe_flags); AddTest("test_create_soft_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_soft_link_invalid_params), NULL, - "soft link creation with invalid parameters", NULL, 0); + "soft link creation with invalid parameters", NULL, testframe_flags); AddTest("test_create_external_link", MT_API_TEST_FUNC_OUTER(test_create_external_link), NULL, - "external link creation to existing object", NULL, 0); + "external link creation to existing object", NULL, testframe_flags); AddTest("test_create_external_link_dangling", MT_API_TEST_FUNC_OUTER(test_create_external_link_dangling), NULL, - "dangling external link creation", NULL, 0); + "dangling external link creation", NULL, testframe_flags); AddTest("test_create_external_link_multi", MT_API_TEST_FUNC_OUTER(test_create_external_link_multi), NULL, - "external link creation to an object across several files", NULL, 0); + "external link creation to an object across several files", NULL, testframe_flags); AddTest("test_create_external_link_ping_pong", MT_API_TEST_FUNC_OUTER(test_create_external_link_ping_pong), NULL, - "external link creation to an object in ping pong style", NULL, 0); + "external link creation to an object in ping pong style", NULL, testframe_flags); AddTest("test_create_external_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_external_link_invalid_params), NULL, - "H5Lcreate_external with invalid parameters", NULL, 0); + "H5Lcreate_external with invalid parameters", NULL, testframe_flags); AddTest("test_create_user_defined_link", MT_API_TEST_FUNC_OUTER(test_create_user_defined_link), NULL, - "user-defined link creation", NULL, 0); + "user-defined link creation", NULL, testframe_flags); AddTest("test_create_user_defined_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_create_user_defined_link_invalid_params), - NULL, "H5Lcreate_ud with invalid parameters", NULL, 0); - AddTest("test_delete_link", MT_API_TEST_FUNC_OUTER(test_delete_link), NULL, "link deletion", NULL, 0); + NULL, "H5Lcreate_ud with invalid parameters", NULL, testframe_flags); + AddTest("test_delete_link", MT_API_TEST_FUNC_OUTER(test_delete_link), NULL, "link deletion", NULL, testframe_flags); AddTest("test_delete_link_reset_grp_max_crt_order", MT_API_TEST_FUNC_OUTER(test_delete_link_reset_grp_max_crt_order), NULL, - "H5Ldelete of all links in group resets group's maximum link creation order value", NULL, 0); + "H5Ldelete of all links in group resets group's maximum link creation order value", NULL, testframe_flags); AddTest("test_delete_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_delete_link_invalid_params), NULL, - "H5Ldelete with invalid parameters", NULL, 0); - AddTest("test_copy_link", MT_API_TEST_FUNC_OUTER(test_copy_link), NULL, "link copying", NULL, 0); + "H5Ldelete with invalid parameters", NULL, testframe_flags); + AddTest("test_copy_link", MT_API_TEST_FUNC_OUTER(test_copy_link), NULL, "link copying", NULL, testframe_flags); AddTest("test_copy_links_into_group_with_links", MT_API_TEST_FUNC_OUTER(test_copy_links_into_group_with_links), NULL, - "H5Lcopy adjusting creation order values for copied links", NULL, 0); + "H5Lcopy adjusting creation order values for copied links", NULL, testframe_flags); AddTest("test_copy_link_across_files", MT_API_TEST_FUNC_OUTER(test_copy_link_across_files), NULL, "link copying across files", - NULL, 0); + NULL, testframe_flags); AddTest("test_copy_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_copy_link_invalid_params), NULL, - "H5Lcopy with invalid parameters", NULL, 0); - AddTest("test_move_link", MT_API_TEST_FUNC_OUTER(test_move_link), NULL, "link moving", NULL, 0); + "H5Lcopy with invalid parameters", NULL, testframe_flags); + AddTest("test_move_link", MT_API_TEST_FUNC_OUTER(test_move_link), NULL, "link moving", NULL, testframe_flags); AddTest("test_move_links_into_group_with_links", MT_API_TEST_FUNC_OUTER(test_move_links_into_group_with_links), NULL, - "H5Lmove adjusting creation order values for moved links", NULL, 0); + "H5Lmove adjusting creation order values for moved links", NULL, testframe_flags); AddTest("test_move_link_across_files", MT_API_TEST_FUNC_OUTER(test_move_link_across_files), NULL, "link moving across files", - NULL, 0); + NULL, testframe_flags); AddTest("test_move_link_reset_grp_max_crt_order", MT_API_TEST_FUNC_OUTER(test_move_link_reset_grp_max_crt_order), NULL, - "H5Lmove of all links out of group resets group's maximum link creation order value", NULL, 0); + "H5Lmove of all links out of group resets group's maximum link creation order value", NULL, testframe_flags); AddTest("test_move_link_invalid_params", MT_API_TEST_FUNC_OUTER(test_move_link_invalid_params), NULL, - "H5Lmove with invalid parameters", NULL, 0); - AddTest("test_get_link_val", MT_API_TEST_FUNC_OUTER(test_get_link_val), NULL, "link value retrieval", NULL, 0); + "H5Lmove with invalid parameters", NULL, testframe_flags); + AddTest("test_get_link_val", MT_API_TEST_FUNC_OUTER(test_get_link_val), NULL, "link value retrieval", NULL, testframe_flags); AddTest("test_get_link_val_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_link_val_invalid_params), NULL, - "link value retrieval with invalid parameters", NULL, 0); - AddTest("test_get_link_info", MT_API_TEST_FUNC_OUTER(test_get_link_info), NULL, "link info retrieval", NULL, 0); + "link value retrieval with invalid parameters", NULL, testframe_flags); + AddTest("test_get_link_info", MT_API_TEST_FUNC_OUTER(test_get_link_info), NULL, "link info retrieval", NULL, testframe_flags); AddTest("test_get_link_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_link_info_invalid_params), NULL, - "link info retrieval with invalid parameters", NULL, 0); - AddTest("test_get_link_name", MT_API_TEST_FUNC_OUTER(test_get_link_name), NULL, "link name retrieval", NULL, 0); + "link info retrieval with invalid parameters", NULL, testframe_flags); + AddTest("test_get_link_name", MT_API_TEST_FUNC_OUTER(test_get_link_name), NULL, "link name retrieval", NULL, testframe_flags); AddTest("test_get_link_name_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_link_name_invalid_params), NULL, - "link name retrieval with invalid parameters", NULL, 0); + "link name retrieval with invalid parameters", NULL, testframe_flags); AddTest("test_link_iterate_hard_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_hard_links), NULL, - "link iteration (only hard links)", NULL, 0); + "link iteration (only hard links)", NULL, testframe_flags); AddTest("test_link_iterate_soft_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_soft_links), NULL, - "link iteration (only soft links)", NULL, 0); + "link iteration (only soft links)", NULL, testframe_flags); AddTest("test_link_iterate_external_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_external_links), NULL, - "link iteration (only external links)", NULL, 0); + "link iteration (only external links)", NULL, testframe_flags); AddTest("test_link_iterate_ud_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_ud_links), NULL, - "link iteration (only user-defined links)", NULL, 0); + "link iteration (only user-defined links)", NULL, testframe_flags); AddTest("test_link_iterate_mixed_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_mixed_links), NULL, - "link iteration (mixed link types)", NULL, 0); + "link iteration (mixed link types)", NULL, testframe_flags); AddTest("test_link_iterate_invalid_params", MT_API_TEST_FUNC_OUTER(test_link_iterate_invalid_params), NULL, - "link iteration with invalid parameters", NULL, 0); + "link iteration with invalid parameters", NULL, testframe_flags); AddTest("test_link_iterate_0_links", MT_API_TEST_FUNC_OUTER(test_link_iterate_0_links), NULL, - "link iteration on group with 0 links", NULL, 0); + "link iteration on group with 0 links", NULL, testframe_flags); AddTest("test_link_visit_hard_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_hard_links_no_cycles), NULL, - "link visiting without cycles (only hard links)", NULL, 0); + "link visiting without cycles (only hard links)", NULL, testframe_flags); AddTest("test_link_visit_soft_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_soft_links_no_cycles), NULL, - "link visiting without cycles (only soft links)", NULL, 0); + "link visiting without cycles (only soft links)", NULL, testframe_flags); AddTest("test_link_visit_external_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_external_links_no_cycles), NULL, - "link visiting without cycles (only external links)", NULL, 0); + "link visiting without cycles (only external links)", NULL, testframe_flags); AddTest("test_link_visit_ud_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_ud_links_no_cycles), NULL, - "link visiting without cycles (only user-defined links)", NULL, 0); + "link visiting without cycles (only user-defined links)", NULL, testframe_flags); AddTest("test_link_visit_mixed_links_no_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_mixed_links_no_cycles), NULL, - "link visiting without cycles (mixed link types)", NULL, 0); + "link visiting without cycles (mixed link types)", NULL, testframe_flags); AddTest("test_link_visit_hard_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_hard_links_cycles), NULL, - "link visiting with cycles (only hard links)", NULL, 0); + "link visiting with cycles (only hard links)", NULL, testframe_flags); AddTest("test_link_visit_soft_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_soft_links_cycles), NULL, - "link visiting with cycles (only soft links)", NULL, 0); + "link visiting with cycles (only soft links)", NULL, testframe_flags); AddTest("test_link_visit_external_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_external_links_cycles), NULL, - "link visiting with cycles (only external links)", NULL, 0); + "link visiting with cycles (only external links)", NULL, testframe_flags); AddTest("test_link_visit_ud_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_ud_links_cycles), NULL, - "link visiting with cycles (only user-defined links)", NULL, 0); + "link visiting with cycles (only user-defined links)", NULL, testframe_flags); AddTest("test_link_visit_mixed_links_cycles", MT_API_TEST_FUNC_OUTER(test_link_visit_mixed_links_cycles), NULL, - "link visiting with cycles (mixed link types)", NULL, 0); + "link visiting with cycles (mixed link types)", NULL, testframe_flags); AddTest("test_link_visit_invalid_params", MT_API_TEST_FUNC_OUTER(test_link_visit_invalid_params), NULL, - "link visiting with invalid parameters", NULL, 0); + "link visiting with invalid parameters", NULL, testframe_flags); AddTest("test_link_visit_0_links", MT_API_TEST_FUNC_OUTER(test_link_visit_0_links), NULL, - "link visiting on group with subgroups containing 0 links", NULL, 0); + "link visiting on group with subgroups containing 0 links", NULL, testframe_flags); } diff --git a/test/API/H5_api_misc_test.c b/test/API/H5_api_misc_test.c index c746b951da6..a6c6da2471d 100644 --- a/test/API/H5_api_misc_test.c +++ b/test/API/H5_api_misc_test.c @@ -20,13 +20,6 @@ static void test_dot_for_object_name(void); static void test_symbols_in_compound_field_name(void); static void test_double_init_term(void); -MULTI_DECLARE(test_open_link_without_leading_slash) -MULTI_DECLARE(test_object_creation_by_absolute_path) -MULTI_DECLARE(test_absolute_vs_relative_path) -MULTI_DECLARE(test_dot_for_object_name) -MULTI_DECLARE(test_symbols_in_compound_field_name) -MULTI_DECLARE(test_double_init_term) - static void print_misc_test_header(void) { @@ -1049,19 +1042,24 @@ test_symbols_in_compound_field_name(void) void H5_api_misc_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_misc_test_header", print_misc_test_header, NULL, "Prints header for miscellaneous tests", NULL, 0); AddTest("test_open_link_without_leading_slash", MT_API_TEST_FUNC_OUTER(test_open_link_without_leading_slash), NULL, - "opening a link without a leading slash", NULL, 0); + "opening a link without a leading slash", NULL, testframe_flags); AddTest("test_object_creation_by_absolute_path", MT_API_TEST_FUNC_OUTER(test_object_creation_by_absolute_path), NULL, - "object creation by absolute path", NULL, 0); + "object creation by absolute path", NULL, testframe_flags); AddTest("test_absolute_vs_relative_path", MT_API_TEST_FUNC_OUTER(test_absolute_vs_relative_path), NULL, - "absolute vs. relative pathnames", NULL, 0); + "absolute vs. relative pathnames", NULL, testframe_flags); AddTest("test_dot_for_object_name", MT_API_TEST_FUNC_OUTER(test_dot_for_object_name), NULL, - "creating objects with \".\" as the name", NULL, 0); + "creating objects with \".\" as the name", NULL, testframe_flags); AddTest("test_symbols_in_compound_field_name", MT_API_TEST_FUNC_OUTER(test_symbols_in_compound_field_name), NULL, - "usage of '{', '}' and '\\\"' symbols in compound field name", NULL, 0); - AddTest("test_double_init_term", MT_API_TEST_FUNC_OUTER(test_double_init_term), NULL, "double init/term correctness", NULL, 0); + "usage of '{', '}' and '\\\"' symbols in compound field name", NULL, testframe_flags); + AddTest("test_double_init_term", MT_API_TEST_FUNC_OUTER(test_double_init_term), NULL, "double init/term correctness", NULL, testframe_flags); } diff --git a/test/API/H5_api_object_test.c b/test/API/H5_api_object_test.c index 3f8e330cec1..b71ce7145b9 100644 --- a/test/API/H5_api_object_test.c +++ b/test/API/H5_api_object_test.c @@ -44,37 +44,6 @@ static void test_flush_object_invalid_params(void); static void test_refresh_object(void); static void test_refresh_object_invalid_params(void); -MULTI_DECLARE(test_open_object) -MULTI_DECLARE(test_open_object_invalid_params) -MULTI_DECLARE(test_object_exists) -MULTI_DECLARE(test_object_exists_invalid_params) -MULTI_DECLARE(test_get_object_info) -MULTI_DECLARE(test_get_object_info_invalid_params) -MULTI_DECLARE(test_link_object) -MULTI_DECLARE(test_link_object_invalid_params) -MULTI_DECLARE(test_incr_decr_object_refcount) -MULTI_DECLARE(test_incr_decr_object_refcount_invalid_params) -MULTI_DECLARE(test_object_copy_basic) -MULTI_DECLARE(test_object_copy_already_existing) -MULTI_DECLARE(test_object_copy_shallow_group_copy) -MULTI_DECLARE(test_object_copy_no_attributes) -MULTI_DECLARE(test_object_copy_by_soft_link) -MULTI_DECLARE(test_object_copy_group_with_soft_links) -MULTI_DECLARE(test_object_copy_between_files) -MULTI_DECLARE(test_object_copy_invalid_params) -MULTI_DECLARE(test_object_comments) -MULTI_DECLARE(test_object_comments_invalid_params) -MULTI_DECLARE(test_object_visit) -MULTI_DECLARE(test_object_visit_soft_link) -MULTI_DECLARE(test_object_visit_invalid_params) -MULTI_DECLARE(test_close_object) -MULTI_DECLARE(test_close_object_invalid_params) -MULTI_DECLARE(test_close_invalid_objects) -MULTI_DECLARE(test_flush_object) -MULTI_DECLARE(test_flush_object_invalid_params) -MULTI_DECLARE(test_refresh_object) -MULTI_DECLARE(test_refresh_object_invalid_params) - static herr_t object_copy_attribute_iter_callback(hid_t location_id, const char *attr_name, const H5A_info_t *ainfo, void *op_data); static herr_t object_copy_soft_link_non_expand_callback(hid_t group, const char *name, @@ -4225,7 +4194,7 @@ test_object_copy_between_files(void) /* * Create the second file for the between file copying tests. */ - if (prefix_filename(test_path_prefix, OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME, &obj_copy_filename) < 0) { + if (prefix_filename(test_path_prefix_g, OBJECT_COPY_BETWEEN_FILES_TEST_FILE_NAME, &obj_copy_filename) < 0) { H5_FAILED(); printf(" couldn't create filename for object copy test file\n"); goto error; @@ -5104,7 +5073,7 @@ test_object_visit(void) goto error; } - if (prefix_filename(test_path_prefix, OBJECT_VISIT_TEST_FILE_NAME, &visit_filename) < 0) { + if (prefix_filename(test_path_prefix_g, OBJECT_VISIT_TEST_FILE_NAME, &visit_filename) < 0) { H5_FAILED(); printf(" couldn't generate filename\n"); goto error; @@ -7388,57 +7357,62 @@ object_visit_noop_callback(hid_t o_id, const char *name, const H5O_info2_t *obje void H5_api_object_test_add(void) { + int64_t testframe_flags = 0; + + if (GetTestMaxNumThreads() > 1) + testframe_flags |= RUN_TEST_MULTITHREADED; + /* Add a fake test to print out a header to distinguish different test interfaces */ AddTest("print_object_test_header", print_object_test_header, NULL, "Prints header for object tests", NULL, 0); - AddTest("test_open_object", MT_API_TEST_FUNC_OUTER(test_open_object), NULL, "object opening", NULL, 0); + AddTest("test_open_object", MT_API_TEST_FUNC_OUTER(test_open_object), NULL, "object opening", NULL, testframe_flags); AddTest("test_open_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_open_object_invalid_params), NULL, - "object opening with invalid parameters", NULL, 0); - AddTest("test_object_exists", MT_API_TEST_FUNC_OUTER(test_object_exists), NULL, "object existence", NULL, 0); + "object opening with invalid parameters", NULL, testframe_flags); + AddTest("test_object_exists", MT_API_TEST_FUNC_OUTER(test_object_exists), NULL, "object existence", NULL, testframe_flags); AddTest("test_object_exists_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_exists_invalid_params), NULL, - "object existence with invalid parameters", NULL, 0); - AddTest("test_get_object_info", MT_API_TEST_FUNC_OUTER(test_get_object_info), NULL, "object info retrieval", NULL, 0); + "object existence with invalid parameters", NULL, testframe_flags); + AddTest("test_get_object_info", MT_API_TEST_FUNC_OUTER(test_get_object_info), NULL, "object info retrieval", NULL, testframe_flags); AddTest("test_get_object_info_invalid_params", MT_API_TEST_FUNC_OUTER(test_get_object_info_invalid_params), NULL, - "object info retrieval with invalid parameters", NULL, 0); - AddTest("test_link_object", MT_API_TEST_FUNC_OUTER(test_link_object), NULL, "object linking", NULL, 0); + "object info retrieval with invalid parameters", NULL, testframe_flags); + AddTest("test_link_object", MT_API_TEST_FUNC_OUTER(test_link_object), NULL, "object linking", NULL, testframe_flags); AddTest("test_link_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_link_object_invalid_params), NULL, - "object linking with invalid parameters", NULL, 0); + "object linking with invalid parameters", NULL, testframe_flags); AddTest("test_incr_decr_object_refcount", MT_API_TEST_FUNC_OUTER(test_incr_decr_object_refcount), NULL, - "increment/decrement the reference count of object", NULL, 0); + "increment/decrement the reference count of object", NULL, testframe_flags); AddTest("test_incr_decr_object_refcount_invalid_params", MT_API_TEST_FUNC_OUTER(test_incr_decr_object_refcount_invalid_params), - NULL, "object reference count incr./decr. with an invalid parameter", NULL, 0); - AddTest("test_object_copy_basic", MT_API_TEST_FUNC_OUTER(test_object_copy_basic), NULL, "basic object copying", NULL, 0); + NULL, "object reference count incr./decr. with an invalid parameter", NULL, testframe_flags); + AddTest("test_object_copy_basic", MT_API_TEST_FUNC_OUTER(test_object_copy_basic), NULL, "basic object copying", NULL, testframe_flags); AddTest("test_object_copy_already_existing", MT_API_TEST_FUNC_OUTER(test_object_copy_already_existing), NULL, - "object copying to location where objects already exist", NULL, 0); + "object copying to location where objects already exist", NULL, testframe_flags); AddTest("test_object_copy_shallow_group_copy", MT_API_TEST_FUNC_OUTER(test_object_copy_shallow_group_copy), NULL, - "object copying with H5O_COPY_SHALLOW_HIERARCHY_FLAG flag", NULL, 0); + "object copying with H5O_COPY_SHALLOW_HIERARCHY_FLAG flag", NULL, testframe_flags); AddTest("test_object_copy_no_attributes", MT_API_TEST_FUNC_OUTER(test_object_copy_no_attributes), NULL, - "object copying with H5O_COPY_WITHOUT_ATTR_FLAG flag", NULL, 0); + "object copying with H5O_COPY_WITHOUT_ATTR_FLAG flag", NULL, testframe_flags); AddTest("test_object_copy_by_soft_link", MT_API_TEST_FUNC_OUTER(test_object_copy_by_soft_link), NULL, - "object copying through use of soft links", NULL, 0); + "object copying through use of soft links", NULL, testframe_flags); AddTest("test_object_copy_group_with_soft_links", MT_API_TEST_FUNC_OUTER(test_object_copy_group_with_soft_links), NULL, - "group copying when group contains soft links", NULL, 0); + "group copying when group contains soft links", NULL, testframe_flags); AddTest("test_object_copy_between_files", MT_API_TEST_FUNC_OUTER(test_object_copy_between_files), NULL, - "object copying between files", NULL, 0); + "object copying between files", NULL, testframe_flags); AddTest("test_object_copy_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_copy_invalid_params), NULL, - "object copying with invalid parameters", NULL, 0); - AddTest("test_object_comments", MT_API_TEST_FUNC_OUTER(test_object_comments), NULL, "object comments", NULL, 0); + "object copying with invalid parameters", NULL, testframe_flags); + AddTest("test_object_comments", MT_API_TEST_FUNC_OUTER(test_object_comments), NULL, "object comments", NULL, testframe_flags); AddTest("test_object_comments_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_comments_invalid_params), NULL, - "object comments with invalid parameters", NULL, 0); - AddTest("test_object_visit", MT_API_TEST_FUNC_OUTER(test_object_visit), NULL, "object visiting", NULL, 0); + "object comments with invalid parameters", NULL, testframe_flags); + AddTest("test_object_visit", MT_API_TEST_FUNC_OUTER(test_object_visit), NULL, "object visiting", NULL, testframe_flags); AddTest("test_object_visit_soft_link", MT_API_TEST_FUNC_OUTER(test_object_visit_soft_link), NULL, - "object visiting with soft links", NULL, 0); + "object visiting with soft links", NULL, testframe_flags); AddTest("test_object_visit_invalid_params", MT_API_TEST_FUNC_OUTER(test_object_visit_invalid_params), NULL, - "object visiting with invalid parameters", NULL, 0); - AddTest("test_close_object", MT_API_TEST_FUNC_OUTER(test_close_object), NULL, "H5Oclose", NULL, 0); + "object visiting with invalid parameters", NULL, testframe_flags); + AddTest("test_close_object", MT_API_TEST_FUNC_OUTER(test_close_object), NULL, "H5Oclose", NULL, testframe_flags); AddTest("test_close_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_close_object_invalid_params), NULL, - "H5Oclose with an invalid object ID", NULL, 0); - AddTest("test_close_invalid_objects", MT_API_TEST_FUNC_OUTER(test_close_invalid_objects), NULL, "H5Oclose invalid objects", NULL, 0); - AddTest("test_flush_object", MT_API_TEST_FUNC_OUTER(test_flush_object), NULL, "H5Oflush", NULL, 0); + "H5Oclose with an invalid object ID", NULL, testframe_flags); + AddTest("test_close_invalid_objects", MT_API_TEST_FUNC_OUTER(test_close_invalid_objects), NULL, "H5Oclose invalid objects", NULL, testframe_flags); + AddTest("test_flush_object", MT_API_TEST_FUNC_OUTER(test_flush_object), NULL, "H5Oflush", NULL, testframe_flags); AddTest("test_flush_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_flush_object_invalid_params), NULL, - "H5Oflush with invalid parameters", NULL, 0); - AddTest("test_refresh_object", MT_API_TEST_FUNC_OUTER(test_refresh_object), NULL, "H5Orefresh", NULL, 0); + "H5Oflush with invalid parameters", NULL, testframe_flags); + AddTest("test_refresh_object", MT_API_TEST_FUNC_OUTER(test_refresh_object), NULL, "H5Orefresh", NULL, testframe_flags); AddTest("test_refresh_object_invalid_params", MT_API_TEST_FUNC_OUTER(test_refresh_object_invalid_params), NULL, - "H5Orefresh with invalid parameters", NULL, 0); + "H5Orefresh with invalid parameters", NULL, testframe_flags); } diff --git a/test/API/H5_api_test.c b/test/API/H5_api_test.c index 90c55b37c78..703b2cf8622 100644 --- a/test/API/H5_api_test.c +++ b/test/API/H5_api_test.c @@ -42,11 +42,9 @@ #ifdef H5_HAVE_MULTITHREAD #include -#else -char H5_api_test_filename[H5_API_TEST_FILENAME_MAX_LENGTH]; #endif +char H5_api_test_filename_g[H5_API_TEST_FILENAME_MAX_LENGTH]; -const char *test_path_prefix = NULL; size_t active_thread_ct = 0; @@ -157,6 +155,7 @@ main(int argc, char **argv) H5E_auto2_t default_err_func; void *default_err_data = NULL; bool err_occurred = false; + int chars_written = 0; int testExpress = 0; @@ -198,18 +197,47 @@ main(int argc, char **argv) if (GetTestMaxNumThreads() <= 0) SetTestMaxNumThreads(API_TESTS_DEFAULT_NUM_THREADS); - /* API Test Specific Setup */ - if (H5_api_test_global_setup() < 0) { - fprintf(stderr, "Error setting up global API test info\n"); - return EXIT_FAILURE; - } - /* Display VOL information */ if (H5_api_test_display_information() < 0) { fprintf(stderr, "Error displaying VOL information\n"); return EXIT_FAILURE; } + if (H5_api_test_setup_vol_cap_flags() < 0) { + fprintf(stderr, "Error setting up VOL flags\n"); + return EXIT_FAILURE; + } + + /* Set up test path prefix for filenames, with default being empty */ + if (test_path_prefix_g == NULL) { + if ((test_path_prefix_g = HDgetenv(HDF5_API_TEST_PATH_PREFIX)) == NULL) + test_path_prefix_g = (const char *)""; + } + + if (GetTestMaxNumThreads() == 1) { + /* Populate global test filename */ + if ((chars_written = HDsnprintf(H5_api_test_filename_g, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s",test_path_prefix_g, + TEST_FILE_NAME)) < 0) { + fprintf(stderr, "Error while creating test file name\n"); + return EXIT_FAILURE; + } + + if ((size_t)chars_written >= H5_API_TEST_FILENAME_MAX_LENGTH) { + fprintf(stderr, "Test file name exceeded expected size\n"); + return EXIT_FAILURE; + } + } + + + /* Create the file(s) that will be used for all of the tests, + * except for those which test file creation.*/ + if (H5_api_test_create_containers(TEST_FILE_NAME, vol_cap_flags_g) < 0) { + fprintf(stderr, "Unable to create testing container file with basename '%s'\n", TEST_FILE_NAME); + return EXIT_FAILURE; + } + + active_thread_ct = (size_t) GetTestMaxNumThreads(); + /* Display generic testing information */ TestInfo(argv[0]); @@ -256,7 +284,7 @@ main(int argc, char **argv) TestAlarmOff(); if (GetTestNumErrs() > 0) - n_tests_failed_g += GetTestNumErrs(); + n_tests_failed_g += (size_t) GetTestNumErrs(); /* Release test infrastructure */ TestShutdown(); diff --git a/test/API/H5_api_test.h b/test/API/H5_api_test.h index aa8d3f4a2a2..c73c80d8721 100644 --- a/test/API/H5_api_test.h +++ b/test/API/H5_api_test.h @@ -35,26 +35,15 @@ /******************************************************************************/ -/* The name of the file that all of the tests will operate on */ -#define TEST_FILE_NAME "H5_api_test.h5" - /* Final name of the API test container file (for this thread) */ #ifdef H5_HAVE_MULTITHREAD -#define H5_API_TEST_FILENAME (pthread_getspecific(thread_info_key_g) ? ((thread_info_t*) pthread_getspecific(thread_info_key_g))->H5_api_test_filename : NULL) +#define H5_API_TEST_FILENAME (GetTestMaxNumThreads() > 1 ? ((thread_info_t*) pthread_getspecific(test_thread_info_key_g))->test_thread_filename : H5_api_test_filename_g) #else -extern char H5_api_test_filename[]; -#define H5_API_TEST_FILENAME H5_api_test_filename +#define H5_API_TEST_FILENAME H5_api_test_filename_g #endif - -extern const char *test_path_prefix; +extern char H5_api_test_filename_g[]; extern size_t active_thread_ct; -/* - * Environment variable specifying a prefix string to add to - * filenames generated by the API tests - */ -#define HDF5_API_TEST_PATH_PREFIX "HDF5_API_TEST_PATH_PREFIX" - /* The names of a set of container groups which hold objects * created by each of the different types of tests. */ @@ -75,61 +64,7 @@ extern size_t active_thread_ct; * of a dataspace/datatype. */ #define MAX_DIM_SIZE 16 -#ifdef H5_HAVE_MULTITHREAD -/* Individual API tests may be run serially or in multiple threads. - * If being run in multiple threads, this macro will define a handler - * named _thread which creates and tears down the threads. - * - * TBD: Note that it invokes another macro-defined routine...which sets up threadlocal info... - * */ -#define DECLARE_MT_API_TEST_FUNC_OUTER(func) \ - void func##_thread_outer(void);\ - void func##_thread_outer(void) {\ - pthread_t *threads = NULL;\ - int max_threads = GetTestMaxNumThreads();\ - if ((threads = calloc((size_t) max_threads, sizeof(pthread_t))) == NULL) {\ - TestErrPrintf("Couldn't allocate threads");\ - return ;\ - }\ - for (int64_t i = 0; i < (int64_t) max_threads; i++) { \ - if (pthread_create(&threads[i], NULL, func##_thread_inner, (void*)i) != 0) { \ - TestErrPrintf("Couldn't create API test thread %ld", i); \ - return; \ - } \ - } \ - for (int i = 0; i < max_threads; i++) { \ - if (pthread_join(threads[i], NULL) != 0) { \ - TestErrPrintf("Couldn't join API test thread %d", i); \ - return; \ - } \ - } \ - free(threads); \ - return; \ - } - -#define MT_API_TEST_FUNC_OUTER(func) func##_thread_outer - -/* Invoked by MT_API_TEST_FUNC_OUTER. Sets up thread-local API test info and runs the actual test in this thread. */ -#define DECLARE_MT_API_TEST_FUNC_INNER(func) \ - void *func##_thread_inner(void *arg);\ - void *func##_thread_inner(void *arg) {\ - int64_t thread_idx = (int64_t)arg;\ - if (H5_api_test_thread_setup((int) thread_idx) < 0) {\ - TestErrPrintf("Error setting up thread-local API test info");\ - return (void*)-1;\ - }\ - func();\ - return NULL;\ - }\ - -#define MT_API_TEST_FUNC_INNER(func) func##_thread_inner - -/* Declare the multi-thread helper routines to execute an API test in multiple threads.*/ -#define MULTI_DECLARE(func)\ - DECLARE_MT_API_TEST_FUNC_INNER(func)\ - DECLARE_MT_API_TEST_FUNC_OUTER(func) -#else /* H5_HAVE_MULTITHREAD */ +// TODO: Remove #define MT_API_TEST_FUNC_OUTER(func) func -#define MULTI_DECLARE(func) -#endif /* H5_HAVE_MULTITHREAD */ + #endif \ No newline at end of file diff --git a/test/API/H5_api_test_util.c b/test/API/H5_api_test_util.c index 5186cd40358..33b1a355ff2 100644 --- a/test/API/H5_api_test_util.c +++ b/test/API/H5_api_test_util.c @@ -76,12 +76,6 @@ #define COMPACT_SPACE_MAX_DIM_SIZE 4 #define COMPACT_SPACE_MAX_DIMS 3 -/* Allow 3-digit thread indexes (0-999)*/ -#define API_THREAD_IDX_LEN 3 - -#define THREAD_IDX_DIGITS_OFFSET(n) (n > 99 ? 3 : (n > 9 ? 2 : 1)) - - typedef hid_t (*generate_datatype_func)(H5T_class_t parent_class, hbool_t is_compact, size_t depth); static hid_t generate_random_datatype_internal(H5T_class_t parent_class, hbool_t is_compact, size_t depth); static hid_t generate_random_datatype_integer(H5T_class_t parent_class, hbool_t is_compact, size_t depth); @@ -92,12 +86,7 @@ static hid_t generate_random_datatype_reference(H5T_class_t parent_class, hbool_ static hid_t generate_random_datatype_enum(H5T_class_t parent_class, hbool_t is_compact, size_t depth); static hid_t generate_random_datatype_array(H5T_class_t parent_class, hbool_t is_compact, size_t depth); -#ifdef H5_HAVE_MULTITHREAD -static void H5_api_test_tl_key_destructor(void *value); -#endif - static int H5_api_test_create_containers_internal(const char *filename, uint64_t vol_cap_flags); -static int H5_api_test_create_containers(const char *filename, uint64_t vol_cap_flags); static int destroy_test_container_internal(const char *filename, uint64_t vol_cap_flags); /* @@ -658,7 +647,7 @@ generate_random_dataspace(int rank, const hsize_t *max_dims, hsize_t *dims_out, return H5I_INVALID_HID; } -static int +int H5_api_test_create_containers_internal(const char *filename, uint64_t vol_cap_flags) { hid_t file_id = H5I_INVALID_HID; hid_t group_id = H5I_INVALID_HID; @@ -726,11 +715,10 @@ H5_api_test_create_containers_internal(const char *filename, uint64_t vol_cap_fl } - - -static int +int H5_api_test_create_containers(const char *filename, uint64_t vol_cap_flags) { + int max_threads = GetTestMaxNumThreads(); char *tl_filename = NULL; if (!(vol_cap_flags & H5VL_CAP_FLAG_FILE_BASIC)) { @@ -738,49 +726,34 @@ H5_api_test_create_containers(const char *filename, uint64_t vol_cap_flags) goto error; } + if (max_threads > 1) { #ifdef H5_HAVE_MULTITHREAD - size_t tl_filename_len = strlen(filename) + API_THREAD_IDX_LEN + 1; - int chars_written = 0; - int max_threads = GetTestMaxNumThreads(); - size_t num_padding = 0; - - if ((tl_filename = (char*)malloc(tl_filename_len)) == NULL) { - printf(" can't allocate space for threadlocal filename\n"); - goto error; - } - - for (int i = 0; i < max_threads; i++) { - /* Set up tl_filename as <3-digit-thread-idx>*/ - - /* First, left-pad with zeros */ - num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(i); - memset(tl_filename, '0', num_padding); - - chars_written = snprintf(tl_filename + num_padding, - tl_filename_len - num_padding, - "%d%s", i, filename); + for (int i = 0; i < max_threads; i++) { + if ((tl_filename = generate_threadlocal_filename(test_path_prefix_g, i, filename)) == NULL) { + printf(" failed to generate thread-local API test filename\n"); + goto error; + } - if (chars_written < 0 || (size_t) chars_written >= tl_filename_len - num_padding) { - printf(" thread-local filename buffer overflow\n"); - goto error; - } + if (H5_api_test_create_containers_internal((const char *)tl_filename, vol_cap_flags) < 0) { + printf(" failed to create thread-local API test container"); + goto error; + } - if (H5_api_test_create_containers_internal((const char *)tl_filename, vol_cap_flags) < 0) { - printf(" failed to create thread-local API test container"); } - } - - free(tl_filename); - + free(tl_filename); #else - (void) tl_filename; - if (H5_api_test_create_containers_internal((const char *)filename, vol_cap_flags) < 0) { - printf(" failed to create test container\n"); + printf(" thread-specific filename requested, but multithread support not enabled\n"); goto error; - } #endif + } else { + if (H5_api_test_create_containers_internal((const char *)filename, vol_cap_flags) < 0) { + printf(" failed to create test container\n"); + goto error; + } + } + return 0; error: @@ -801,42 +774,26 @@ destroy_test_container_internal(const char *filename, uint64_t vol_cap_flags) { size_t tl_filename_len = strlen(filename) + API_THREAD_IDX_LEN + 1; int chars_written = 0; int max_threads = GetTestMaxNumThreads(); - size_t num_padding = 0; - - if ((tl_filename = (char*)malloc(tl_filename_len)) == NULL) { - printf(" can't allocate space for threadlocal filename\n"); - goto error; - } for (int i = 0; i < max_threads; i++) { - /* Set up tl_filename as <3-digit-thread-idx>*/ - - /* First, left-pad with zeros */ - num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(i); - memset(tl_filename, '0', num_padding); - - chars_written = snprintf(tl_filename + num_padding, - tl_filename_len - num_padding, - "%d%s", i, filename); - - if (chars_written < 0 || (size_t) chars_written >= tl_filename_len - num_padding) { - printf(" thread-local filename buffer overflow\n"); + if ((tl_filename = generate_threadlocal_filename(test_path_prefix_g, i, filename)) == NULL) { + printf(" failed to generate thread-local API test filename\n"); goto error; } - + H5E_BEGIN_TRY { if (H5Fis_accessible(tl_filename, H5P_DEFAULT) > 0) { if (H5Fdelete(tl_filename, H5P_DEFAULT) < 0) { printf(" failed to destroy thread-local API test container"); + free(tl_filename); goto error; } } } H5E_END_TRY - - } - free(tl_filename); + free(tl_filename); + } #else @@ -856,58 +813,6 @@ destroy_test_container_internal(const char *filename, uint64_t vol_cap_flags) { return -1; } -#ifdef H5_HAVE_MULTITHREAD -/* Set up any thread-local variables for individual API tests. - * Must be run from each individual thread in multi-thread scenarios. */ -int H5_api_test_thread_setup(int thread_idx) { - int chars_written = 0; - thread_info_t *tinfo = NULL; - size_t num_padding = 0; - num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(thread_idx); - - if (API_THREAD_IDX_LEN + strlen(TEST_FILE_NAME) >= H5_API_TEST_FILENAME_MAX_LENGTH) { - TestErrPrintf(" test file name exceeded expected size\n"); - goto error; - } - - if (NULL == (tinfo = (thread_info_t *)calloc(1, sizeof(thread_info_t)))) { - TestErrPrintf(" couldn't allocate memory for thread-specific data\n"); - goto error; - } - - tinfo->thread_idx = thread_idx; - - if (NULL == (tinfo->H5_api_test_filename = (char *)calloc(1, H5_API_TEST_FILENAME_MAX_LENGTH))) { - TestErrPrintf(" couldn't allocate memory for test file name\n"); - goto error; - } - - /* First, left-pad with zeros */ - memset(tinfo->H5_api_test_filename, '0', num_padding); - - /* Set up test filename*/ - if ((chars_written = snprintf(tinfo->H5_api_test_filename + num_padding, - H5_API_TEST_FILENAME_MAX_LENGTH - num_padding, "%s%d%s", - test_path_prefix, thread_idx, TEST_FILE_NAME)) < 0) { - TestErrPrintf(" couldn't create test file name\n"); - goto error; - } - - if (pthread_setspecific(thread_info_key_g, (void *) tinfo) != 0) { - TestErrPrintf(" couldn't set thread-specific data\n"); - goto error; - } - - return 0; - -error: - free(tinfo->H5_api_test_filename); - free(tinfo); - return -1; -} - -#endif - /* * Add a thread-specific prefix to the given filename. The caller * is responsible for freeing the returned filename @@ -939,40 +844,40 @@ prefix_filename(const char *prefix, const char *filename, char **filename_out) goto done; } - if (NULL == (out_buf = malloc(H5_API_TEST_FILENAME_MAX_LENGTH))) { - printf(" couldn't allocated filename buffer\n"); - ret_value = FAIL; - goto done; - } - + if (GetTestMaxNumThreads() > 1) { #ifdef H5_HAVE_MULTITHREAD - size_t num_padding = 0; - if ((tinfo = (thread_info_t *)pthread_getspecific(thread_info_key_g)) == NULL) { - printf(" failed to retrieve thread-specific info\n"); - ret_value = FAIL; - goto done; - } - - num_padding = (size_t) API_THREAD_IDX_LEN - THREAD_IDX_DIGITS_OFFSET(tinfo->thread_idx); + if ((tinfo = (thread_info_t *)pthread_getspecific(test_thread_info_key_g)) == NULL) { + printf(" failed to retrieve thread-specific info\n"); + ret_value = FAIL; + goto done; + } - /* First, left-pad with zeros */ - memset(out_buf, '0', num_padding); + if ((out_buf = generate_threadlocal_filename(prefix, tinfo->thread_idx, filename)) == NULL) { + printf(" failed to generate thread-specific filename\n"); + ret_value = FAIL; + goto done; + } - if ((chars_written = HDsnprintf(out_buf + num_padding, H5_API_TEST_FILENAME_MAX_LENGTH - num_padding, "%s%d%s", - prefix, tinfo->thread_idx, filename)) < 0) { - printf(" couldn't prefix filename\n"); - ret_value = FAIL; - goto done; - } #else - if ((chars_written = HDsnprintf(out_buf, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", prefix, filename)) < - 0) { - printf(" couldn't prefix filename\n"); + printf(" thread-specific filename requested, but multithread support not enabled\n"); ret_value = FAIL; goto done; - } #endif + } else { + if (NULL == (out_buf = malloc(H5_API_TEST_FILENAME_MAX_LENGTH))) { + printf(" couldn't allocated filename buffer\n"); + ret_value = FAIL; + goto done; + } + + if ((chars_written = HDsnprintf(out_buf, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", prefix, filename)) < + 0) { + printf(" couldn't prefix filename\n"); + ret_value = FAIL; + goto done; + } + } if ((size_t)chars_written >= H5_API_TEST_FILENAME_MAX_LENGTH) { printf(" filename buffer too small\n"); @@ -1060,7 +965,7 @@ int H5_api_test_display_information(void) { printf("Test parameters:\n"); printf(" - Test file name: '%s'\n", TEST_FILE_NAME); printf(" - Test seed: %u\n", seed); - printf(" - Test path prefix: '%s'\n", test_path_prefix); + printf(" - Test path prefix: '%s'\n", test_path_prefix_g); printf("\n\n"); free(vol_connector_name_copy); @@ -1070,87 +975,6 @@ int H5_api_test_display_information(void) { return -1; } -/* Set up global variables used for API tests */ -int H5_api_test_global_setup(void) { - int max_threads = 0; - int chars_written = 0; - hid_t fapl_id = H5I_INVALID_HID; - - /* Silence compiler warnings */ - (void)chars_written; - - /* Set up test path prefix for filenames, with default being empty */ - if (test_path_prefix == NULL) { - if ((test_path_prefix = HDgetenv(HDF5_API_TEST_PATH_PREFIX)) == NULL) - test_path_prefix = (const char *)""; - } - - /* Set up thread count, used for some file tests */ - max_threads = GetTestMaxNumThreads(); - - if (max_threads <= 0) { - printf(" invalid max thread count\n"); - goto error; - } - - active_thread_ct = (size_t) max_threads; - -#ifdef H5_HAVE_MULTITHREAD - /* Set up pthread key */ - if (pthread_key_create(&thread_info_key_g, H5_api_test_tl_key_destructor) != 0) { - fprintf(stderr, "Error creating threadlocal key\n"); - goto error; - } -#else - /* Populate global test filename */ - if ((chars_written = HDsnprintf(H5_api_test_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s",test_path_prefix, - TEST_FILE_NAME)) < 0) { - fprintf(stderr, "Error while creating test file name\n"); - goto error; - } - - if ((size_t)chars_written >= H5_API_TEST_FILENAME_MAX_LENGTH) { - fprintf(stderr, "Test file name exceeded expected size\n"); - goto error; - } - -#endif /* H5_HAVE_MULTITHREAD */ - - /* Retrieve the VOL cap flags - work around an HDF5 - * library issue by creating a FAPL - */ - if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { - printf(" couldn't create FAPL\n"); - goto error; - } - - vol_cap_flags_g = H5VL_CAP_FLAG_NONE; - if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { - printf(" unable to retrieve VOL connector capability flags\n"); - goto error; - } - - /* - * Create the file(s) that will be used for all of the tests, - * except for those which test file creation. - */ - if (H5_api_test_create_containers(TEST_FILE_NAME, vol_cap_flags_g) < 0) { - printf(" unable to create testing container file with basename '%s'\n", TEST_FILE_NAME); - goto error; - } - - if (H5Pclose(fapl_id) < 0) { - printf(" unable to close FAPL\n"); - goto error; - } - - return 0; - -error: - H5Pclose(fapl_id); - return -1; -} - int H5_api_test_destroy_container_files(void) { hid_t fapl_id = H5I_INVALID_HID; @@ -1297,18 +1121,31 @@ void H5_api_test_display_results(void) { vol_connector_name); } -#ifdef H5_HAVE_MULTITHREAD -/* Destructor for the API-test managed threadlocal value */ -static void H5_api_test_tl_key_destructor(void *value) { - thread_info_t *tinfo = (thread_info_t *)value; +int H5_api_test_setup_vol_cap_flags(void) { + hid_t fapl_id = H5I_INVALID_HID; - if (tinfo) { - free(tinfo->H5_api_test_filename); + /* Retrieve the VOL cap flags - work around an HDF5 + * library issue by creating a FAPL + */ + if ((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) { + printf(" couldn't create FAPL\n"); + goto error; } - - free(tinfo); - return; -} + vol_cap_flags_g = H5VL_CAP_FLAG_NONE; + if (H5Pget_vol_cap_flags(fapl_id, &vol_cap_flags_g) < 0) { + printf(" unable to retrieve VOL connector capability flags\n"); + goto error; + } -#endif + if (H5Pclose(fapl_id) < 0) { + printf(" unable to close FAPL\n"); + goto error; + } + + return 0; + +error: + H5Pclose(fapl_id); + return -1; +} diff --git a/test/API/H5_api_test_util.h b/test/API/H5_api_test_util.h index 2af21613a32..48a06604169 100644 --- a/test/API/H5_api_test_util.h +++ b/test/API/H5_api_test_util.h @@ -19,17 +19,15 @@ hid_t generate_random_datatype(H5T_class_t parent_class, hbool_t is_compact); hid_t generate_random_dataspace(int rank, const hsize_t *max_dims, hsize_t *dims_out, hbool_t is_compact); -int H5_api_test_global_setup(void); int H5_api_test_destroy_container_files(void); -int H5_api_test_display_information(void); -void H5_api_test_display_results(void); -int H5_api_check_vol_registration(void); +int H5_api_test_display_information(void); +int H5_api_check_vol_registration(void); +int H5_api_test_setup_vol_cap_flags(void); +int H5_api_test_create_containers(const char *filename, uint64_t vol_cap_flags); +void H5_api_test_display_results(void); herr_t prefix_filename(const char *prefix, const char *filename, char **filename_out); herr_t remove_test_file(const char *prefix, const char *filename); -#ifdef H5_HAVE_MULTITHREAD -int H5_api_test_thread_setup(int thread_idx); -#endif #endif /* H5_API_TEST_UTIL_H_ */ diff --git a/test/h5test.c b/test/h5test.c index 278a4fb4938..d29c0ba1166 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -119,7 +119,7 @@ H5_ATOMIC(size_t) n_tests_skipped_g = 0; int reg_opt_curr_op_val = 0; #ifdef H5_HAVE_MULTITHREAD -pthread_key_t thread_info_key_g; +pthread_key_t test_thread_info_key_g; #endif uint64_t vol_cap_flags_g = H5VL_CAP_FLAG_NONE; @@ -2469,4 +2469,39 @@ reg_opt_datatype_get(void H5_ATTR_UNUSED *obj, H5VL_datatype_get_args_t *args, h ret_value = FAIL; return ret_value; -} /* end reg_opt_datatype_get() */ \ No newline at end of file +} /* end reg_opt_datatype_get() */ + +/* Generate a heap-allocated filename of the form */ +char *generate_threadlocal_filename(const char *prefix, int thread_idx, const char *filename) { + int chars_written = 0; + char *test_filename = NULL; + + if (thread_idx > MAX_THREAD_IDX) { + fprintf(stderr, " thread index exceeded expected size\n"); + goto error; + } + + if (MAX_THREAD_IDX_LEN + strlen(filename) >= H5_API_TEST_FILENAME_MAX_LENGTH) { + fprintf(stderr, " test file name exceeded expected size\n"); + goto error; + } + + if (NULL == (test_filename = (char *)calloc(1, H5_API_TEST_FILENAME_MAX_LENGTH))) { + fprintf(stderr, " couldn't allocate memory for test file name\n"); + goto error; + } + + /* Write prefix, thread index, and filename into buffer */ + if ((chars_written = snprintf(test_filename, + H5_API_TEST_FILENAME_MAX_LENGTH, "%s%d%s", + prefix, thread_idx, filename)) < 0) { + fprintf(stderr, " couldn't create test file name\n"); + goto error; + } + + return test_filename; + +error: + free(test_filename); + return NULL; +} \ No newline at end of file diff --git a/test/h5test.h b/test/h5test.h index 3e2beab4466..3bd0d837e5e 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -95,17 +95,22 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ /* Information for an individual thread running the API tests */ typedef struct thread_info_t { int thread_idx; /* The test-assign index of the thread */ - char* H5_api_test_filename; /* The name of the test container file */ + char* test_thread_filename; /* The name of the test container file */ } thread_info_t; #ifdef H5_HAVE_MULTITHREAD -extern pthread_key_t thread_info_key_g; +extern pthread_key_t test_thread_info_key_g; + +#define IS_MAIN_TEST_THREAD ((GetTestMaxNumThreads() == 1) ||\ + ((pthread_getspecific(test_thread_info_key_g)) && (((thread_info_t*)pthread_getspecific(test_thread_info_key_g))->thread_idx == 0))) -#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_TEST_THREAD true #endif /* H5_HAVE_MULTITHREAD */ +/* Flag values for TestFrameworkFlags */ +#define RUN_TEST_MULTITHREADED 0x00000001 /* Run the test in a multi-threaded environment */ + /* * Print the current location on the standard output stream. */ @@ -397,6 +402,29 @@ H5TEST_DLL void SetTest(const char *testname, int action); H5TEST_DLL void TestAlarmOn(void); H5TEST_DLL void TestAlarmOff(void); +#ifdef H5_HAVE_MULTITHREAD +H5TEST_DLL void* PerformThreadTest(void *test); +H5TEST_DLL int H5_mt_test_global_setup(void); +H5TEST_DLL int H5_mt_test_thread_setup(int thread_idx); +H5TEST_DLL void H5_test_thread_info_key_destructor(void *value); +#endif + +/* Allow up to 3-digit thread indexes (0-999)*/ +#define MAX_THREAD_IDX 999 +#define MAX_THREAD_IDX_LEN + +/* Generate a heap-allocated filename of the form */ +char *generate_threadlocal_filename(const char *prefix, int thread_idx, const char *filename); + +/* + * Environment variable specifying a prefix string to add to + * filenames generated by the API tests + */ +#define HDF5_API_TEST_PATH_PREFIX "HDF5_API_TEST_PATH_PREFIX" +#define TEST_FILE_NAME "H5_api_test.h5" +/* Prefix to use for filepaths in API tests */ +extern const char *test_path_prefix_g; + H5TEST_DLL int GetTestMaxNumThreads(void); H5TEST_DLL void SetTestMaxNumThreads(int num_threads); diff --git a/test/testframe.c b/test/testframe.c index b25bb273153..840ea903d37 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -23,25 +23,29 @@ #define MAXTESTNAME 64 #define MAXTESTDESC 128 +typedef void (*TestCall)(void); + typedef struct TestStruct { - int NumErrors; + H5_ATOMIC(int) NumErrors; char Description[MAXTESTDESC]; int SkipFlag; char Name[MAXTESTNAME]; - void (*Call)(void); + TestCall Call; void (*Cleanup)(void); const void *TestParameters; int64_t TestFrameworkFlags; } TestStruct; -/* Flag values for TestFrameworkFlags */ -#define RUN_TEST_MULTITHREADED 0x00000001 /* Run the test in a multi-threaded environment */ +typedef struct TestThreadArgs { + int ThreadIndex; + TestCall Call; +} TestThreadArgs; /* * Variables used by testing framework. */ static int enable_error_stack = 0; /* enable error stack; disable=0 enable=1 */ -static int num_errs = 0; /* Total number of errors during testing */ +static H5_ATOMIC(int) num_errs_g = 0; /* Total number of errors during testing */ int TestVerbosity = VERBO_DEF; /* Default Verbosity is Low */ static int Summary = 0; /* Show test summary. Default is no. */ static int CleanUp = 1; /* Do cleanup or not. Default is yes. */ @@ -55,6 +59,7 @@ static void (*TestPrivateUsage)(void) = NULL; static int (*TestPrivateParser)(int ac, char *av[]) = NULL; static int TestMaxNumThreads_g = -1; /* Max number of threads that can be spawned */ +const char *test_path_prefix_g = NULL; /* * Setup a test function and add it to the list of tests. @@ -114,7 +119,8 @@ AddTest(const char *TheName, void (*TheCall)(void), void (*Cleanup)(void), const } Test[Index].Call = TheCall; Test[Index].Cleanup = Cleanup; - Test[Index].NumErrors = -1; + + H5_ATOMIC_STORE(Test[Index].NumErrors, -1); Test[Index].TestParameters = TestParameters; Test[Index].TestFrameworkFlags = TestFrameworkFlags; @@ -152,6 +158,13 @@ TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser TestPrivateUsage = private_usage; if (NULL != private_parser) TestPrivateParser = private_parser; + + /* Set up test path prefix for filenames, with default being empty */ + if (test_path_prefix_g == NULL) { + if ((test_path_prefix_g = HDgetenv(HDF5_API_TEST_PATH_PREFIX)) == NULL) + test_path_prefix_g = (const char *)""; + } + } /* @@ -333,33 +346,181 @@ void PerformTests(void) { unsigned Loop; + bool is_test_mt = false; + bool mt_initialized = false; + int test_num_errs = 0; + + /* Silence compiler warnings */ + (void) mt_initialized; + + for (Loop = 0; Loop < Index; Loop++) { + is_test_mt = (Test[Loop].TestFrameworkFlags & RUN_TEST_MULTITHREADED) ? true : false; - for (Loop = 0; Loop < Index; Loop++) if (Test[Loop].SkipFlag) { MESSAGE(2, ("Skipping -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name)); } else { - MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name)); + MESSAGE(2, ("Testing %s -- %s (%s) \n", (is_test_mt ? "(Multi-threaded)" : ""), + Test[Loop].Description, Test[Loop].Name)); MESSAGE(5, ("===============================================\n")); - Test[Loop].NumErrors = num_errs; + H5_ATOMIC_STORE(Test[Loop].NumErrors, num_errs_g); Test_parameters = Test[Loop].TestParameters; TestAlarmOn(); - Test[Loop].Call(); + + if (!is_test_mt) { + Test[Loop].Call(); + TestAlarmOff(); + test_num_errs = H5_ATOMIC_LOAD(Test[Loop].NumErrors); + H5_ATOMIC_STORE(Test[Loop].NumErrors, num_errs_g - test_num_errs); + MESSAGE(5, ("===============================================\n")); + MESSAGE(5, ("There were %d errors detected.\n\n", (int)H5_ATOMIC_LOAD(Test[Loop].NumErrors))); + } else { +#ifndef H5_HAVE_MULTITHREAD + if (Test[Loop].TestFrameworkFlags & RUN_TEST_MULTITHREADED) { + MESSAGE(2, ("Multi-threaded tests are not supported in this configuration; Skipping \n")); + TestAlarmOff(); + continue; + } +#else + pthread_t *threads; + TestThreadArgs *thread_args; + int max_num_threads = GetTestMaxNumThreads(); + int ret = 0; + + if (max_num_threads <= 0) { + fprintf(stderr, "Invalid number of threads specified\n"); + exit(EXIT_FAILURE); + } + + threads = (pthread_t *)calloc((size_t) max_num_threads, sizeof(pthread_t)); + thread_args = (TestThreadArgs *)calloc((size_t) max_num_threads, sizeof(TestThreadArgs)); + + if (!mt_initialized) { + if (H5_mt_test_global_setup() < 0) { + fprintf(stderr, "Error setting up global MT test info\n"); + exit(EXIT_FAILURE); + } + + mt_initialized = true; + } + + for (int i = 0; i < GetTestMaxNumThreads(); i++) { + thread_args[i].ThreadIndex = i; + thread_args[i].Call = Test[Loop].Call; + + ret = pthread_create(&threads[i], NULL, PerformThreadTest, (void*) &thread_args[i]); + + if (ret != 0) { + fprintf(stderr, "Error creating thread %d\n", i); + exit(EXIT_FAILURE); + } + } + + for (int i = 0; i < GetTestMaxNumThreads(); i++) { + ret = pthread_join(threads[i], NULL); + + if (ret != 0) { + fprintf(stderr, "Error joining thread %d\n", i); + exit(EXIT_FAILURE); + } + } + + + free(threads); + free(thread_args); + TestAlarmOff(); - Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors; + + test_num_errs = H5_ATOMIC_LOAD(Test[Loop].NumErrors); + H5_ATOMIC_STORE(Test[Loop].NumErrors, num_errs_g - test_num_errs); MESSAGE(5, ("===============================================\n")); - MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors)); + MESSAGE(5, ("There were %d errors detected.\n\n", (int)H5_ATOMIC_LOAD(Test[Loop].NumErrors))); +#endif /* H5_HAVE_MULTITHREAD */ + } } + } Test_parameters = NULL; /* clear it. */ MESSAGE(2, ("\n\n")); - if (num_errs) - print_func("!!! %d Error(s) were detected !!!\n\n", (int)num_errs); + if (num_errs_g) + print_func("!!! %d Error(s) were detected !!!\n\n", (int)num_errs_g); else print_func("All tests were successful. \n\n"); } +#ifdef H5_HAVE_MULTITHREAD +/* + * Set up and execute a test flagged for multi-threaded + * execution within a single thread. + */ +void *PerformThreadTest(void *test) +{ + TestCall test_call; + int thread_idx; + + assert(test); + + thread_idx = ((TestThreadArgs *)test)->ThreadIndex; + test_call = ((TestThreadArgs *)test)->Call; + + if (H5_mt_test_thread_setup((int)thread_idx) < 0) { + fprintf(stderr, "Error setting up thread-local test info"); + return (void*)-1; + } + + TestAlarmOn(); + test_call(); + TestAlarmOff(); + return NULL; +} + +/* Set up any thread-local variables for individual API tests. + * Must be run from each individual thread in multi-thread scenarios. */ +int H5_mt_test_thread_setup(int thread_idx) { + thread_info_t *tinfo = NULL; + + if (NULL == (tinfo = (thread_info_t *)calloc(1, sizeof(thread_info_t)))) { + TestErrPrintf(" couldn't allocate memory for thread-specific data\n"); + goto error; + } + + tinfo->thread_idx = thread_idx; + + /* TBD: This is currently only useful for API tests. Modification of existing testframe tests would be necessary + * for them to use thread-local filenames to avoid conflicts during multi-threaded execution */ + if (NULL == (tinfo->test_thread_filename = generate_threadlocal_filename(test_path_prefix_g, thread_idx, TEST_FILE_NAME))) { + TestErrPrintf(" couldn't allocate memory for test file name\n"); + goto error; + } + + if (pthread_setspecific(test_thread_info_key_g, (void *) tinfo) != 0) { + TestErrPrintf(" couldn't set thread-specific data\n"); + goto error; + } + + return 0; + +error: + free(tinfo->test_thread_filename); + free(tinfo); + return -1; +} + +/* Destructor for the API-test managed threadlocal value */ +void H5_test_thread_info_key_destructor(void *value) { + thread_info_t *tinfo = (thread_info_t *)value; + + if (tinfo) { + free(tinfo->test_thread_filename); + } + + free(tinfo); + + return; +} + +#endif /* * Display test summary. */ @@ -373,10 +534,10 @@ TestSummary(void) print_func("---------------- ------ --------------------------------------\n"); for (Loop = 0; Loop < Index; Loop++) { - if (Test[Loop].NumErrors == -1) + if (H5_ATOMIC_LOAD(Test[Loop].NumErrors) == -1) print_func("%16s %6s %s\n", Test[Loop].Name, "N/A", Test[Loop].Description); else - print_func("%16s %6d %s\n", Test[Loop].Name, (int)Test[Loop].NumErrors, Test[Loop].Description); + print_func("%16s %6d %s\n", Test[Loop].Name, (int)H5_ATOMIC_LOAD(Test[Loop].NumErrors), Test[Loop].Description); } print_func("\n\n"); @@ -566,7 +727,7 @@ ParseTestVerbosity(char *argv) H5_ATTR_PURE int GetTestNumErrs(void) { - return (num_errs); + return (num_errs_g); } /* @@ -575,7 +736,7 @@ GetTestNumErrs(void) void IncTestNumErrs(void) { - num_errs++; + num_errs_g++; } /* @@ -598,7 +759,7 @@ TestErrPrintf(const char *format, ...) int ret_value; /* Increment the error count */ - num_errs++; + num_errs_g++; /* Print the requested information */ va_start(arglist, format); @@ -656,6 +817,31 @@ SetTest(const char *testname, int action) } } +#ifdef H5_HAVE_MULTITHREAD +/* Set up global variables used for API tests */ +int H5_mt_test_global_setup(void) { + int max_threads = 0; + + /* Set up thread count, used for some file tests */ + max_threads = GetTestMaxNumThreads(); + + if (max_threads <= 0) { + printf(" invalid max thread count\n"); + goto error; + } + + /* Set up pthread key */ + if (pthread_key_create(&test_thread_info_key_g, H5_test_thread_info_key_destructor) != 0) { + fprintf(stderr, "Error creating threadlocal key\n"); + goto error; + } + + return 0; +error: + return -1; +} +#endif + /* Enable a test timer that will kill long-running tests, the time is configurable * via an environment variable. * diff --git a/testpar/API/H5_api_test_parallel.c b/testpar/API/H5_api_test_parallel.c index da21dfed379..dcbfa55f82f 100644 --- a/testpar/API/H5_api_test_parallel.c +++ b/testpar/API/H5_api_test_parallel.c @@ -27,7 +27,7 @@ char H5_api_test_parallel_filename[H5_API_TEST_FILENAME_MAX_LENGTH]; -const char *test_path_prefix; +const char *test_path_prefix_g; size_t n_tests_run_g; size_t n_tests_passed_g; @@ -236,10 +236,10 @@ main(int argc, char **argv) srand(seed); - if (NULL == (test_path_prefix = HDgetenv(HDF5_API_TEST_PATH_PREFIX))) - test_path_prefix = ""; + if (NULL == (test_path_prefix_g = HDgetenv(HDF5_API_TEST_PATH_PREFIX))) + test_path_prefix_g = ""; - HDsnprintf(H5_api_test_parallel_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix, + HDsnprintf(H5_api_test_parallel_filename, H5_API_TEST_FILENAME_MAX_LENGTH, "%s%s", test_path_prefix_g, PARALLEL_TEST_FILE_NAME); if (NULL == (vol_connector_string = HDgetenv(HDF5_VOL_CONNECTOR))) {