summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-08-15 06:26:08 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-08-15 06:26:08 (GMT)
commit173083e1a5c9696be01bd983dd8c9bb87eb5a433 (patch)
treec8c4aa2dd961d18b48d0c734da3e16ea107e6c6f /test
parentec7ca0dea2fba8071ce57e4f61d685c3e4d0d111 (diff)
downloadhdf5-173083e1a5c9696be01bd983dd8c9bb87eb5a433.zip
hdf5-173083e1a5c9696be01bd983dd8c9bb87eb5a433.tar.gz
hdf5-173083e1a5c9696be01bd983dd8c9bb87eb5a433.tar.bz2
[svn-r17365] Description:
Final merge of changes from sblock_mdc branch back to trunk. The superblock is now managed by the metadata cache. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.8 (amazon) in debug mode Mac OS X/32 10.5.8 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test')
-rw-r--r--test/tfile.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/test/tfile.c b/test/tfile.c
index 2116a2c..07ccfb2 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -1351,7 +1351,7 @@ test_file_ishdf5(void)
/* Create non-HDF5 file and check it */
fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666);
- CHECK(ret, FAIL, "HDopen");
+ CHECK(fd, FAIL, "HDopen");
/* Initialize information to write */
for(u=0; u<1024; u++)
@@ -2026,6 +2026,59 @@ test_cached_stab_info(void)
/****************************************************************
**
+** test_rw_noupdate(): low-level file test routine.
+** This test checks to ensure that opening and closing a file
+** with read/write permissions does not write anything to the
+** file if the file does not change.
+**
+** Programmer: Mike McGreevy
+** mamcgree@hdfgroup.org
+** June 29, 2009
+**
+*****************************************************************/
+static void
+test_rw_noupdate(void)
+{
+ hid_t file_id; /* HDF5 File ID */
+ h5_stat_t sb1, sb2; /* Info from 'stat' call */
+ double diff; /* Difference in modification times */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing to verify that nothing is written if nothing is changed.\n"));
+
+ /* Create and Close File */
+ file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fcreate");
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Determine File's Initial Timestamp */
+ ret = HDstat(FILE1, &sb1);
+ VERIFY(ret, 0, "HDfstat");
+
+ /* Wait for 2 seconds */
+ /* This ensures a system time difference between the two file accesses */
+ HDsleep(2);
+
+ /* Open and Close File With Read/Write Permission */
+ file_id = H5Fopen(FILE1, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(file_id, FAIL, "H5Fopen");
+ ret = H5Fclose(file_id);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Determine File's New Timestamp */
+ ret = HDstat(FILE1, &sb2);
+ VERIFY(ret, 0, "HDstat");
+
+ /* Ensure That Timestamps Are Equal */
+ diff = HDdifftime(sb2.st_mtime, sb1.st_mtime);
+ ret = (diff > 0.0);
+ VERIFY(ret, 0, "Timestamp");
+} /* end test_rw_noupdate() */
+
+/****************************************************************
+**
** test_file(): Main low-level file I/O test routine.
**
****************************************************************/
@@ -2057,6 +2110,7 @@ test_file(void)
#endif /*H5_CANNOT_OPEN_TWICE*/
test_userblock_file_size(); /* Tests that files created with a userblock have the correct size */
test_cached_stab_info(); /* Tests that files are created with cached stab info in the superblock */
+ test_rw_noupdate(); /* Test to ensure that RW permissions don't write the file unless dirtied */
} /* test_file() */