summaryrefslogtreecommitdiffstats
path: root/c++/test
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 /c++/test
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 'c++/test')
-rw-r--r--c++/test/tattr.cpp27
-rw-r--r--c++/test/tvlstr.cpp2
2 files changed, 15 insertions, 14 deletions
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index 0d545d7..fe95fe7 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -1050,6 +1050,11 @@ static void test_attr_dtype_shared()
// Open the file again
fid1.openFile(FILENAME, H5F_ACC_RDWR);
+ // Enclosing to work around the issue of unused variables and/or
+ // objects created by copy constructors stay around until end of
+ // scope, causing incorrect number of ref counts.
+ { // First enclosed block
+
// Create a datatype to commit and use
IntType dtype(PredType::NATIVE_INT);
@@ -1065,13 +1070,6 @@ static void test_attr_dtype_shared()
// Create dataspace for dataset
DataSpace dspace;
- // Enclose the following so that all temporary objects can be
- // destroyed before testing reference count - this is to overcome
- // the different time when the temporary objects are to be destroyed
- // by different compilers.
- {
-
- // Create dataset
DataSet dset = fid1.createDataSet(DSET1_NAME, dtype, dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
@@ -1089,8 +1087,8 @@ static void test_attr_dtype_shared()
verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- // Close attribute
- attr.close();
+ // Close attribute
+ attr.close();
// Delete attribute
dset.removeAttr(ATTR1_NAME);
@@ -1101,8 +1099,8 @@ static void test_attr_dtype_shared()
verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__, __FILE__);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
- // Create attribute on dataset
- attr = dset.createAttribute(ATTR1_NAME,dtype,dspace);
+ // Create attribute on dataset
+ attr = dset.createAttribute(ATTR1_NAME,dtype,dspace);
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
@@ -1118,11 +1116,15 @@ static void test_attr_dtype_shared()
dset.close();
dspace.close();
dtype.close();
+ } // end of first enclosing
+
fid1.close();
// Open the file again
fid1.openFile(FILENAME, H5F_ACC_RDWR);
+ { // Second enclosed block...
+
// Open dataset
DataSet *dset2 = new DataSet (fid1.openDataSet(DSET1_NAME));
@@ -1142,12 +1144,11 @@ static void test_attr_dtype_shared()
fid1.getObjinfo(TYPE1_NAME, statbuf);
verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
+ } // end of second enclosing
// Unlink the dataset
fid1.unlink(DSET1_NAME);
- } // end of enclosing to test reference counts
-
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 007ab10..d4d0fd1 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -416,7 +416,7 @@ static void test_vlstring_type()
file1 = new H5File(FILENAME, H5F_ACC_RDWR);
// Open the variable-length string datatype just created
- vlstr_type.setId((file1->openStrType(VLSTR_TYPE)).getId());
+ vlstr_type = file1->openStrType(VLSTR_TYPE);
// Verify character set and padding
cset = vlstr_type.getCset();