diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-10-19 03:31:11 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-10-19 03:31:11 (GMT) |
commit | a4c0ed037424ada07720a22ebb15a58f199c5b78 (patch) | |
tree | c67f19286f10b58c299a0fbd0eab0756eb5c7853 /test/tattr.c | |
parent | 4f846baa4a2ab80ac70a8b288589e307926534bf (diff) | |
download | hdf5-a4c0ed037424ada07720a22ebb15a58f199c5b78.zip hdf5-a4c0ed037424ada07720a22ebb15a58f199c5b78.tar.gz hdf5-a4c0ed037424ada07720a22ebb15a58f199c5b78.tar.bz2 |
[svn-r9433] Purpose:
Bug fix
Description:
Fix core dump when flushing a file with a newly created attribute which
hasn't had a value written to it still open.
Solution:
Write the attribute fill value when appropriate.
Platforms tested:
FreeBSd 4.10 (sleipnir)
Linux 2.4 (verbena)
Solaris 2.7 (arabica)
Diffstat (limited to 'test/tattr.c')
-rw-r--r-- | test/tattr.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/test/tattr.c b/test/tattr.c index ded9a79..6727442 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -395,6 +395,72 @@ test_attr_basic_read(void) /**************************************************************** ** +** test_attr_flush(): Test H5A (attribute) code for performing +** I/O when H5Fflush is used. +** +****************************************************************/ +static void +test_attr_flush(void) +{ + hid_t fil, /* File ID */ + att, /* Attribute ID */ + spc, /* Dataspace ID */ + set; /* Dataset ID */ + double wdata=3.14159; /* Data to write */ + double rdata; /* Data read in */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Attribute Flushing\n")); + + fil = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fil, FAIL, "H5Fcreate"); + + spc = H5Screate(H5S_SCALAR); + CHECK(spc, FAIL, "H5Screate"); + + set = H5Dcreate(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT); + CHECK(set, FAIL, "H5Dcreate"); + + att = H5Acreate(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT); + CHECK(att, FAIL, "H5Acreate"); + + ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); + CHECK(ret, FAIL, "H5Awrite"); + + if(rdata!=0.0) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,0.0); + + ret=H5Fflush(fil, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); + + ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); + CHECK(ret, FAIL, "H5Awrite"); + + if(rdata!=0.0) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,0.0); + + ret=H5Awrite(att, H5T_NATIVE_DOUBLE, &wdata); + CHECK(ret, FAIL, "H5Awrite"); + + ret=H5Aread(att, H5T_NATIVE_DOUBLE, &rdata); + CHECK(ret, FAIL, "H5Awrite"); + + if(rdata!=wdata) + TestErrPrintf("attribute value wrong: rdata=%f, should be %f\n",rdata,wdata); + + ret=H5Sclose(spc); + CHECK(ret, FAIL, "H5Sclose"); + ret=H5Aclose(att); + CHECK(ret, FAIL, "H5Aclose"); + ret=H5Dclose(set); + CHECK(ret, FAIL, "H5Dclose"); + ret=H5Fclose(fil); + CHECK(ret, FAIL, "H5Fclose"); +} /* test_attr_basic_flush() */ + +/**************************************************************** +** ** test_attr_compound_write(): Test H5A (attribute) code. ** Tests compound datatype attributes ** @@ -1503,6 +1569,7 @@ test_attr(void) /* These next two tests use the same file information */ test_attr_basic_write(); /* Test basic H5A writing code */ test_attr_basic_read(); /* Test basic H5A reading code */ + test_attr_flush(); /* Test H5A I/O in the presence of H5Fflush calls */ /* These next two tests use the same file information */ test_attr_compound_write(); /* Test complex datatype H5A writing code */ |