summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2009-09-24 19:24:48 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2009-09-24 19:24:48 (GMT)
commit73f24a8ed0cff263cc6f646aa918d035e64e3a46 (patch)
tree699a44d5c8f6fadc5dbafd3db20c331639afeebb /test
parente46380bfb6db1ca1aa230809a7605d84eb2e9f8e (diff)
downloadhdf5-73f24a8ed0cff263cc6f646aa918d035e64e3a46.zip
hdf5-73f24a8ed0cff263cc6f646aa918d035e64e3a46.tar.gz
hdf5-73f24a8ed0cff263cc6f646aa918d035e64e3a46.tar.bz2
[svn-r17517] In the function test_rw_noupdate, I added a test with the system functions to make
sure the stat function behaves as we expected. This test is skipped on some system because the modification time from stat is the same as the last access time (We know OpenVMS behaves in this way). Tested on jam. I've tested the same change for the trunk on jam, smirom, and linew. My account for OpenVMS expired. I'll test it once I have it back.
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am8
-rw-r--r--test/Makefile.in10
-rw-r--r--test/tfile.c56
3 files changed, 54 insertions, 20 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index f0aa131..84d1510 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -105,10 +105,10 @@ flush2.chkexe_: flush1.chkexe_
CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offset.h5 \
max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \
- extend.h5 istore.h5 extlinks*.h5 links*.h5 \
- tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 \
- extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] \
- links.h5 links[0-6]*.h5 extlinks[0-9].h5 tmp \
+ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
+ sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \
+ stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
+ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
big.data big[0-9][0-9][0-9][0-9][0-9].h5 \
stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \
tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \
diff --git a/test/Makefile.in b/test/Makefile.in
index 15bc4e0..fb769f3 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -637,11 +637,11 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \
compact_dataset.h5 dataset.h5 dset_offset.h5 \
max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \
huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_expand.h5 \
- extend.h5 istore.h5 extlinks*.h5 links*.h5 tfile[1-4].h5 \
- th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 extern_[1-3].h5 \
- extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] links.h5 \
- links[0-6]*.h5 extlinks[0-9].h5 tmp big.data \
- big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \
+ extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \
+ sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \
+ stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \
+ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \
+ big.data big[0-9][0-9][0-9][0-9][0-9].h5 stdio.h5 sec2.h5 \
dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \
unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \
mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \
diff --git a/test/tfile.c b/test/tfile.c
index 0d07d1b..b8902e3 100644
--- a/test/tfile.c
+++ b/test/tfile.c
@@ -49,6 +49,7 @@
#define F1_SYM_LEAF_K 4
#define F1_SYM_INTERN_K 16
#define FILE1 "tfile1.h5"
+#define SFILE1 "sys_file1"
#define F2_USERBLOCK_SIZE (hsize_t)512
#define F2_OFFSET_SIZE 8
@@ -2074,20 +2075,15 @@ test_cached_stab_info(void)
** June 29, 2009
**
** Modification: Raymond Lu
-** Skip this function for OpenVMS.
+** I added a test with the system functions to make
+** sure the stat function behaves as we expected.
** 17 September 2009
*****************************************************************/
-#ifdef H5_VMS
-static void
-test_rw_noupdate(void)
-{
- /* Output message about test being performed */
- MESSAGE(1, ("Testing to verify that nothing is written if nothing is changed. This test is skipped on OpenVMS because the modification time from stat is the same as the last access time.\n"));
-} /* end test_rw_noupdate() */
-#else
static void
test_rw_noupdate(void)
{
+ int fid; /* File ID from system-created file */
+ struct stat sys_sb1, sys_sb2; /* Info from the system stat */
hid_t file_id; /* HDF5 File ID */
h5_stat_t sb1, sb2; /* Info from 'stat' call */
double diff; /* Difference in modification times */
@@ -2096,7 +2092,42 @@ test_rw_noupdate(void)
/* Output message about test being performed */
MESSAGE(5, ("Testing to verify that nothing is written if nothing is changed.\n"));
- /* Create and Close File */
+ /* First make sure the stat function behaves as we expect - the modification time
+ * is the time that the file was modified last time. */
+ fid = open(SFILE1, O_RDWR | O_CREAT | O_TRUNC, 0666);
+ CHECK(fid, FAIL, "open");
+ ret = close(fid);
+ CHECK(ret, FAIL, "close");
+
+ /* Determine File's Initial Timestamp */
+ ret = stat(SFILE1, &sys_sb1);
+ VERIFY(ret, 0, "stat");
+
+ /* Wait for 2 seconds */
+ /* This ensures a system time difference between the two file accesses */
+ sleep(2);
+
+ fid = open(SFILE1, O_RDWR);
+ CHECK(fid, FAIL, "open");
+ ret = close(fid);
+ CHECK(ret, FAIL, "close");
+
+ /* Determine File's New Timestamp */
+ ret = stat(SFILE1, &sys_sb2);
+ VERIFY(ret, 0, "stat");
+
+ /* Ensure That Timestamps Are Equal */
+ diff = difftime(sys_sb2.st_mtime, sys_sb1.st_mtime);
+
+ if(!DBL_ABS_EQUAL(diff, 0.0)) {
+ /* Output message about test being performed */
+ MESSAGE(1, ("Testing to verify that nothing is written if nothing is changed: This test is skipped on this system because the modification time from stat is the same as the last access time (We know OpenVMS behaves in this way).\n"));
+
+ goto done;
+ }
+
+ /* Then we can test with a HDF5 file */
+ /* Create and Close a HDF5 File */
file_id = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(file_id, FAIL, "H5Fcreate");
ret = H5Fclose(file_id);
@@ -2124,8 +2155,10 @@ test_rw_noupdate(void)
diff = HDdifftime(sb2.st_mtime, sb1.st_mtime);
ret = (diff > 0.0);
VERIFY(ret, 0, "Timestamp");
+
+done:
+ ; /* do nothing */
} /* end test_rw_noupdate() */
-#endif
/****************************************************************
**
@@ -2532,6 +2565,7 @@ test_file(void)
void
cleanup_file(void)
{
+ HDremove(SFILE1);
HDremove(FILE1);
HDremove(FILE2);
HDremove(FILE3);