diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2006-07-14 19:06:24 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2006-07-14 19:06:24 (GMT) |
commit | d39ba334a630710554c1755c1cd266f2840cbc5a (patch) | |
tree | dab3930799b4ee9b68cc311a26cdc48c3f97edac /test/tmisc.c | |
parent | b69cf7ea840f2c34dd5b4368c8e52beb815b48f0 (diff) | |
download | hdf5-d39ba334a630710554c1755c1cd266f2840cbc5a.zip hdf5-d39ba334a630710554c1755c1cd266f2840cbc5a.tar.gz hdf5-d39ba334a630710554c1755c1cd266f2840cbc5a.tar.bz2 |
[svn-r12465] Add regression test to check that the library handles files with merged
object header messages properly.
Too minor to require h5committest
Diffstat (limited to 'test/tmisc.c')
-rw-r--r-- | test/tmisc.c | 141 |
1 files changed, 94 insertions, 47 deletions
diff --git a/test/tmisc.c b/test/tmisc.c index 7f39cf3..cc4d7b2 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -272,18 +272,20 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC24_DATATYPE_NAME "datatype" #define MISC24_DATATYPE_LINK "datatype_link" -/* Definitions for misc. test #25 */ -#define MISC25_FILE "foo.h5" -#define MISC25_GROUP0_NAME "grp0" -#define MISC25_GROUP1_NAME "/grp0/grp1" -#define MISC25_GROUP2_NAME "/grp0/grp2" -#define MISC25_GROUP3_NAME "/grp0/grp3" -#define MISC25_ATTR1_NAME "_long attribute_" -#define MISC25_ATTR1_LEN 11 -#define MISC25_ATTR2_NAME "_short attr__" -#define MISC25_ATTR2_LEN 11 -#define MISC25_ATTR3_NAME "_short attr__" -#define MISC25_ATTR3_LEN 1 +/* Definitions for misc. test #25 'a' & 'b' */ +#define MISC25A_FILE "foo.h5" +#define MISC25A_GROUP0_NAME "grp0" +#define MISC25A_GROUP1_NAME "/grp0/grp1" +#define MISC25A_GROUP2_NAME "/grp0/grp2" +#define MISC25A_GROUP3_NAME "/grp0/grp3" +#define MISC25A_ATTR1_NAME "_long attribute_" +#define MISC25A_ATTR1_LEN 11 +#define MISC25A_ATTR2_NAME "_short attr__" +#define MISC25A_ATTR2_LEN 11 +#define MISC25A_ATTR3_NAME "_short attr__" +#define MISC25A_ATTR3_LEN 1 +#define MISC25B_FILE "mergemsg.h5" +#define MISC25B_GROUP "grp1" /**************************************************************** ** @@ -4280,11 +4282,12 @@ test_misc24(void) /**************************************************************** ** -** test_misc25(): Exercise null object header message merge bug +** test_misc25a(): Exercise null object header message merge bug +** with new file ** ****************************************************************/ static void -test_misc25(void) +test_misc25a(void) { hid_t fid; /* File ID */ hid_t gid, gid2, gid3; /* Group IDs */ @@ -4297,11 +4300,11 @@ test_misc25(void) MESSAGE(5, ("Exercise null object header message bug\n")); /* Create file */ - fid = H5Fcreate(MISC25_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(MISC25A_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fcreate"); /* Create top group */ - gid = H5Gcreate(fid, MISC25_GROUP0_NAME, (size_t)0); + gid = H5Gcreate(fid, MISC25A_GROUP0_NAME, (size_t)0); CHECK(gid, FAIL, "H5Gcreate"); /* Close top group */ @@ -4309,7 +4312,7 @@ test_misc25(void) CHECK(ret, FAIL, "H5Gclose"); /* Create first group */ - gid = H5Gcreate(fid, MISC25_GROUP1_NAME, (size_t)0); + gid = H5Gcreate(fid, MISC25A_GROUP1_NAME, (size_t)0); CHECK(gid, FAIL, "H5Gcreate"); /* Close first group */ @@ -4317,7 +4320,7 @@ test_misc25(void) CHECK(ret, FAIL, "H5Gclose"); /* Create second group */ - gid2 = H5Gcreate(fid, MISC25_GROUP2_NAME, (size_t)0); + gid2 = H5Gcreate(fid, MISC25A_GROUP2_NAME, (size_t)0); CHECK(gid2, FAIL, "H5Gcreate"); /* Close second group */ @@ -4330,11 +4333,11 @@ test_misc25(void) /* Re-open file */ - fid = H5Fopen(MISC25_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Re-open first group */ - gid = H5Gopen(fid, MISC25_GROUP1_NAME); + gid = H5Gopen(fid, MISC25A_GROUP1_NAME); CHECK(gid, FAIL, "H5Gopen"); /* Create dataspace for attribute */ @@ -4344,11 +4347,11 @@ test_misc25(void) /* Create dataype for attribute */ tid = H5Tcopy(H5T_C_S1); CHECK(tid, FAIL, "H5Tcopy"); - ret = H5Tset_size(tid, MISC25_ATTR1_LEN); + ret = H5Tset_size(tid, MISC25A_ATTR1_LEN); CHECK(ret, FAIL, "H5Tset_size"); /* Add 1st attribute on first group */ - aid = H5Acreate(gid, MISC25_ATTR1_NAME, tid, sid, H5P_DEFAULT); + aid = H5Acreate(gid, MISC25A_ATTR1_NAME, tid, sid, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate"); /* Close dataspace */ @@ -4370,11 +4373,11 @@ test_misc25(void) /* Create dataype for attribute */ tid = H5Tcopy(H5T_C_S1); CHECK(tid, FAIL, "H5Tcopy"); - ret = H5Tset_size(tid, MISC25_ATTR2_LEN); + ret = H5Tset_size(tid, MISC25A_ATTR2_LEN); CHECK(ret, FAIL, "H5Tset_size"); /* Add 2nd attribute on first group */ - aid = H5Acreate(gid, MISC25_ATTR2_NAME, tid, sid, H5P_DEFAULT); + aid = H5Acreate(gid, MISC25A_ATTR2_NAME, tid, sid, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate"); /* Close dataspace */ @@ -4399,11 +4402,11 @@ test_misc25(void) /* Re-open file */ - fid = H5Fopen(MISC25_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Create third group */ - gid3 = H5Gcreate(fid, MISC25_GROUP3_NAME, (size_t)0); + gid3 = H5Gcreate(fid, MISC25A_GROUP3_NAME, (size_t)0); CHECK(gid3, FAIL, "H5Gcreate"); /* Close third group */ @@ -4411,11 +4414,11 @@ test_misc25(void) CHECK(ret, FAIL, "H5Gclose"); /* Re-open first group */ - gid = H5Gopen(fid, MISC25_GROUP1_NAME); + gid = H5Gopen(fid, MISC25A_GROUP1_NAME); CHECK(gid, FAIL, "H5Gopen"); /* Delete 2nd attribute */ - ret = H5Adelete(gid, MISC25_ATTR2_NAME); + ret = H5Adelete(gid, MISC25A_ATTR2_NAME); CHECK(ret, FAIL, "H5Adelete"); /* Close first group */ @@ -4429,11 +4432,11 @@ test_misc25(void) /* Re-open file */ - fid = H5Fopen(MISC25_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Re-open first group */ - gid = H5Gopen(fid, MISC25_GROUP1_NAME); + gid = H5Gopen(fid, MISC25A_GROUP1_NAME); CHECK(gid, FAIL, "H5Gopen"); /* Create dataspace for 3rd attribute */ @@ -4443,11 +4446,11 @@ test_misc25(void) /* Create dataype for attribute */ tid = H5Tcopy(H5T_C_S1); CHECK(tid, FAIL, "H5Tcopy"); - ret = H5Tset_size(tid, MISC25_ATTR3_LEN); + ret = H5Tset_size(tid, MISC25A_ATTR3_LEN); CHECK(ret, FAIL, "H5Tset_size"); /* Add 3rd attribute on first group (smaller than 2nd attribute) */ - aid = H5Acreate(gid, MISC25_ATTR3_NAME, tid, sid, H5P_DEFAULT); + aid = H5Acreate(gid, MISC25A_ATTR3_NAME, tid, sid, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate"); /* Close dataspace */ @@ -4473,15 +4476,15 @@ test_misc25(void) /* Re-open file */ - fid = H5Fopen(MISC25_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Re-open first group */ - gid = H5Gopen(fid, MISC25_GROUP1_NAME); + gid = H5Gopen(fid, MISC25A_GROUP1_NAME); CHECK(gid, FAIL, "H5Gopen"); /* Delete 3rd attribute */ - ret = H5Adelete(gid, MISC25_ATTR3_NAME); + ret = H5Adelete(gid, MISC25A_ATTR3_NAME); CHECK(ret, FAIL, "H5Adelete"); /* Create dataspace for 3rd attribute */ @@ -4491,11 +4494,11 @@ test_misc25(void) /* Create dataype for attribute */ tid = H5Tcopy(H5T_C_S1); CHECK(tid, FAIL, "H5Tcopy"); - ret = H5Tset_size(tid, MISC25_ATTR2_LEN); + ret = H5Tset_size(tid, MISC25A_ATTR2_LEN); CHECK(ret, FAIL, "H5Tset_size"); /* Re-create 2nd attribute on first group */ - aid = H5Acreate(gid, MISC25_ATTR2_NAME, tid, sid, H5P_DEFAULT); + aid = H5Acreate(gid, MISC25A_ATTR2_NAME, tid, sid, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate"); /* Close dataspace */ @@ -4520,15 +4523,15 @@ test_misc25(void) /* Re-open file */ - fid = H5Fopen(MISC25_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Re-open first group */ - gid = H5Gopen(fid, MISC25_GROUP1_NAME); + gid = H5Gopen(fid, MISC25A_GROUP1_NAME); CHECK(gid, FAIL, "H5Gopen"); /* Delete 2nd attribute */ - ret = H5Adelete(gid, MISC25_ATTR2_NAME); + ret = H5Adelete(gid, MISC25A_ATTR2_NAME); CHECK(ret, FAIL, "H5Adelete"); /* Close first group */ @@ -4541,11 +4544,11 @@ test_misc25(void) /* Re-open file */ - fid = H5Fopen(MISC25_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); /* Re-open first group */ - gid = H5Gopen(fid, MISC25_GROUP1_NAME); + gid = H5Gopen(fid, MISC25A_GROUP1_NAME); CHECK(gid, FAIL, "H5Gopen"); /* Create dataspace for 3rd attribute */ @@ -4555,11 +4558,11 @@ test_misc25(void) /* Create dataype for attribute */ tid = H5Tcopy(H5T_C_S1); CHECK(tid, FAIL, "H5Tcopy"); - ret = H5Tset_size(tid, MISC25_ATTR2_LEN); + ret = H5Tset_size(tid, MISC25A_ATTR2_LEN); CHECK(ret, FAIL, "H5Tset_size"); /* Re-create 2nd attribute on first group */ - aid = H5Acreate(gid, MISC25_ATTR2_NAME, tid, sid, H5P_DEFAULT); + aid = H5Acreate(gid, MISC25A_ATTR2_NAME, tid, sid, H5P_DEFAULT); CHECK(aid, FAIL, "H5Acreate"); /* Close dataspace */ @@ -4581,7 +4584,50 @@ test_misc25(void) /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); -} /* end test_misc25() */ +} /* end test_misc25a() */ + +/**************************************************************** +** +** test_misc25b(): Exercise null object header message merge bug +** with existing file (This test relies on +** the file produced by test/gen_mergemsg.c) +** +****************************************************************/ +static void +test_misc25b(void) +{ + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + char testfile[512]=""; + char *srcdir = HDgetenv("srcdir"); + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Exercise null object header message bug\n")); + + /* Build the name of the file, with the source directory */ + if (srcdir && ((HDstrlen(srcdir) + HDstrlen(MISC25B_FILE) + 1) < sizeof(testfile))){ + HDstrcpy(testfile, srcdir); + HDstrcat(testfile, "/"); + } + HDstrcat(testfile, MISC25B_FILE); + + /* Open file */ + fid = H5Fopen(testfile, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + /* Re-open group with object header messages that will merge */ + gid = H5Gopen(fid, MISC25B_GROUP); + CHECK(gid, FAIL, "H5Gopen"); + + /* Close first group */ + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_misc25a() */ /**************************************************************** ** @@ -4622,7 +4668,8 @@ test_misc(void) test_misc23(); /* Test intermediate group creation */ #endif /* H5_GROUP_REVISION */ test_misc24(); /* Test inappropriate API opens of objects */ - test_misc25(); /* Exercise null object header message merge bug */ + test_misc25a(); /* Exercise null object header message merge bug */ + test_misc25b(); /* Exercise null object header message merge bug on existing file */ } /* test_misc() */ @@ -4673,6 +4720,6 @@ cleanup_misc(void) #endif /* H5_HAVE_FILTER_SZIP */ HDremove(MISC23_FILE); HDremove(MISC24_FILE); - HDremove(MISC25_FILE); + HDremove(MISC25A_FILE); } |