diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-08-18 18:25:49 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-08-18 18:25:49 (GMT) |
commit | ebde7af78ab5cfacc8a55105f1de0e53ccffa5a4 (patch) | |
tree | bded46cf03fd13d3311cd959dcb9b091e7379dca /test | |
parent | 339471fe0d38ce9527c6c6a91f9a9cfb3810bb9c (diff) | |
download | hdf5-ebde7af78ab5cfacc8a55105f1de0e53ccffa5a4.zip hdf5-ebde7af78ab5cfacc8a55105f1de0e53ccffa5a4.tar.gz hdf5-ebde7af78ab5cfacc8a55105f1de0e53ccffa5a4.tar.bz2 |
[svn-r17374] Description:
Bring r17365 from trunk to 1.8 branch:
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
(h5committest performed on trunk)
Diffstat (limited to 'test')
-rw-r--r-- | test/tfile.c | 56 |
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() */ |