summaryrefslogtreecommitdiffstats
path: root/test/tsohm.c
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2008-07-22 20:36:31 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2008-07-22 20:36:31 (GMT)
commit8704820d1c56165fcf930ab21adebea0a48c664f (patch)
treeb74991b3c84c1a6d52e1003c7668863b1fd3dfb4 /test/tsohm.c
parent717388ea0683ff9db970cd8f8998ba9b94d62cf0 (diff)
downloadhdf5-8704820d1c56165fcf930ab21adebea0a48c664f.zip
hdf5-8704820d1c56165fcf930ab21adebea0a48c664f.tar.gz
hdf5-8704820d1c56165fcf930ab21adebea0a48c664f.tar.bz2
[svn-r15395] When an attribute was opened twice and data was written with one of the handles,
the file didn't have the data. It happened because each handle had its own object structure, and the empty one overwrote the data with fill value. This is fixed by making some attribute information like the data be shared in the attribute structure. Tested on smirom, kagiso, and linew.
Diffstat (limited to 'test/tsohm.c')
-rw-r--r--test/tsohm.c49
1 files changed, 48 insertions, 1 deletions
diff --git a/test/tsohm.c b/test/tsohm.c
index 0fc94f2..e213d25 100644
--- a/test/tsohm.c
+++ b/test/tsohm.c
@@ -974,13 +974,16 @@ static void sohm_attr_helper(hid_t fcpl_id)
hid_t type_id;
hid_t space_id;
hid_t group_id;
- hid_t attr_id;
+ hid_t attr_id, attr_id2;
hsize_t dims = 2;
int wdata[2] = {7, 42};
int rdata[2];
herr_t ret;
size_t x;
+ /*----------------------------------------------------------------------------
+ * Test attribute with transient datatype
+ */
/* Create a file using the fcpl */
file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT);
CHECK_I(file_id, "H5Fcreate");
@@ -1021,6 +1024,9 @@ static void sohm_attr_helper(hid_t fcpl_id)
ret = H5Aclose(attr_id);
CHECK_I(ret, "H5Aclose");
+ /*----------------------------------------------------------------------------
+ * Test attribute with committed datatype
+ */
/* Repeat with a committed datatype */
type_id = H5Tcopy(H5T_NATIVE_INT);
CHECK_I(type_id, "H5Tcopy");
@@ -1056,6 +1062,47 @@ static void sohm_attr_helper(hid_t fcpl_id)
/* Cleanup */
ret = H5Aclose(attr_id);
CHECK_I(ret, "H5Aclose");
+
+ /*----------------------------------------------------------------------------
+ * Test attribute operation with two ID handles
+ */
+ /* Create and verify an attribute */
+ group_id = H5Gcreate2(file_id, "yet_another_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK_I(group_id, "H5Gcreate2");
+
+ attr_id = H5Acreate2(group_id, "attribute", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK_I(attr_id, "H5Acreate2");
+
+ /* Open the attribute to get another handle */
+ attr_id2 = H5Aopen(group_id, "attribute", H5P_DEFAULT);
+ CHECK_I(attr_id2, "H5Aopen");
+
+ ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata);
+ CHECK_I(ret, "H5Awrite");
+
+ /* Close the group */
+ ret = H5Gclose(group_id);
+ CHECK_I(ret, "H5Gclose");
+
+ /* Flush the file to force data to be written */
+ ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+ CHECK_I(ret, "H5Fflush");
+
+ /* Verify the data with another ID handle */
+ memset(rdata, 0, sizeof(rdata));
+ ret = H5Aread(attr_id2, H5T_NATIVE_INT, rdata);
+ CHECK_I(ret, "H5Aread");
+
+ for(x=0; x<(size_t)dims; ++x) {
+ VERIFY(rdata[x], wdata[x], "H5Aread");
+ }
+
+ /* Cleanup */
+ ret = H5Aclose(attr_id);
+ CHECK_I(ret, "H5Aclose");
+ ret = H5Aclose(attr_id2);
+ CHECK_I(ret, "H5Aclose");
+
ret = H5Sclose(space_id);
CHECK_I(ret, "H5Sclose");
ret = H5Fclose(file_id);