Skip to content

Commit

Permalink
Enable API tests by default and fix some issues (#5223)
Browse files Browse the repository at this point in the history
* Enable API tests by default

* Fix leaked file handle in API link test

* Fix some versioned API misuses
  • Loading branch information
jhendersonHDF authored Jan 10, 2025
1 parent 5d32619 commit 2d0c676
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CMakeTests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
option (HDF5_DISABLE_TESTS_REGEX "Regex pattern to set execution of specific tests to DISABLED" "")
mark_as_advanced (HDF5_DISABLE_TESTS_REGEX)

option (HDF5_TEST_API "Execute HDF5 API tests" OFF)
option (HDF5_TEST_API "Execute HDF5 API tests" ON)
mark_as_advanced (HDF5_TEST_API)
if (HDF5_TEST_API)
option (HDF5_TEST_API_INSTALL "Install HDF5 API tests" OFF)
Expand Down
16 changes: 8 additions & 8 deletions test/API/H5_api_attribute_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8641,15 +8641,15 @@ test_attribute_string_encodings(void H5_ATTR_UNUSED *params)
goto error;
}

if ((dset_id1 = H5Dcreate(container_group, ATTRIBUTE_STRING_ENCODINGS_DSET_NAME1, type_id1, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
if ((dset_id1 = H5Dcreate2(container_group, ATTRIBUTE_STRING_ENCODINGS_DSET_NAME1, type_id1, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create dataset with ascii string\n");
goto error;
}

if ((attr_id1 = H5Acreate(dset_id1, ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME1, type_id1, space_id,
H5P_DEFAULT, H5P_DEFAULT)) < 0) {
if ((attr_id1 = H5Acreate2(dset_id1, ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME1, type_id1, space_id,
H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create attribute with ascii string\n");
goto error;
Expand All @@ -8673,15 +8673,15 @@ test_attribute_string_encodings(void H5_ATTR_UNUSED *params)
goto error;
}

if ((dset_id2 = H5Dcreate(container_group, ATTRIBUTE_STRING_ENCODINGS_DSET_NAME2, type_id2, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
if ((dset_id2 = H5Dcreate2(container_group, ATTRIBUTE_STRING_ENCODINGS_DSET_NAME2, type_id2, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create dataset with UTF-8 string\n");
goto error;
}

if ((attr_id2 = H5Acreate(dset_id2, ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME2, type_id2, space_id,
H5P_DEFAULT, H5P_DEFAULT)) < 0) {
if ((attr_id2 = H5Acreate2(dset_id2, ATTRIBUTE_STRING_ENCODINGS_ATTR_NAME2, type_id2, space_id,
H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create attribute with ascii string\n");
goto error;
Expand Down
14 changes: 7 additions & 7 deletions test/API/H5_api_dataset_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2385,9 +2385,9 @@ test_create_dataset_creation_properties(void H5_ATTR_UNUSED *params)
PART_ERROR(DCPL_fill_value_test);
}

if ((dset_id =
H5Dcreate(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME1, DATASET_FILL_VALUE_TEST_INT_TYPE,
fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0) {
if ((dset_id = H5Dcreate2(group_id, DATASET_FILL_VALUE_TEST_DSET_NAME1,
DATASET_FILL_VALUE_TEST_INT_TYPE, fspace_id, H5P_DEFAULT, dcpl_id,
H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create dataset with integer fill value");
PART_ERROR(DCPL_fill_value_test);
Expand Down Expand Up @@ -8218,8 +8218,8 @@ test_dataset_string_encodings(void H5_ATTR_UNUSED *params)
goto error;
}

if ((dset_id1 = H5Dcreate(container_group, DATASET_STRING_ENCODINGS_DSET_NAME1, type_id1, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
if ((dset_id1 = H5Dcreate2(container_group, DATASET_STRING_ENCODINGS_DSET_NAME1, type_id1, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create dataset with ascii string\n");
goto error;
Expand All @@ -8243,8 +8243,8 @@ test_dataset_string_encodings(void H5_ATTR_UNUSED *params)
goto error;
}

if ((dset_id2 = H5Dcreate(container_group, DATASET_STRING_ENCODINGS_DSET_NAME2, type_id2, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
if ((dset_id2 = H5Dcreate2(container_group, DATASET_STRING_ENCODINGS_DSET_NAME2, type_id2, space_id,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) {
H5_FAILED();
printf(" couldn't create dataset with UTF-8 string\n");
goto error;
Expand Down
8 changes: 6 additions & 2 deletions test/API/H5_api_link_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,12 @@ test_create_hard_link_invalid_params(void H5_ATTR_UNUSED *params)
PART_ERROR(H5Lcreate_hard_across_files);
}

if (H5Fclose(ext_file_id) < 0) {
H5_FAILED();
printf(" couldn't close external file '%s'\n", ext_link_filename);
PART_ERROR(H5Lcreate_hard_across_files);
}

if (remove_test_file(NULL, ext_link_filename) < 0) {
H5_FAILED();
printf(" failed to delete external file '%s'\n", ext_link_filename);
Expand Down Expand Up @@ -934,8 +940,6 @@ test_create_hard_link_invalid_params(void H5_ATTR_UNUSED *params)

TESTING_2("test cleanup");

if (H5Fclose(ext_file_id) < 0)
TEST_ERROR;
if (H5Gclose(group_id) < 0)
TEST_ERROR;
if (H5Gclose(container_group) < 0)
Expand Down
4 changes: 2 additions & 2 deletions test/API/H5_api_object_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -5638,8 +5638,8 @@ test_object_visit(void H5_ATTR_UNUSED *params)

i = 0;

if (H5Ovisit_by_name(attr_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, object_visit_simple_callback,
&i, H5O_INFO_ALL, H5P_DEFAULT) < 0) {
if (H5Ovisit_by_name3(attr_id, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, object_visit_simple_callback,
&i, H5O_INFO_ALL, H5P_DEFAULT) < 0) {
H5_FAILED();
printf(" H5Ovisit_by_name on an attribute failed!\n");
PART_ERROR(H5Ovisit_by_name_attr);
Expand Down

0 comments on commit 2d0c676

Please sign in to comment.