summaryrefslogtreecommitdiffstats
path: root/test/tmisc.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-10-09 04:09:34 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-10-09 04:09:34 (GMT)
commitdcbf871fed9a07211458188fb52174c72d93f759 (patch)
treede1400b1b610853017fc0548c1a95a5ad2c0a836 /test/tmisc.c
parent13e5632d32650ff53190bdc37777277d0ae2913d (diff)
downloadhdf5-dcbf871fed9a07211458188fb52174c72d93f759.zip
hdf5-dcbf871fed9a07211458188fb52174c72d93f759.tar.gz
hdf5-dcbf871fed9a07211458188fb52174c72d93f759.tar.bz2
[svn-r17624] Description:
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 41128a2..21715b4 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
@@ -5106,6 +5114,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.
@@ -5149,6 +5214,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() */
@@ -5203,5 +5269,6 @@ cleanup_misc(void)
HDremove(MISC25C_FILE);
HDremove(MISC26_FILE);
HDremove(MISC28_FILE);
+ HDremove(MISC29_COPY_FILE);
}