From 5543d6eb36bbb32ede0598b0f36641933368f90f Mon Sep 17 00:00:00 2001 From: raylu-hdf <60487644+raylu-hdf@users.noreply.github.com> Date: Tue, 10 Jan 2023 11:29:54 -0600 Subject: HDFFV-11208 (OESS-320): H5VLquery_optional had an assertion failure with a committed datatype (#2398) * HDFFV-11208 (OESS-320): H5VLquery_optional had an assertion failure with a committed datatype. Added a test case for the fix that Quincey checked in. * Committing clang-format changes * Fixed a typo in a comment. * Fixed a typo in a comment. * Minor change: changed H5Tcommit to H5Tcommit2. Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- test/vol.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/test/vol.c b/test/vol.c index e50476f..4cfb3de 100644 --- a/test/vol.c +++ b/test/vol.c @@ -2363,6 +2363,85 @@ error: } /* end test_wrap_register() */ /*------------------------------------------------------------------------- + * Function: test_query_optional + * + * Purpose: Tests the bug fix (HDFFV-11208) that a committed datatype + * triggered an assertion failure in H5VLquery_optional + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_query_optional(void) +{ + hid_t fapl_id = H5I_INVALID_HID; + hid_t file_id = H5I_INVALID_HID; + hid_t group_id = H5I_INVALID_HID; + hid_t dtype_id = H5I_INVALID_HID; + char filename[NAME_LEN]; + uint64_t supported = 0; + + TESTING("H5VLquery_optional"); + + /* Retrieve the file access property for testing */ + fapl_id = h5_fileaccess(); + + h5_fixname(FILENAME[0], fapl_id, filename, sizeof filename); + + if ((file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + TEST_ERROR; + + if ((group_id = H5Gcreate2(file_id, "test_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Test H5VLquery_optional with a group */ + if (H5VLquery_optional(group_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported) < 0) + TEST_ERROR; + + if ((dtype_id = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR; + + /* Commit the datatype into the file */ + if (H5Tcommit2(file_id, "test_dtype", dtype_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR; + + /* Test H5VLquery_optional with a committed datatype where the assertion failure happened in the past */ + if (H5VLquery_optional(dtype_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported) < 0) + TEST_ERROR; + + if (H5Gclose(group_id) < 0) + TEST_ERROR; + + if (H5Tclose(dtype_id) < 0) + TEST_ERROR; + + if (H5Fclose(file_id) < 0) + TEST_ERROR; + + h5_delete_test_file(FILENAME[0], fapl_id); + + if (H5Pclose(fapl_id) < 0) + TEST_ERROR; + + PASSED(); + + return SUCCEED; + +error: + H5E_BEGIN_TRY + { + H5Gclose(group_id); + H5Tclose(dtype_id); + H5Fclose(file_id); + H5Pclose(fapl_id); + } + H5E_END_TRY; + + return FAIL; +} /* end test_query_optional() */ + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the virtual object layer interface (H5VL) @@ -2400,6 +2479,7 @@ main(void) nerrors += test_vol_cap_flags() < 0 ? 1 : 0; nerrors += test_get_vol_name() < 0 ? 1 : 0; nerrors += test_wrap_register() < 0 ? 1 : 0; + nerrors += test_query_optional() < 0 ? 1 : 0; if (nerrors) { HDprintf("***** %d Virtual Object Layer TEST%s FAILED! *****\n", nerrors, nerrors > 1 ? "S" : ""); -- cgit v0.12