summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2008-01-13 05:38:40 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2008-01-13 05:38:40 (GMT)
commit52e401106794acc8ca9f654e8c9d22159f4e9bab (patch)
treec186de5724d9b25c9f95b0de440d3806862baf00 /test
parentfc59a903d181253c43444ae1d1dd5de4692f8dc0 (diff)
downloadhdf5-52e401106794acc8ca9f654e8c9d22159f4e9bab.zip
hdf5-52e401106794acc8ca9f654e8c9d22159f4e9bab.tar.gz
hdf5-52e401106794acc8ca9f654e8c9d22159f4e9bab.tar.bz2
[svn-r14403] Description:
Add work-around to allow reading files that were produced with a buggy earlier version of the library, which could create objects with the wrong object header message count. There is now a configure flag "--enable-strict-format-checks" which triggers a failure on reading a file with this sort of corruption (when enabled) and allows the object to be read (when disabled). The default value for the "strict-format-checks" flag is yes when the "debug" flag is enabled and no when the "debug" flag is disabled. Note that if strict format checks are disabled (allowing objects with this particular kind of corruption to be read) and the file is opened with write access, the library will re-write the object header for the corrupt object with the correct # of object header messages. This closes bugzilla bug #1010. Tested on: Linux/32 2.6 (kagiso) FreeBSD/64 6.2 (liberty)
Diffstat (limited to 'test')
-rw-r--r--test/tbad_msg_count.h5bin0 -> 1984 bytes
-rw-r--r--test/tmisc.c63
2 files changed, 63 insertions, 0 deletions
diff --git a/test/tbad_msg_count.h5 b/test/tbad_msg_count.h5
new file mode 100644
index 0000000..ca5eb65
--- /dev/null
+++ b/test/tbad_msg_count.h5
Binary files differ
diff --git a/test/tmisc.c b/test/tmisc.c
index 88c9ea2..3e38b8f 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -279,6 +279,13 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset
#define MISC25B_FILE "mergemsg.h5"
#define MISC25B_GROUP "grp1"
+/* Definitions for misc. test #27 */
+/* (Note that this test file is generated by the "gen_bad_ohdr.c" code in
+ * the 1.8 branch/trunk)
+ */
+#define MISC27_FILE "tbad_msg_count.h5"
+#define MISC27_GROUP "Group"
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -4186,6 +4193,60 @@ test_misc25b(void)
CHECK(ret, FAIL, "H5Fclose");
} /* end test_misc25a() */
+
+/****************************************************************
+**
+** test_misc27(): Ensure that objects with incorrect # of object
+** header messages are handled appropriately.
+**
+** (Note that this test file is generated by the "gen_bad_ohdr.c" code,
+** in the 1.8 branch/trunk)
+**
+****************************************************************/
+static void
+test_misc27(void)
+{
+ hid_t fid; /* File ID */
+ hid_t gid; /* Group ID */
+ char testfile[512]=""; /* Character buffer for corrected test file name */
+ char *srcdir = HDgetenv("srcdir"); /* Pointer to the directory the source code is located within */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Corrupt object header handling\n"));
+
+ /* Generate the correct name for the test file, by prepending the source path */
+ if(srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC27_FILE) + 1) < sizeof(testfile))) {
+ HDstrcpy(testfile, srcdir);
+ HDstrcat(testfile, "/");
+ }
+ HDstrcat(testfile, MISC27_FILE);
+
+ /* Open the file */
+ fid = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT);
+ CHECK(fid, FAIL, "H5Fopen");
+
+#ifdef H5_STRICT_FORMAT_CHECKS
+ /* Open group with incorrect # of object header messages (should fail) */
+ H5E_BEGIN_TRY {
+ gid = H5Gopen(fid, MISC27_GROUP);
+ } H5E_END_TRY;
+ VERIFY(gid, FAIL, "H5Gopen");
+#else /* H5_STRICT_FORMAT_CHECKS */
+ /* Open group with incorrect # of object header messages */
+ gid = H5Gopen(fid, MISC27_GROUP);
+ CHECK(gid, FAIL, "H5Gopen");
+
+ /* Close group */
+ ret = H5Gclose(gid);
+ CHECK(ret, FAIL, "H5Gclose");
+#endif /* H5_STRICT_FORMAT_CHECKS */
+
+ /* Close file */
+ ret = H5Fclose(fid);
+ CHECK(ret, FAIL, "H5Fclose");
+} /* end test_misc27() */
+
/****************************************************************
**
** test_misc(): Main misc. test routine.
@@ -4225,6 +4286,8 @@ test_misc(void)
test_misc24(); /* Test inappropriate API opens of objects */
test_misc25a(); /* Exercise null object header message merge bug */
test_misc25b(); /* Exercise null object header message merge bug on existing file */
+ /* misc. test #26 only in 1.8 branch/trunk */
+ test_misc27(); /* Test opening file with object that has bad # of object header messages */
} /* test_misc() */