summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorraylu-hdf <60487644+raylu-hdf@users.noreply.github.com>2023-01-10 17:29:54 (GMT)
committerGitHub <noreply@github.com>2023-01-10 17:29:54 (GMT)
commit5543d6eb36bbb32ede0598b0f36641933368f90f (patch)
tree99008aea72c19c91338a296b5bec9cfadfd81eab /test
parent06c12f97cd309f661926a7cbc007325cd4284d52 (diff)
downloadhdf5-5543d6eb36bbb32ede0598b0f36641933368f90f.zip
hdf5-5543d6eb36bbb32ede0598b0f36641933368f90f.tar.gz
hdf5-5543d6eb36bbb32ede0598b0f36641933368f90f.tar.bz2
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>
Diffstat (limited to 'test')
-rw-r--r--test/vol.c80
1 files changed, 80 insertions, 0 deletions
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" : "");