summaryrefslogtreecommitdiffstats
path: root/test/tfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/tfile.c')
-rw-r--r--test/tfile.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/test/tfile.c b/test/tfile.c
index 25c1590..518138c 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_swmr_write(): low-level file test routine.
** This test checks that the H5F_ACC_SWMR_WRITE access flag is
** working properly.
@@ -2253,6 +2306,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_swmr_write(); /* Tests for SWMR write access flag */
test_swmr_read(); /* Tests for SWMR read access flag */
} /* test_file() */