summaryrefslogtreecommitdiffstats
path: root/test/tmisc.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-10-13 15:28:42 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-10-13 15:28:42 (GMT)
commit2a2a49f42280220ad7cf2c45b1e5103d3b72146a (patch)
tree1b442dd4961dbf643d4e9a21abb01da10e49122c /test/tmisc.c
parenteb8838be0ba2b49931f3f5eadcea308dfe911d85 (diff)
downloadhdf5-2a2a49f42280220ad7cf2c45b1e5103d3b72146a.zip
hdf5-2a2a49f42280220ad7cf2c45b1e5103d3b72146a.tar.gz
hdf5-2a2a49f42280220ad7cf2c45b1e5103d3b72146a.tar.bz2
[svn-r17638] Description:
Bring r17624 from trunk to 1.8 branch: Don't allow reads to change or add to the metadata accumulator, since they might be speculative and could bring raw data into the metadata accumulator. 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 (jam) w/PGI compilers, w/default API=1.8.x, 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 debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.6.1 (amazon) in debug mode Mac OS X/32 10.6.1 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test/tmisc.c')
-rw-r--r--test/tmisc.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/test/tmisc.c b/test/tmisc.c
index b646a69..005e77a 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -32,6 +32,9 @@
#include "testhdf5.h"
#include "H5Dpkg.h" /* Datasets */
+#define NAME_BUF_SIZE 1024
+#define READ_OLD_BUFSIZE 1024
+
/* Definitions for misc. test #1 */
#define MISC1_FILE "tmisc1.h5"
#define MISC1_VAL (13417386) /* 0xccbbaa */
@@ -305,6 +308,11 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#define MISC28_SIZE 10
#define MISC28_NSLOTS 10000
+/* Definitions for misc. test #29 */
+#define MISC29_ORIG_FILE "specmetaread.h5"
+#define MISC29_COPY_FILE "tmisc29.h5"
+#define MISC29_DSETNAME "dset2"
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -5118,6 +5126,63 @@ test_misc28(void)
CHECK_I(ret, "H5Pclose");
} /* end test_misc28() */
+
+/****************************************************************
+**
+** test_misc29(): Ensure that speculative metadata reads don't
+** get raw data into the metadata accumulator.
+**
+****************************************************************/
+static void
+test_misc29(void)
+{
+ int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */
+ char buf[READ_OLD_BUFSIZE]; /* Buffer for copying data */
+ ssize_t nread; /* Number of bytes read in */
+ char *srcdir = HDgetenv("srcdir"); /* where the src code is located */
+ char filename[NAME_BUF_SIZE] = ""; /* old test file name */
+ hid_t fid; /* File ID */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Speculative metadata reads\n"));
+
+ /* Generate correct name for test file by prepending the source path */
+ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC29_ORIG_FILE) + 1) < sizeof(filename))) {
+ HDstrcpy(filename, srcdir);
+ HDstrcat(filename, "/");
+ } /* end if */
+ HDstrcat(filename, MISC29_ORIG_FILE);
+
+ /* Copy old file into temporary file */
+ fd_old = HDopen(filename, O_RDONLY, 0666);
+ CHECK(fd_old, -1, "HDopen");
+ fd_new = HDopen(MISC29_COPY_FILE, O_RDWR|O_CREAT|O_TRUNC, 0666);
+ CHECK(fd_new, -1, "HDopen");
+
+ /* Copy data */
+ while((nread = HDread(fd_old, buf, (size_t)READ_OLD_BUFSIZE)) > 0)
+ HDwrite(fd_new, buf, (size_t)nread);
+
+ /* Close files */
+ ret = HDclose(fd_old);
+ CHECK(ret, -1, "HDclose");
+ ret = HDclose(fd_new);
+ CHECK(ret, -1, "HDclose");
+
+ /* Open the copied file */
+ fid = H5Fopen(MISC29_COPY_FILE, H5F_ACC_RDWR, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+ /* Delete the last dataset */
+ ret = H5Ldelete(fid, MISC29_DSETNAME, H5P_DEFAULT);
+ CHECK(ret, FAIL, "H5Ldelete");
+
+ /* Close the file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* end test_misc29() */
+
/****************************************************************
**
** test_misc(): Main misc. test routine.
@@ -5161,6 +5226,7 @@ test_misc(void)
test_misc26(); /* Test closing property lists with long filter pipelines */
test_misc27(); /* Test opening file with object that has bad # of object header messages */
test_misc28(); /* Test that chunks are cached appropriately */
+ test_misc29(); /* Test that speculative metadata reads are handled correctly */
} /* test_misc() */
@@ -5216,5 +5282,6 @@ cleanup_misc(void)
HDremove(MISC25C_FILE);
HDremove(MISC26_FILE);
HDremove(MISC28_FILE);
+ HDremove(MISC29_COPY_FILE);
}