diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-05-01 21:00:52 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-05-01 21:00:52 (GMT) |
commit | 2757f75317a07422c9a1d0378f969c3eb802c3a0 (patch) | |
tree | 6374d38220529efef51cbeead15f906e1782ebbd /test | |
parent | 4e243fd5e741fbdeaf92a484d52dbae4b0008268 (diff) | |
download | hdf5-2757f75317a07422c9a1d0378f969c3eb802c3a0.zip hdf5-2757f75317a07422c9a1d0378f969c3eb802c3a0.tar.gz hdf5-2757f75317a07422c9a1d0378f969c3eb802c3a0.tar.bz2 |
[svn-r13721] Description:
Add "fail if unknown" and "mark if unknown" flags to object header messages.
This gives the library a clean way to tell older libraries that a message should
not be just ignored if it's unknown, but that other actions should occur.
Tested on:
Mac OS X/32 10.4.9 (amazon)
FreeBSD/32 6.2 (duty)
FreeBSD/64 6.2 (liberty)
Linux/32 2.6 (chicago)
Linux/64 2.6 (chicago2)
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/Makefile.in | 16 | ||||
-rw-r--r-- | test/gen_bogus.c | 100 | ||||
-rw-r--r-- | test/ohdr.c | 327 | ||||
-rw-r--r-- | test/tbogus.h5 | bin | 2052 -> 1944 bytes |
5 files changed, 295 insertions, 150 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index d32d856..2def39a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -59,7 +59,7 @@ check_PROGRAMS=$(TEST_PROG) error_test err_compat testmeta # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS=gen_deflate gen_filters gen_new_array gen_new_fill \ +BUILD_ALL_PROGS=gen_bogus gen_deflate gen_filters gen_new_array gen_new_fill \ gen_new_group gen_new_mtime gen_new_super gen_noencoder \ gen_nullspace space_overflow gen_cross gen_udlinks diff --git a/test/Makefile.in b/test/Makefile.in index 47eb02c..806bea7 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -81,7 +81,7 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ getname$(EXEEXT) vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ dtransform$(EXEEXT) reserved$(EXEEXT) cross_read$(EXEEXT) \ btree2$(EXEEXT) fheap$(EXEEXT) -am__EXEEXT_2 = gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ +am__EXEEXT_2 = gen_bogus$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ gen_new_group$(EXEEXT) gen_new_mtime$(EXEEXT) \ gen_new_super$(EXEEXT) gen_noencoder$(EXEEXT) \ @@ -172,6 +172,10 @@ flush2_SOURCES = flush2.c flush2_OBJECTS = flush2.$(OBJEXT) flush2_LDADD = $(LDADD) flush2_DEPENDENCIES = libh5test.la $(LIBHDF5) +gen_bogus_SOURCES = gen_bogus.c +gen_bogus_OBJECTS = gen_bogus.$(OBJEXT) +gen_bogus_LDADD = $(LDADD) +gen_bogus_DEPENDENCIES = libh5test.la $(LIBHDF5) gen_cross_SOURCES = gen_cross.c gen_cross_OBJECTS = gen_cross.$(OBJEXT) gen_cross_LDADD = $(LDADD) @@ -330,7 +334,7 @@ SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c cache.c \ cache_api.c cmpd_dset.c cross_read.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ error_test.c extend.c external.c fheap.c fillval.c flush1.c \ - flush2.c gen_cross.c gen_deflate.c gen_filters.c \ + flush2.c gen_bogus.c gen_cross.c gen_deflate.c gen_filters.c \ gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ gen_new_super.c gen_noencoder.c gen_nullspace.c gen_udlinks.c \ getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ @@ -342,7 +346,7 @@ DIST_SOURCES = $(libh5test_la_SOURCES) big.c bittests.c btree2.c \ cache.c cache_api.c cmpd_dset.c cross_read.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c enum.c err_compat.c \ error_test.c extend.c external.c fheap.c fillval.c flush1.c \ - flush2.c gen_cross.c gen_deflate.c gen_filters.c \ + flush2.c gen_bogus.c gen_cross.c gen_deflate.c gen_filters.c \ gen_new_array.c gen_new_fill.c gen_new_group.c gen_new_mtime.c \ gen_new_super.c gen_noencoder.c gen_nullspace.c gen_udlinks.c \ getname.c gheap.c hyperslab.c istore.c lheap.c links.c mount.c \ @@ -627,7 +631,7 @@ TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api \ # --enable-build-all at configure time. # The gen_old_* files can only be compiled with older versions of the library # so do not appear in this list. -BUILD_ALL_PROGS = gen_deflate gen_filters gen_new_array gen_new_fill \ +BUILD_ALL_PROGS = gen_bogus gen_deflate gen_filters gen_new_array gen_new_fill \ gen_new_group gen_new_mtime gen_new_super gen_noencoder \ gen_nullspace space_overflow gen_cross gen_udlinks @@ -789,6 +793,9 @@ flush1$(EXEEXT): $(flush1_OBJECTS) $(flush1_DEPENDENCIES) flush2$(EXEEXT): $(flush2_OBJECTS) $(flush2_DEPENDENCIES) @rm -f flush2$(EXEEXT) $(LINK) $(flush2_OBJECTS) $(flush2_LDADD) $(LIBS) +gen_bogus$(EXEEXT): $(gen_bogus_OBJECTS) $(gen_bogus_DEPENDENCIES) + @rm -f gen_bogus$(EXEEXT) + $(LINK) $(gen_bogus_OBJECTS) $(gen_bogus_LDADD) $(LIBS) gen_cross$(EXEEXT): $(gen_cross_OBJECTS) $(gen_cross_DEPENDENCIES) @rm -f gen_cross$(EXEEXT) $(LINK) $(gen_cross_OBJECTS) $(gen_cross_LDADD) $(LIBS) @@ -917,6 +924,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flush2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_bogus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_cross.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_deflate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gen_filters.Po@am__quote@ diff --git a/test/gen_bogus.c b/test/gen_bogus.c new file mode 100644 index 0000000..6078e71 --- /dev/null +++ b/test/gen_bogus.c @@ -0,0 +1,100 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Quincey Koziol <koziol@hdfgroup.org> + * Apr 17, 2007 + * + * Purpose: This program is run to generate an HDF5 data file with several + * datasets that have "bogus" messages in their object header. + */ + +#include "hdf5.h" +#include "H5Oprivate.h" + +#define FILENAME "tbogus.h5" + +#ifndef TRUE +#define TRUE 1 +#endif /* TRUE */ +#ifndef FALSE +#define FALSE 0 +#endif /* FALSE */ + +int main(void) +{ +#ifdef H5O_ENABLE_BOGUS + hid_t fid = -1; /* File ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t did = -1; /* Dataset ID */ + uint8_t bogus_flags = 0; /* Flags for bogus message */ + + /* Create file for test datasets */ + if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + + /* Create dataspace for datasets */ + if((sid = H5Screate(H5S_SCALAR)) < 0) goto error; + + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + + /* Add property for bogus message flags */ + if(H5Pinsert(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, H5O_BOGUS_MSG_FLAGS_SIZE, &bogus_flags, NULL, NULL, NULL, NULL, NULL, NULL) < 0) goto error; + + /* Create dataset with "bogus" message, but no message flags */ + if((did = H5Dcreate(fid, "/Dataset1", H5T_NATIVE_INT, sid, dcpl)) < 0) goto error; + if(H5Dclose(did) < 0) goto error; + + /* Set "fail if unknown" message flag for bogus message */ + bogus_flags = H5O_MSG_FLAG_FAIL_IF_UNKNOWN; + if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error; + + /* Create second dataset, with "fail if unknown" message flag */ + if((did = H5Dcreate(fid, "/Dataset2", H5T_NATIVE_INT, sid, dcpl)) < 0) goto error; + if(H5Dclose(did) < 0) goto error; + + /* Set "mark if unknown" message flag for bogus message */ + bogus_flags = H5O_MSG_FLAG_MARK_IF_UNKNOWN; + if(H5Pset(dcpl, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) goto error; + + /* Create second dataset, with "mark if unknown" message flag */ + if((did = H5Dcreate(fid, "/Dataset3", H5T_NATIVE_INT, sid, dcpl)) < 0) goto error; + if(H5Dclose(did) < 0) goto error; + + /* Close dataset creation property list */ + if(H5Pclose(dcpl) < 0) goto error; + + /* Close dataspace */ + if(H5Sclose(sid) < 0) goto error; + + /* Close file */ + if(H5Fclose(fid) < 0) goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Dclose(did); + H5Sclose(sid); + H5Pclose(dcpl); + H5Fclose(fid); + } H5E_END_TRY; +#else /* H5O_ENABLE_BOGUS */ + HDputs("H5O_ENABLE_BOGUS compiler macro not defined!"); +#endif /* H5O_ENABLE_BOGUS */ + return 1; +} + diff --git a/test/ohdr.c b/test/ohdr.c index 43cc78e..73ede43 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -20,8 +20,10 @@ #include "H5Iprivate.h" /* * This file needs to access private datatypes from the H5O package. + * This file also needs to access the object header testing code. */ #define H5O_PACKAGE +#define H5O_TESTING #include "H5Opkg.h" /* @@ -37,7 +39,8 @@ const char *FILENAME[] = { /* The tbogus.h5 is generated from gen_bogus.c in HDF5 'test' directory. * To get this data file, define H5O_ENABLE_BOGUS in src/H5Oprivate, rebuild - * the library and simply compile gen_bogus.c with that HDF5 library and run it. */ + * the library and simply compile gen_bogus.c with that HDF5 library and run it. + */ #define FILE_BOGUS "tbogus.h5" @@ -73,12 +76,9 @@ main(void) h5_reset(); fapl = h5_fileaccess(); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) - goto error; - if (NULL==(f=H5I_object(file))) { - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if(NULL == (f = H5I_object(file))) FAIL_STACK_ERROR + /* * Test object header creation @@ -86,65 +86,38 @@ main(void) */ TESTING("object header creation"); HDmemset(&oh_loc, 0, sizeof(oh_loc)); - if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } + if(H5O_create(f, H5P_DATASET_XFER_DEFAULT, (size_t)64, H5P_GROUP_CREATE_DEFAULT, &oh_loc/*out*/) < 0) + FAIL_STACK_ERROR PASSED(); + /* create a new message */ TESTING("message creation"); time_new = 11111111; - if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (ro!=time_new) { - H5_FAILED(); - HDfprintf(stdout, " got: {%ld}\n", (long)ro); - HDfprintf(stdout, " ans: {%ld}\n", (long)time_new); - goto error; - } + if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0) + FAIL_STACK_ERROR + if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) + FAIL_STACK_ERROR + if(ro != time_new) + TEST_ERROR PASSED(); + /* * Test modification of an existing message. */ TESTING("message modification"); time_new = 33333333; - if (H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (ro!=time_new) { - H5_FAILED(); - HDfprintf(stdout, " got: {%ld}\n", (long)ro); - HDfprintf(stdout, " ans: {%ld}\n", (long)time_new); - goto error; - } + if(H5O_msg_write(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0) + FAIL_STACK_ERROR + if(NULL == H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) + FAIL_STACK_ERROR + if(ro != time_new) + TEST_ERROR PASSED(); @@ -157,123 +130,187 @@ main(void) * message from an object header currently - QAK - 10/8/03) */ TESTING("object header overflow in memory"); - for (i=0; i<40; i++) { - time_new = (i+1)*1000+1; - if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - } - if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } + for(i = 0; i < 40; i++) { + time_new = (i + 1) * 1000 + 1; + if(H5O_msg_create(&oh_loc, H5O_MTIME_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + } /* end for */ + if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0) + FAIL_STACK_ERROR PASSED(); + /* * Test creation of a bunch of messages one after another to see * what happens when the object header overflows on disk. */ TESTING("object header overflow on disk"); - for (i=0; i<10; i++) { + for(i = 0; i < 10; i++) { time_new = (i + 1) * 1000 + 10; - if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - } + if(H5O_msg_create(&oh_loc, H5O_MTIME_NEW_ID, 0, 0, &time_new, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + if(H5AC_flush(f, H5P_DATASET_XFER_DEFAULT, TRUE) < 0) + FAIL_STACK_ERROR + } /* end for */ PASSED(); + /* * Delete all time messages. */ TESTING("message deletion"); - if (H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (H5O_msg_remove(&oh_loc, H5O_MTIME_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if(H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { - H5_FAILED(); - puts(" H5O_msg_read() should have failed but didn't"); - H5Eclear2(H5E_DEFAULT); - goto error; - } - if(H5O_msg_read(&oh_loc, H5O_MTIME_ID, &ro, H5P_DATASET_XFER_DEFAULT)) { - H5_FAILED(); - puts(" H5O_msg_read() should have failed but didn't"); - H5Eclear2(H5E_DEFAULT); - goto error; - } + if(H5O_msg_remove(&oh_loc, H5O_MTIME_NEW_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + if(H5O_msg_remove(&oh_loc, H5O_MTIME_ID, H5O_ALL, TRUE, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + if(H5O_msg_read(&oh_loc, H5O_MTIME_NEW_ID, &ro, H5P_DATASET_XFER_DEFAULT)) + FAIL_STACK_ERROR + if(H5O_msg_read(&oh_loc, H5O_MTIME_ID, &ro, H5P_DATASET_XFER_DEFAULT)) + FAIL_STACK_ERROR PASSED(); /* release resources */ TESTING("object header closing"); - if (H5O_close(&oh_loc)<0) { - H5_FAILED(); - H5Eprint2(H5E_DEFAULT, stdout); - goto error; - } - if (H5Fclose(file)<0) goto error; + if(H5O_close(&oh_loc) < 0) + FAIL_STACK_ERROR PASSED(); - /* Test reading dataset with undefined object header message */ - TESTING("reading object with unknown header message"); + + /* Test reading datasets with undefined object header messages */ + puts("Reading objects with unknown header messages"); envval = HDgetenv("HDF5_DRIVER"); - if (envval == NULL) + if(envval == NULL) envval = "nomatch"; - if (HDstrcmp(envval, "core") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "split") && HDstrcmp(envval, "family")) { - { - char testfile[512]=""; - char *srcdir = getenv("srcdir"); - - /* Build path to test file */ - if (srcdir && ((HDstrlen(srcdir) + HDstrlen(FILE_BOGUS) + 1) < sizeof(testfile))){ - HDstrcpy(testfile, srcdir); - HDstrcat(testfile, "/"); - } - HDstrcat(testfile, FILE_BOGUS); - - if ((file=H5Fopen(testfile, H5F_ACC_RDONLY, fapl))<0) - goto error; - - /* Open the dataset with the unknown header message (generated with gen_bogus.c) */ - if((dset=H5Dopen(file,"/Dataset1"))<0) - goto error; - if (H5Dclose(dset)<0) goto error; - - if (H5Fclose(file)<0) goto error; - } - PASSED(); - } - else - { + if(HDstrcmp(envval, "core") && HDstrcmp(envval, "multi") && HDstrcmp(envval, "split") && HDstrcmp(envval, "family")) { + hid_t file2; /* File ID for 'bogus' object file */ + char testpath[512] = ""; + char testfile[512] = ""; + char *srcdir = HDgetenv("srcdir"); + + /* Build path to all test files */ + if(srcdir && ((HDstrlen(srcdir) + 2) < sizeof(testpath))) { + HDstrcpy(testpath, srcdir); + HDstrcat(testpath, "/"); + } /* end if */ + + /* Build path to test file */ + if(srcdir && ((HDstrlen(testpath) + HDstrlen(FILE_BOGUS) + 1) < sizeof(testfile))) + HDstrcpy(testfile, testpath); + HDstrcat(testfile, FILE_BOGUS); + + TESTING("object with unknown header message and no flags set"); + + /* Open the file with objects that have unknown header messages (generated with gen_bogus.c) */ + if((file2 = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + + /* Open the dataset with the unknown header message, but no extra flags */ + if((dset = H5Dopen(file2, "/Dataset1")) < 0) + TEST_ERROR + if(H5Dclose(dset) < 0) + TEST_ERROR + + PASSED(); + + TESTING("object with unknown header message & 'fail if unknown' flag set"); + + /* Attempt to open the dataset with the unknown header message, and "fail if unknown" flag */ + H5E_BEGIN_TRY { + dset = H5Dopen(file2, "/Dataset2"); + } H5E_END_TRY; + if(dset >= 0) { + H5Dclose(dset); + TEST_ERROR + } /* end if */ + + PASSED(); + + TESTING("object with unknown header message & 'mark if unknown' flag set"); + + /* Copy object with "mark if unknown" flag on message into file that can be modified */ + if(H5Ocopy(file2, "/Dataset3", file, "/Dataset3", H5P_DEFAULT, H5P_DEFAULT) < 0) + TEST_ERROR + + /* Close the file we created (to flush changes to file) */ + if(H5Fclose(file) < 0) + TEST_ERROR + + /* Re-open the file created, with read-only permissions */ + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + + /* Open the dataset with the "mark if unknown" message */ + if((dset = H5Dopen(file, "/Dataset3")) < 0) + TEST_ERROR + + /* Check that the "unknown" message was _NOT_ marked */ + if(H5O_check_msg_marked_test(dset, FALSE) < 0) + FAIL_STACK_ERROR + + /* Close the dataset */ + if(H5Dclose(dset) < 0) + TEST_ERROR + + /* Close the file we created (to flush change to object header) */ + if(H5Fclose(file) < 0) + TEST_ERROR + + /* Re-open the file created */ + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + + /* Open the dataset with the "mark if unknown" message */ + if((dset = H5Dopen(file, "/Dataset3")) < 0) + TEST_ERROR + if(H5Dclose(dset) < 0) + TEST_ERROR + + /* Close the file we created (to flush change to object header) */ + if(H5Fclose(file) < 0) + TEST_ERROR + + /* Re-open the file created */ + if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + + /* Re-open the dataset with the "mark if unknown" message */ + if((dset = H5Dopen(file, "/Dataset3")) < 0) + TEST_ERROR + + /* Check that the "unknown" message was marked */ + if(H5O_check_msg_marked_test(dset, TRUE) < 0) + FAIL_STACK_ERROR + + /* Close the dataset */ + if(H5Dclose(dset) < 0) + TEST_ERROR + + + /* Close the file with the bogus objects */ + if(H5Fclose(file2) < 0) + TEST_ERROR + + PASSED(); + } /* end if */ + else { SKIPPED(); puts(" Test not compatible with current Virtual File Driver"); - } + } /* end else */ + + /* Close the file we created */ + if(H5Fclose(file) < 0) + TEST_ERROR puts("All object header tests passed."); h5_cleanup(FILENAME, fapl); - return 0; + return(0); + +error: + puts("*** TESTS FAILED ***"); + H5E_BEGIN_TRY { + H5Fclose(file); + } H5E_END_TRY; + return(1); +} /* end main() */ - error: - puts("*** TESTS FAILED ***"); - H5E_BEGIN_TRY { - H5Fclose(file); - } H5E_END_TRY; - return 1; -} diff --git a/test/tbogus.h5 b/test/tbogus.h5 Binary files differindex ddc3b65..2b8b1dd 100644 --- a/test/tbogus.h5 +++ b/test/tbogus.h5 |