diff options
Diffstat (limited to 'test/tmisc.c')
-rw-r--r-- | test/tmisc.c | 63 |
1 files changed, 63 insertions, 0 deletions
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() */ |