summaryrefslogtreecommitdiffstats
path: root/test/dsets.c
diff options
context:
space:
mode:
authorDavid Young <dyoung@hdfgroup.org>2020-09-03 21:13:47 (GMT)
committerDavid Young <dyoung@hdfgroup.org>2020-09-03 21:13:47 (GMT)
commitd85cd245d29d72990ded9fdf60a2b849a85b1912 (patch)
tree83aaf2f0b9acc06c1d69af4c843fa23927822efb /test/dsets.c
parent651facc1446c36e6d77cc328682dac397bae27e3 (diff)
parentb3a89155b986bca9c436d4ff6c229a68ac23f1ef (diff)
downloadhdf5-d85cd245d29d72990ded9fdf60a2b849a85b1912.zip
hdf5-d85cd245d29d72990ded9fdf60a2b849a85b1912.tar.gz
hdf5-d85cd245d29d72990ded9fdf60a2b849a85b1912.tar.bz2
Merge remote-tracking branch 'hdffv/develop' into rebased-fprintf-experiment
Diffstat (limited to 'test/dsets.c')
-rw-r--r--test/dsets.c117
1 files changed, 109 insertions, 8 deletions
diff --git a/test/dsets.c b/test/dsets.c
index fdaea7c..c06ac97 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -12,7 +12,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Purpose: Tests the dataset interface (H5D)
@@ -112,6 +112,8 @@ const char *FILENAME[] = {
#define DSET_FLETCHER32_NAME_3 "fletcher32_3"
#define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32"
#define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2"
+#define DSET_OPTIONAL_SCALAR "dataset_with_scalar_space"
+#define DSET_OPTIONAL_VLEN "dataset_with_vlen_type"
#ifdef H5_HAVE_FILTER_SZIP
#define DSET_SZIP_NAME "szip"
#define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32"
@@ -1888,7 +1890,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR;
/* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
} H5E_END_TRY;
if(status>=0) TEST_ERROR;
}
@@ -1934,7 +1936,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
/* Default behavior is failure when data is corrupted. */
/* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
} H5E_END_TRY;
if(status>=0) TEST_ERROR;
@@ -1947,7 +1949,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR;
/* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
} H5E_END_TRY;
if(status>=0) TEST_ERROR;
}
@@ -2048,7 +2050,7 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
/* Default behavior is failure when data is corrupted. */
/* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
} H5E_END_TRY;
if(status>=0) TEST_ERROR;
@@ -2061,12 +2063,12 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32,
if(H5Pset_filter_callback(write_dxpl, filter_cb_fail, NULL) < 0) TEST_ERROR;
/* (Use the "write" DXPL in order to make certain corruption is seen) */
H5E_BEGIN_TRY {
- status=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
+ status = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, write_dxpl, check_data);
} H5E_END_TRY;
if(status>=0) TEST_ERROR;
}
else {
- if(H5Dread (dataset, H5T_NATIVE_INT, sid, sid, dxpl, check_data) < 0)
+ if(H5Dread(dataset, H5T_NATIVE_INT, sid, sid, dxpl, check_data) < 0)
TEST_ERROR;
/* Check that the values read are the same as the values written */
@@ -5770,6 +5772,101 @@ error:
} /* end test_can_apply2() */
+/*-------------------------------------------------------------------------
+ * Function: test_optional_filters
+ *
+ * Purpose: Tests that H5Dcreate2 will not fail when a combination of
+ * type, space, etc... doesn't work for a filter and filter is
+ * optional.
+ *
+ * Return: Success: SUCCEED
+ * Failure: FAIL
+ *
+ * Programmer: Binh-Minh Ribler
+ * 24 July 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+test_optional_filters(hid_t file)
+{
+ unsigned int level = 9;
+ unsigned int cd_values[1] = {level};
+ size_t cd_nelmts = 1;
+ hsize_t dim1d[1]; /* Dataspace dimensions */
+ hid_t dsid = H5I_INVALID_HID; /* Dataset ID */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t strtid = H5I_INVALID_HID; /* Datatype ID for string */
+ hid_t vlentid = H5I_INVALID_HID; /* Datatype ID for vlen */
+ hid_t dcplid = H5I_INVALID_HID; /* Dataspace creation property list ID */
+
+ TESTING("dataset with optional filters");
+
+ /* Create dcpl with special filter */
+ if((dcplid = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR;
+
+ /* Create the datatype */
+ if((strtid = H5Tcreate(H5T_STRING, H5T_VARIABLE)) < 0) TEST_ERROR;
+
+ /* Create the data space */
+ if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR;
+
+ /* The filter is optional. */
+ if(H5Pset_filter(dcplid, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, cd_nelmts, cd_values) < 0)
+ TEST_ERROR;
+
+ /* Create dataset with optional filter */
+ if((dsid = H5Dcreate2(file, DSET_OPTIONAL_SCALAR, strtid, sid, H5P_DEFAULT, dcplid, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Close dataset */
+ if(H5Dclose(dsid) < 0) TEST_ERROR;
+
+ /* Close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* Close datatype */
+ if(H5Tclose(strtid) < 0) TEST_ERROR;
+
+ /* Set dataspace dimensions */
+ dim1d[0]=DIM1;
+
+ /* Create a non-scalar dataspace */
+ if((sid = H5Screate_simple(1, dim1d, NULL)) < 0) TEST_ERROR;
+
+ /* Create a vlen datatype */
+ if((vlentid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR;
+
+ /* Create dataset with optional filter */
+ if((dsid = H5Dcreate2(file, DSET_OPTIONAL_VLEN, vlentid, sid, H5P_DEFAULT, dcplid, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Close dataset */
+ if(H5Dclose(dsid) < 0) TEST_ERROR;
+
+ /* Close dataspace */
+ if(H5Sclose(sid) < 0) TEST_ERROR;
+
+ /* Close datatype */
+ if(H5Tclose(vlentid) < 0) TEST_ERROR;
+
+ /* Close dataset creation property list */
+ if(H5Pclose(dcplid) < 0) TEST_ERROR;
+
+ PASSED();
+ return SUCCEED;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(dsid);
+ H5Sclose(sid);
+ H5Pclose(dcplid);
+ H5Tclose(strtid);
+ H5Tclose(vlentid);
+ } H5E_END_TRY;
+ return FAIL;
+} /* end test_optional_filters() */
+
/*-------------------------------------------------------------------------
* Function: test_can_apply_szip
@@ -11237,6 +11334,9 @@ test_bt2_hdr_fd(const char *env_h5_driver, hid_t fapl)
TESTING("Version 2 B-tree chunk index header flush dependencies handled correctly");
+ /* Initialize struct */
+ HDmemset(&info, 0, sizeof(info));
+
/* Skip this test if SWMR I/O is not supported for the VFD specified
* by the environment variable.
*/
@@ -13366,7 +13466,7 @@ test_versionbounds(void)
return FAIL;
} /* end test_versionbounds() */
-
+
/*-----------------------------------------------------------------------------
* Function: test_object_header_minimization_dcpl
*
@@ -13862,6 +13962,7 @@ main(void)
nerrors += (test_missing_filter(file) < 0 ? 1 : 0);
nerrors += (test_can_apply(file) < 0 ? 1 : 0);
nerrors += (test_can_apply2(file) < 0 ? 1 : 0);
+ nerrors += (test_optional_filters(file) < 0 ? 1 : 0);
nerrors += (test_set_local(my_fapl) < 0 ? 1 : 0);
nerrors += (test_can_apply_szip(file) < 0 ? 1 : 0);
nerrors += (test_compare_dcpl(file) < 0 ? 1 : 0);