summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-29 04:13:02 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-29 04:13:02 (GMT)
commit2f3344a0495c09448e7fac023c8d91a567110a48 (patch)
treea060e469e3129f63e63ffa1d6e2813bd6d9e1436 /test
parent1b16195060d142f4e78a447d1ea360401bcf722d (diff)
downloadhdf5-2f3344a0495c09448e7fac023c8d91a567110a48.zip
hdf5-2f3344a0495c09448e7fac023c8d91a567110a48.tar.gz
hdf5-2f3344a0495c09448e7fac023c8d91a567110a48.tar.bz2
[svn-r12994] Description:
Propagate object creation properties up into group, dataset and named datatype property lists, when those property lists are retrieved for existing objects in a file. Also, add H5Tget_create_plist() API routine, to allow named datatype property lists to be retrieved for named datatypes. Tested on: FreeBSD/32 4.11 (sleipnir) Linux/32 2.4 (heping) Linux/64 2.4 (mir) AIX/32 5.? (copper)
Diffstat (limited to 'test')
-rw-r--r--test/ohdr.c3
-rw-r--r--test/th5o.c167
2 files changed, 167 insertions, 3 deletions
diff --git a/test/ohdr.c b/test/ohdr.c
index 6a8bec9..cc8841e 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -81,10 +81,11 @@ main(void)
/*
* Test object header creation
+ * (using default group creation property list only because it's convenient)
*/
TESTING("object header creation");
HDmemset(&oh_loc, 0, sizeof(oh_loc));
- if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, &oh_loc/*out*/)<0) {
+ if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/)<0) {
H5_FAILED();
H5Eprint_stack(H5E_DEFAULT, stdout);
goto error;
diff --git a/test/th5o.c b/test/th5o.c
index 1743a6b..ad12e30 100644
--- a/test/th5o.c
+++ b/test/th5o.c
@@ -564,6 +564,170 @@ test_h5o_refcount(void)
/****************************************************************
**
+** test_h5o_plist(): Test object creation properties
+**
+****************************************************************/
+static void
+test_h5o_plist(void)
+{
+ hid_t fid; /* HDF5 File ID */
+ hid_t grp, dset, dtype, dspace; /* Object identifiers */
+ hid_t fapl; /* File access property list */
+ hid_t gcpl, dcpl, tcpl; /* Object creation properties */
+ unsigned def_max_compact, def_min_dense; /* Default phase change parameters */
+ unsigned max_compact, min_dense; /* Actual phase change parameters */
+ herr_t ret; /* Value returned from API calls */
+
+ /* Make a FAPL that uses the "use the latest version of the format" flag */
+ fapl = H5Pcreate(H5P_FILE_ACCESS);
+ CHECK(fapl, FAIL, "H5Pcreate");
+
+ /* Set the "use the latest version of the format" flag for creating objects in the file */
+ ret = H5Pset_latest_format(fapl, TRUE);
+ CHECK(ret, FAIL, "H5Pset_latest_format");
+
+ /* Create a new HDF5 file */
+ fid = H5Fcreate(TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ CHECK(fid, FAIL, "H5Fcreate");
+
+ /* Create group, dataset & named datatype creation property lists */
+ gcpl = H5Pcreate(H5P_GROUP_CREATE);
+ CHECK(gcpl, FAIL, "H5Pcreate");
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ CHECK(dcpl, FAIL, "H5Pcreate");
+ tcpl = H5Pcreate(H5P_DATATYPE_CREATE);
+ CHECK(tcpl, FAIL, "H5Pcreate");
+
+ /* Retrieve default attribute phase change values */
+ ret = H5Pget_attr_phase_change(gcpl, &def_max_compact, &def_min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+
+ /* Set non-default attribute phase change values on each creation property list */
+ ret = H5Pset_attr_phase_change(gcpl, def_max_compact + 1, def_min_dense - 1);
+ CHECK(ret, FAIL, "H5Pset_attr_phase_change");
+ ret = H5Pset_attr_phase_change(dcpl, def_max_compact + 1, def_min_dense - 1);
+ CHECK(ret, FAIL, "H5Pset_attr_phase_change");
+ ret = H5Pset_attr_phase_change(tcpl, def_max_compact + 1, def_min_dense - 1);
+ CHECK(ret, FAIL, "H5Pset_attr_phase_change");
+
+ /* Retrieve attribute phase change values on each creation property list and verify */
+ ret = H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(max_compact, (def_max_compact + 1), "H5Pget_attr_phase_change");
+ VERIFY(min_dense, (def_min_dense - 1), "H5Pget_attr_phase_change");
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(max_compact, (def_max_compact + 1), "H5Pget_attr_phase_change");
+ VERIFY(min_dense, (def_min_dense - 1), "H5Pget_attr_phase_change");
+ ret = H5Pget_attr_phase_change(tcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(max_compact, (def_max_compact + 1), "H5Pget_attr_phase_change");
+ VERIFY(min_dense, (def_min_dense - 1), "H5Pget_attr_phase_change");
+
+ /* Create a group, dataset, and committed datatype within the file,
+ * using the respective type of creation property lists.
+ */
+
+ /* Create the group */
+ grp = H5Gcreate_expand(fid, gcpl, H5P_DEFAULT);
+ CHECK(grp, FAIL, "H5Gcreate_expand");
+ ret = H5Llink(fid, "group", grp, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Llink");
+
+ /* Commit the type inside the group */
+ dtype = H5Tcopy(H5T_NATIVE_INT);
+ CHECK(dtype, FAIL, "H5Tcopy");
+ ret = H5Tcommit_expand(fid, dtype, tcpl, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Tcommit_expand");
+ ret = H5Llink(fid, "datatype", dtype, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Llink");
+
+ /* Create the dataspace for the dataset. */
+ dspace = H5Screate(H5S_SCALAR);
+ CHECK(dspace, FAIL, "H5Screate");
+
+ /* Create the dataset. */
+ dset = H5Dcreate_expand(fid, H5T_NATIVE_INT, dspace, dcpl, H5P_DEFAULT);
+ CHECK(dset, FAIL, "H5Dcreate_expand");
+ ret = H5Llink(fid, "dataset", dset, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Llink");
+ ret = H5Sclose(dspace);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close current objects */
+ ret = H5Pclose(gcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(tcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Gclose(grp);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Tclose(dtype);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Re-open the file and check that the object creation properties persist */
+ fid = H5Fopen(TEST_FILENAME, H5F_ACC_RDONLY, fapl);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Re-open objects */
+ grp = H5Gopen(fid, "group");
+ CHECK(grp, FAIL, "H5Gopen");
+ dtype = H5Topen(fid, "datatype");
+ CHECK(dtype, FAIL, "H5Topen");
+ dset = H5Dopen(fid, "dataset");
+ CHECK(dset, FAIL, "H5Dopen");
+
+ /* Retrieve each object's creation property list */
+ gcpl = H5Gget_create_plist(grp);
+ CHECK(gcpl, FAIL, "H5Gget_create_plist");
+ tcpl = H5Tget_create_plist(dtype);
+ CHECK(dcpl, FAIL, "H5Tget_create_plist");
+ dcpl = H5Dget_create_plist(dset);
+ CHECK(dcpl, FAIL, "H5Dget_create_plist");
+
+ /* Retrieve attribute phase change values on each creation property list and verify */
+ ret = H5Pget_attr_phase_change(gcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(max_compact, (def_max_compact + 1), "H5Pget_attr_phase_change");
+ VERIFY(min_dense, (def_min_dense - 1), "H5Pget_attr_phase_change");
+ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(max_compact, (def_max_compact + 1), "H5Pget_attr_phase_change");
+ VERIFY(min_dense, (def_min_dense - 1), "H5Pget_attr_phase_change");
+ ret = H5Pget_attr_phase_change(tcpl, &max_compact, &min_dense);
+ CHECK(ret, FAIL, "H5Pget_attr_phase_change");
+ VERIFY(max_compact, (def_max_compact + 1), "H5Pget_attr_phase_change");
+ VERIFY(min_dense, (def_min_dense - 1), "H5Pget_attr_phase_change");
+
+ /* Close current objects */
+ ret = H5Pclose(gcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Pclose(tcpl);
+ CHECK(ret, FAIL, "H5Pclose");
+ ret = H5Gclose(grp);
+ CHECK(ret, FAIL, "H5Gclose");
+ ret = H5Tclose(dtype);
+ CHECK(ret, FAIL, "H5Tclose");
+ ret = H5Dclose(dset);
+ CHECK(ret, FAIL, "H5Dclose");
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Close the FAPL */
+ ret = H5Pclose(fapl);
+ CHECK(ret, FAIL, "H5Pclose");
+} /* test_h5o_plist() */
+
+
+/****************************************************************
+**
** test_h5o(): Main H5O (generic object) testing routine.
**
****************************************************************/
@@ -577,6 +741,7 @@ test_h5o(void)
test_h5o_open_by_addr(); /* Test opening objects by address */
test_h5o_close(); /* Test generic close function */
test_h5o_refcount(); /* Test incrementing and decrementing reference count */
+ test_h5o_plist(); /* Test object creation properties */
} /* test_h5o() */
@@ -590,8 +755,6 @@ test_h5o(void)
* Programmer: James Laird
* June 3, 2006
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void