summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2019-04-18 18:15:14 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2019-04-18 18:15:14 (GMT)
commit11c8c9835281d36d8a7a3a962838d9c6abc7f777 (patch)
tree1f83087377ed17f3be2e8a5ca0d478c0f1349f18 /test
parent80ec7cfd6ad5de0c975998172d63a8953507b84d (diff)
parent53a5c3be903ce7c24d02a6bd3a8d9b07a3f82404 (diff)
downloadhdf5-11c8c9835281d36d8a7a3a962838d9c6abc7f777.zip
hdf5-11c8c9835281d36d8a7a3a962838d9c6abc7f777.tar.gz
hdf5-11c8c9835281d36d8a7a3a962838d9c6abc7f777.tar.bz2
Merge pull request #1654 in HDFFV/hdf5 from ~VCHOI/my_third_fork:bugfix/HDFFV-10579-h5arename-function-fails-when to develop
* commit '53a5c3be903ce7c24d02a6bd3a8d9b07a3f82404': Change the checking to H5I_INVALID_HID in test_attr_dense_rename(). Fix for HDFFV-10579 H5Arename fails when creation order of attributes is tracked. The attribute needs to be removed from the creation order index v2 B-tree before re-inserting the renamed attribute via H5A__dense_insert().
Diffstat (limited to 'test')
-rw-r--r--test/tattr.c109
1 files changed, 63 insertions, 46 deletions
diff --git a/test/tattr.c b/test/tattr.c
index 454ea71..37763da 100644
--- a/test/tattr.c
+++ b/test/tattr.c
@@ -2626,6 +2626,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
H5O_info_t oinfo; /* Object info */
unsigned u; /* Local index variable */
int use_min_dset_oh = (dcpl_g != H5P_DEFAULT);
+ unsigned use_corder; /* Track creation order or not */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
@@ -2641,7 +2642,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
CHECK(ret, FAIL, "H5Pset_file_space_strategy");
}
fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl);
- CHECK(fid, FAIL, "H5Fcreate");
+ CHECK(fid, H5I_INVALID_HID, "H5Fcreate");
if (use_min_dset_oh)
CHECK(H5Pclose(fcpl), FAIL, "H5Pclose");
@@ -2656,76 +2657,92 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
- CHECK(fid, FAIL, "H5Fopen");
+ CHECK(fid, H5I_INVALID_HID, "H5Fopen");
/* Create dataspace for dataset */
sid = H5Screate(H5S_SCALAR);
- CHECK(sid, FAIL, "H5Screate");
+ CHECK(sid, H5I_INVALID_HID, "H5Screate");
/* need DCPL to query the group creation properties */
if (use_min_dset_oh) {
dcpl = H5Pcopy(dcpl_g);
- CHECK(dcpl, FAIL, "H5Pcopy");
+ CHECK(dcpl, H5I_INVALID_HID, "H5Pcopy");
} else {
dcpl = H5Pcreate(H5P_DATASET_CREATE);
- CHECK(dcpl, FAIL, "H5Pcreate");
+ CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate");
}
- /* Create a dataset */
- dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
- CHECK(dataset, FAIL, "H5Dcreate2");
-
/* Retrieve limits for compact/dense attribute storage */
ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense);
CHECK(ret, FAIL, "H5Pget_attr_phase_change");
- /* Close property list */
- ret = H5Pclose(dcpl);
- CHECK(ret, FAIL, "H5Pclose");
+ /* Using creation order or not */
+ for(use_corder = FALSE; use_corder <= TRUE; use_corder++) {
- /* Check on dataset's attribute storage status */
- is_dense = H5O__is_attr_dense_test(dataset);
- VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
+ if(use_corder) {
+ ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
+ CHECK(ret, FAIL, "H5Pset_attr_creation_order");
+ }
- /* Add attributes, until well into dense storage */
- for(u = 0; u < (max_compact * 2); u++) {
- /* Create attribute */
- sprintf(attrname, "attr %02u", u);
- attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Acreate2");
+ /* Create a dataset */
+ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT);
+ CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2");
- /* Write data into the attribute */
- ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
- CHECK(ret, FAIL, "H5Awrite");
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test");
- /* Close attribute */
- ret = H5Aclose(attr);
- CHECK(ret, FAIL, "H5Aclose");
+ /* Add attributes, until well into dense storage */
+ for(u = 0; u < (max_compact * 2); u++) {
+ /* Create attribute */
+ sprintf(attrname, "attr %02u", u);
+ attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(attr, H5I_INVALID_HID, "H5Acreate2");
- /* Rename attribute */
- sprintf(new_attrname, "new attr %02u", u);
+ /* Write data into the attribute */
+ ret = H5Awrite(attr, H5T_NATIVE_UINT, &u);
+ CHECK(ret, FAIL, "H5Awrite");
- /* Rename attribute */
- ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT);
- CHECK(ret, FAIL, "H5Arename_by_name");
+ /* Close attribute */
+ ret = H5Aclose(attr);
+ CHECK(ret, FAIL, "H5Aclose");
- /* Check # of attributes */
- ret = H5Oget_info2(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
- CHECK(ret, FAIL, "H5Oget_info");
- VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info");
- } /* end for */
+ /* Rename attribute */
+ sprintf(new_attrname, "new attr %02u", u);
- /* Check on dataset's attribute storage status */
- is_dense = H5O__is_attr_dense_test(dataset);
- VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
+ /* Rename attribute */
+ ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Arename_by_name");
+
+ /* Check # of attributes */
+ ret = H5Oget_info2(dataset, &oinfo, H5O_INFO_NUM_ATTRS);
+ CHECK(ret, FAIL, "H5Oget_info");
+ VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info");
+ } /* end for */
+
+ /* Check on dataset's attribute storage status */
+ is_dense = H5O__is_attr_dense_test(dataset);
+ VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ if(!use_corder) {
+ /* Unlink dataset with attributes */
+ ret = H5Ldelete(fid, DSET1_NAME, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Ldelete");
+ }
+
+ } /* end for use_corder */
/* Close dataspace */
ret = H5Sclose(sid);
CHECK(ret, FAIL, "H5Sclose");
- /* Close Dataset */
- ret = H5Dclose(dataset);
- CHECK(ret, FAIL, "H5Dclose");
+ /* Close property list */
+ ret = H5Pclose(dcpl);
+ CHECK(ret, FAIL, "H5Pclose");
/* Close file */
ret = H5Fclose(fid);
@@ -2734,11 +2751,11 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
/* Re-open file */
fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl);
- CHECK(fid, FAIL, "H5Fopen");
+ CHECK(fid, H5I_INVALID_HID, "H5Fopen");
/* Open dataset */
dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT);
- CHECK(dataset, FAIL, "H5Dopen2");
+ CHECK(dataset, H5I_INVALID_HID, "H5Dopen2");
/* Verify renamed attributes */
for(u = 0; u < (max_compact * 2); u++) {
@@ -2747,7 +2764,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl)
/* Open attribute */
sprintf(attrname, "new attr %02u", u);
attr = H5Aopen(dataset, attrname, H5P_DEFAULT);
- CHECK(attr, FAIL, "H5Aopen");
+ CHECK(attr, H5I_INVALID_HID, "H5Aopen");
/* Read data from the attribute */
ret = H5Aread(attr, H5T_NATIVE_UINT, &value);