diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-09-17 12:45:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-09-17 12:45:55 (GMT) |
commit | 6747ebd9858374ae912b6182024861b1710518c8 (patch) | |
tree | 9bd75142d9dd292fe4272118f650f1c91205a988 /test | |
parent | 9de3a84f916168831f29a4259fe93cb4823d8f57 (diff) | |
download | hdf5-6747ebd9858374ae912b6182024861b1710518c8.zip hdf5-6747ebd9858374ae912b6182024861b1710518c8.tar.gz hdf5-6747ebd9858374ae912b6182024861b1710518c8.tar.bz2 |
[svn-r19413] Description:
Bring r19349:19411 from trunk to revise_chunks branch.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.4 (amazon) in debug mode
Mac OS X/32 10.6.4 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Mac OS X/32 10.6.4 (amazon) w/parallel, in debug mode
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 77 | ||||
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/Makefile.in | 53 | ||||
-rw-r--r-- | test/dsets.c | 14 | ||||
-rw-r--r-- | test/error_test.c | 64 | ||||
-rw-r--r-- | test/fheap.c | 142 | ||||
-rw-r--r-- | test/filter_fail.c | 382 | ||||
-rw-r--r-- | test/tfile.c | 61 | ||||
-rw-r--r-- | test/tid.c | 4 | ||||
-rw-r--r-- | test/ttsafe.c | 13 | ||||
-rw-r--r-- | test/ttsafe.h | 2 | ||||
-rw-r--r-- | test/ttsafe_acreate.c | 10 | ||||
-rw-r--r-- | test/ttsafe_cancel.c | 2 | ||||
-rw-r--r-- | test/ttsafe_dcreate.c | 23 | ||||
-rw-r--r-- | test/ttsafe_error.c | 33 |
15 files changed, 737 insertions, 149 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bbf7894..0bec69f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -148,16 +148,7 @@ SET (testhdf5_SRCS #-- Adding test for testhdf5 ADD_EXECUTABLE (testhdf5 ${testhdf5_SRCS}) H5_NAMING (testhdf5) -IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (testhdf5 - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) -ENDIF (WIN32) +TARGET_WIN_PROPERTIES (testhdf5) TARGET_LINK_LIBRARIES (testhdf5 ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) ADD_TEST (NAME testhdf5 COMMAND $<TARGET_FILE:testhdf5>) @@ -171,16 +162,7 @@ ADD_TEST (NAME testhdf5 COMMAND $<TARGET_FILE:testhdf5>) MACRO (ADD_H5_TEST file) ADD_EXECUTABLE (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) H5_NAMING (${file}) - IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (${file} - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) - ENDIF (WIN32) + TARGET_WIN_PROPERTIES (${file}) TARGET_LINK_LIBRARIES (${file} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) ADD_TEST (NAME ${file} COMMAND $<TARGET_FILE:${file}>) @@ -254,16 +236,7 @@ ENDIF (WIN32) #-- Adding test for cache ADD_EXECUTABLE (cache ${HDF5_TEST_SOURCE_DIR}/cache.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) H5_NAMING (cache) -IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (cache - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) -ENDIF (WIN32) +TARGET_WIN_PROPERTIES (cache) TARGET_LINK_LIBRARIES (cache ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) ADD_TEST (NAME cache COMMAND $<TARGET_FILE:cache>) @@ -271,16 +244,7 @@ ADD_TEST (NAME cache COMMAND $<TARGET_FILE:cache>) #-- Adding test for cache_api ADD_EXECUTABLE (cache_api ${HDF5_TEST_SOURCE_DIR}/cache_api.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) H5_NAMING (cache_api) -IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (cache_api - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) -ENDIF (WIN32) +TARGET_WIN_PROPERTIES (cache_api) TARGET_LINK_LIBRARIES (cache_api ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) ADD_TEST (NAME cache_api COMMAND $<TARGET_FILE:cache_api>) @@ -288,16 +252,7 @@ ADD_TEST (NAME cache_api COMMAND $<TARGET_FILE:cache_api>) #-- Adding test for cache_tagging ADD_EXECUTABLE (cache_tagging ${HDF5_TEST_SOURCE_DIR}/cache_tagging.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) H5_NAMING (cache_tagging) -IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (cache_tagging - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) -ENDIF (WIN32) +TARGET_WIN_PROPERTIES (cache_tagging) TARGET_LINK_LIBRARIES (cache_tagging ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) ADD_TEST (NAME cache_tagging COMMAND $<TARGET_FILE:cache_tagging>) @@ -310,16 +265,7 @@ ADD_EXECUTABLE (ttsafe ${HDF5_TEST_SOURCE_DIR}/ttsafe_acreate.c ) H5_NAMING (ttsafe) -IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (ttsafe - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) -ENDIF (WIN32) +TARGET_WIN_PROPERTIES (ttsafe) TARGET_LINK_LIBRARIES (ttsafe ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) ADD_TEST (NAME ttsafe COMMAND $<TARGET_FILE:ttsafe>) @@ -334,16 +280,7 @@ IF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) MACRO (ADD_H5_GENERATOR genfile) ADD_EXECUTABLE (${genfile} ${HDF5_TEST_SOURCE_DIR}/${genfile}.c) H5_NAMING (${genfile}) - IF (WIN32) - IF (MSVC) - IF (NOT BUILD_SHARED_LIBS) - SET_TARGET_PROPERTIES (${genfile} - PROPERTIES - LINK_FLAGS "/NODEFAULTLIB:MSVCRT" - ) - ENDIF (NOT BUILD_SHARED_LIBS) - ENDIF (MSVC) - ENDIF (WIN32) + TARGET_WIN_PROPERTIES (${genfile}) TARGET_LINK_LIBRARIES (${genfile} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) ENDMACRO (ADD_H5_GENERATOR genfile) diff --git a/test/Makefile.am b/test/Makefile.am index 6ca7227..42545d1 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -38,8 +38,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) # other current library code tests. TEST_PROG=testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ pool hyperslab istore bittests dt_arith \ - dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \ - fillval mount flush1 flush2 app_ref enum \ + dtypes dsets cmpd_dset filter_fail extend external objcopy links unlink \ + big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe \ getname vfd ntypes dangle dtransform reserved cross_read \ freespace mf farray earray btree2 fheap @@ -112,7 +112,7 @@ CHECK_CLEANFILES+=cmpd_dset.h5 compact_dataset.h5 dataset.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_fast.h5 \ chunk_expand.h5 \ copy_dcpl_newfile.h5 extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ - sys_file1 tfile[1-4].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \ + sys_file1 tfile[1-5].h5 th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 \ stab.h5 extern_[1-3].h5 extern_[1-4][ab].raw gheap[0-4].h5 \ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ diff --git a/test/Makefile.in b/test/Makefile.in index 65bdaec..e91de4c 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -84,9 +84,9 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ cache_tagging$(EXEEXT) pool$(EXEEXT) hyperslab$(EXEEXT) \ istore$(EXEEXT) bittests$(EXEEXT) dt_arith$(EXEEXT) \ dtypes$(EXEEXT) dsets$(EXEEXT) cmpd_dset$(EXEEXT) \ - extend$(EXEEXT) external$(EXEEXT) objcopy$(EXEEXT) \ - links$(EXEEXT) unlink$(EXEEXT) big$(EXEEXT) mtime$(EXEEXT) \ - fillval$(EXEEXT) mount$(EXEEXT) flush1$(EXEEXT) \ + filter_fail$(EXEEXT) extend$(EXEEXT) external$(EXEEXT) \ + objcopy$(EXEEXT) links$(EXEEXT) unlink$(EXEEXT) big$(EXEEXT) \ + mtime$(EXEEXT) fillval$(EXEEXT) mount$(EXEEXT) flush1$(EXEEXT) \ flush2$(EXEEXT) app_ref$(EXEEXT) enum$(EXEEXT) \ set_extent$(EXEEXT) ttsafe$(EXEEXT) getname$(EXEEXT) \ vfd$(EXEEXT) ntypes$(EXEEXT) dangle$(EXEEXT) \ @@ -194,6 +194,10 @@ fillval_SOURCES = fillval.c fillval_OBJECTS = fillval.$(OBJEXT) fillval_LDADD = $(LDADD) fillval_DEPENDENCIES = libh5test.la $(LIBHDF5) +filter_fail_SOURCES = filter_fail.c +filter_fail_OBJECTS = filter_fail.$(OBJEXT) +filter_fail_LDADD = $(LDADD) +filter_fail_DEPENDENCIES = libh5test.la $(LIBHDF5) flush1_SOURCES = flush1.c flush1_OBJECTS = flush1.$(OBJEXT) flush1_LDADD = $(LDADD) @@ -405,10 +409,10 @@ SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c btree2.c \ cache.c cache_api.c cache_tagging.c cmpd_dset.c cross_read.c \ dangle.c dsets.c dt_arith.c dtransform.c dtypes.c earray.c \ enum.c err_compat.c error_test.c extend.c external.c farray.c \ - fheap.c fillval.c flush1.c flush2.c freespace.c gen_bad_ohdr.c \ - gen_bogus.c gen_cross.c gen_deflate.c gen_filespace.c \ - gen_filters.c gen_idx.c gen_new_array.c gen_new_fill.c \ - gen_new_group.c gen_new_mtime.c gen_new_super.c \ + fheap.c fillval.c filter_fail.c flush1.c flush2.c freespace.c \ + gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \ + gen_filespace.c gen_filters.c gen_idx.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_sizes_lheap.c \ gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \ istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \ @@ -420,17 +424,18 @@ DIST_SOURCES = $(libh5test_la_SOURCES) app_ref.c big.c bittests.c \ btree2.c cache.c cache_api.c cache_tagging.c cmpd_dset.c \ cross_read.c dangle.c dsets.c dt_arith.c dtransform.c dtypes.c \ earray.c enum.c err_compat.c error_test.c extend.c external.c \ - farray.c fheap.c fillval.c flush1.c flush2.c freespace.c \ - gen_bad_ohdr.c gen_bogus.c gen_cross.c gen_deflate.c \ - gen_filespace.c gen_filters.c gen_idx.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_sizes_lheap.c \ - gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \ - istore.c lheap.c links.c mf.c mount.c mtime.c ntypes.c \ - objcopy.c ohdr.c pool.c reserved.c set_extent.c \ - space_overflow.c stab.c swmr_generator.c swmr_reader.c \ - swmr_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c vfd.c + farray.c fheap.c fillval.c filter_fail.c flush1.c flush2.c \ + freespace.c gen_bad_ohdr.c gen_bogus.c gen_cross.c \ + gen_deflate.c gen_filespace.c gen_filters.c gen_idx.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_sizes_lheap.c gen_specmetaread.c gen_udlinks.c getname.c \ + gheap.c hyperslab.c istore.c lheap.c links.c mf.c mount.c \ + mtime.c ntypes.c objcopy.c ohdr.c pool.c reserved.c \ + set_extent.c space_overflow.c stab.c swmr_generator.c \ + swmr_reader.c swmr_writer.c tcheck_version.c \ + $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ + vfd.c ETAGS = etags CTAGS = ctags am__tty_colors = \ @@ -637,7 +642,6 @@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ -lt_ECHO = @lt_ECHO@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ @@ -686,6 +690,7 @@ H5CC_PP = $(bindir)/h5pcc H5FC = $(bindir)/h5fc H5FC_PP = $(bindir)/h5pfc H5CPP = $(bindir)/h5c++ +ACLOCAL_AMFLAGS = "-I m4" # The trace script; this is used on source files from the C library to # insert tracing macros. @@ -705,7 +710,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog cmpd_dset.h5 \ max_compact_dataset.h5 simple.h5 set_local.h5 random_chunks.h5 \ huge_chunks.h5 chunk_cache.h5 big_chunk.h5 chunk_fast.h5 \ chunk_expand.h5 copy_dcpl_newfile.h5 extend.h5 istore.h5 \ - extlinks*.h5 frspace.h5 links*.h5 sys_file1 tfile[1-4].h5 \ + extlinks*.h5 frspace.h5 links*.h5 sys_file1 tfile[1-5].h5 \ th5s[1-3].h5 lheap.h5 fheap.h5 ohdr.h5 stab.h5 extern_[1-3].h5 \ extern_[1-4][ab].raw gheap[0-4].h5 dt_arith[1-2] links.h5 \ links[0-6]*.h5 extlinks[0-15].h5 tmp big.data \ @@ -739,8 +744,8 @@ SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) # other current library code tests. TEST_PROG = testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ pool hyperslab istore bittests dt_arith \ - dtypes dsets cmpd_dset extend external objcopy links unlink big mtime \ - fillval mount flush1 flush2 app_ref enum \ + dtypes dsets cmpd_dset filter_fail extend external objcopy links unlink \ + big mtime fillval mount flush1 flush2 app_ref enum \ set_extent ttsafe \ getname vfd ntypes dangle dtransform reserved cross_read \ freespace mf farray earray btree2 fheap @@ -981,6 +986,9 @@ fheap$(EXEEXT): $(fheap_OBJECTS) $(fheap_DEPENDENCIES) fillval$(EXEEXT): $(fillval_OBJECTS) $(fillval_DEPENDENCIES) @rm -f fillval$(EXEEXT) $(LINK) $(fillval_OBJECTS) $(fillval_LDADD) $(LIBS) +filter_fail$(EXEEXT): $(filter_fail_OBJECTS) $(filter_fail_DEPENDENCIES) + @rm -f filter_fail$(EXEEXT) + $(LINK) $(filter_fail_OBJECTS) $(filter_fail_LDADD) $(LIBS) flush1$(EXEEXT): $(flush1_OBJECTS) $(flush1_DEPENDENCIES) @rm -f flush1$(EXEEXT) $(LINK) $(flush1_OBJECTS) $(flush1_LDADD) $(LIBS) @@ -1150,6 +1158,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/farray.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fheap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fillval.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filter_fail.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)/freespace.Po@am__quote@ diff --git a/test/dsets.c b/test/dsets.c index 15de972..88ffe5d 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -944,10 +944,10 @@ static herr_t test_layout_extend(hid_t fapl) { char filename[FILENAME_BUF_SIZE]; /* File name */ - hid_t fid; /* File id */ - hid_t sid_fix, sid_unlim; /* Dataspace id */ - hid_t dcpl_compact, dcpl_contig, dcpl_chunked; /* Dataset creation property list id */ - hid_t did_fixed, did_unlim; /* Dataset id */ + hid_t fid = -1; /* File id */ + hid_t sid_fix = -1, sid_unlim = -1; /* Dataspace id */ + hid_t dcpl_compact = -1, dcpl_contig = -1, dcpl_chunked = -1; /* Dataset creation property list id */ + hid_t did_fixed = -1, did_unlim = -1; /* Dataset id */ hsize_t cur_size[1] = {10}; /* Current size of dataspace */ hsize_t max_unlim[1] = {H5S_UNLIMITED}; /* Maximum size of dataspace (unlimited) */ hsize_t max_fix[1] = {100}; /* Maximum size of dataspace (fixed) */ @@ -6336,7 +6336,7 @@ error: static herr_t test_zero_dims(hid_t file) { - hid_t s=-1, d=-1, dcpl=-1; + hid_t s = -1, d = -1, dcpl = -1; hid_t s2 = -1, d2 = -1, dcpl2 = -1; hsize_t dsize = 0, dmax = H5S_UNLIMITED, csize = 5; hsize_t dsize2[2] = {0, 0}; @@ -6748,7 +6748,7 @@ test_random_chunks(hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; /* Open file again */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Open dataset */ if((d = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; @@ -6850,7 +6850,7 @@ test_random_chunks(hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; /* Open file again */ - if((file = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) TEST_ERROR; + if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; /* Open dataset */ if((d = H5Dopen2(file, dname, H5P_DEFAULT)) < 0) TEST_ERROR; diff --git a/test/error_test.c b/test/error_test.c index e784eb9..52dcc0c 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -515,6 +515,67 @@ error: return(-1); } /* end test_create() */ +/*------------------------------------------------------------------------- + * Function: test_copy + * + * Purpose: Test copyinging an error stack + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Allen Byrne + * February 18, 2010 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_copy(void) +{ + const char *err_func = "test_copy"; /* Function name for pushing error */ + const char *err_msg = "Error message"; /* Error message for pushing error */ + int err_num; /* Number of errors on stack */ + int err_num_copy; /* Number of errors on stack copy */ + hid_t estack_id; /* Error stack ID */ + herr_t ret; /* Generic return value */ + + /* Push an error with a long description */ + if(H5Epush(H5E_DEFAULT, __FILE__, err_func, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, err_msg) < 0) TEST_ERROR; + + /* Check the number of errors on stack */ + err_num = H5Eget_num(H5E_DEFAULT); + if(err_num != 1) TEST_ERROR + + /* Copy error stack, which clears the original */ + if((estack_id = H5Eget_current_stack()) < 0) TEST_ERROR + + /* Check the number of errors on stack copy */ + err_num = H5Eget_num(estack_id); + if(err_num != 1) TEST_ERROR + + /* Check the number of errors on original stack */ + err_num = H5Eget_num(H5E_DEFAULT); + if(err_num != 0) TEST_ERROR + + /* Put the stack copy as the default. It closes the stack copy, too. */ + if(H5Eset_current_stack(estack_id) < 0) TEST_ERROR + + /* Check the number of errors on default stack */ + err_num = H5Eget_num(H5E_DEFAULT); + if(err_num != 1) TEST_ERROR + + /* Try to close error stack copy. Should fail because + * the current H5Eset_current_stack closes the stack to be set.*/ + H5E_BEGIN_TRY { + ret = H5Eclose_stack(estack_id); + } H5E_END_TRY + if(ret >= 0) TEST_ERROR + + return(0); + +error: + return(-1); +} /* end test_copy() */ + /*------------------------------------------------------------------------- * Function: close_error @@ -624,6 +685,9 @@ main(void) /* Test creating a new error stack */ if(test_create() < 0) TEST_ERROR; + /* Test copying a new error stack */ + if(test_copy() < 0) TEST_ERROR; + if(H5Fclose(file) < 0) TEST_ERROR; h5_cleanup(FILENAME, fapl); diff --git a/test/fheap.c b/test/fheap.c index f983184..e38302c 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -2975,7 +2975,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Re-open the heap */ - if(NULL == (fh = H5HF_open(f, H5P_DATASET_XFER_DEFAULT, fh_addr))) + if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) FAIL_STACK_ERROR /* Check the heap's size */ @@ -3019,6 +3019,145 @@ error: return(1); } /* test_size() */ + +/*------------------------------------------------------------------------- + * Function: test_reopen_hdr + * + * Purpose: Test opening a header through one file handle, closing + * that file handle, then reopening through a different file + * handle that was open the whole time. The header should + * stay in cache between the two opens. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Neil Fortner + * Tuesday, September 14, 2010 + * + *------------------------------------------------------------------------- + */ +static unsigned +test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam) +{ + hid_t file1 = -1; /* File ID */ + hid_t file2 = -2; /* File ID */ + hid_t dxpl = H5P_DATASET_XFER_DEFAULT; /* DXPL to use */ + char filename[FHEAP_FILENAME_LEN]; /* Filename to use */ + H5F_t *f = NULL; /* Internal file object pointer */ + H5HF_t *fh = NULL; /* Fractal heap wrapper */ + haddr_t fh_addr; /* Address of fractal heap */ + hsize_t heap_size; /* Total size of heap on disk */ + + /* Set the filename to use for this test (dependent on fapl) */ + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Create the file to work on */ + if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object */ + if(NULL == (f = (H5F_t *)H5I_object(file1))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if (H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + + /* Display testing message */ + TESTING("reopening header through different file") + + + /* Create absolute heap */ + if(NULL == (fh = H5HF_create(f, dxpl, cparam))) + FAIL_STACK_ERROR + + /* Get heap's address */ + if(H5HF_get_heap_addr(fh, &fh_addr) < 0) + FAIL_STACK_ERROR + if(!H5F_addr_defined(fh_addr)) + TEST_ERROR + + /* Insert an object */ + if(add_obj(fh, dxpl, (size_t)0, (size_t)10, NULL, NULL) < 0) + TEST_ERROR + + /* Close the fractal heap */ + if(H5HF_close(fh, dxpl) < 0) + FAIL_STACK_ERROR + fh = NULL; + + /* Close the file */ + if(H5Fclose(file1) < 0) + FAIL_STACK_ERROR + + + /* Re-open the file */ + if((file1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Re-open the file again */ + if((file2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + FAIL_STACK_ERROR + + /* Get a pointer to the internal file object (file1) */ + if(NULL == (f = (H5F_t *)H5I_object(file1))) + FAIL_STACK_ERROR + + /* Ignore metadata tags in the file's cache */ + if (H5AC_ignore_tags(f) < 0) + FAIL_STACK_ERROR + + /* Open the heap */ + if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) + FAIL_STACK_ERROR + + /* Close the heap */ + if(H5HF_close(fh, dxpl) < 0) + FAIL_STACK_ERROR + fh = NULL; + + /* Close the file (file1) */ + if(H5Fclose(file1) < 0) + FAIL_STACK_ERROR + + + /* Get a pointer to the internal file object (file2) */ + if(NULL == (f = (H5F_t *)H5I_object(file2))) + FAIL_STACK_ERROR + + /* Reopen the heap */ + if(NULL == (fh = H5HF_open(f, dxpl, fh_addr))) + FAIL_STACK_ERROR + + /* Check the heap's size */ + heap_size = 0; + if(H5HF_size(fh, dxpl, &heap_size) < 0) + FAIL_STACK_ERROR + + /* Close the fractal heap */ + if(H5HF_close(fh, H5P_DATASET_XFER_DEFAULT) < 0) + FAIL_STACK_ERROR + + + /* Close the file (file2) */ + if(H5Fclose(file2) < 0) + FAIL_STACK_ERROR + + /* All tests passed */ + PASSED() + + return(0); + +error: + H5E_BEGIN_TRY { + if(fh) + H5HF_close(fh, dxpl); + H5Fclose(file1); + H5Fclose(file2); + } H5E_END_TRY; + return(1); +} /* test_reopen_hdr() */ + #ifndef QAK2 /*------------------------------------------------------------------------- @@ -16159,6 +16298,7 @@ curr_test = FHEAP_TEST_NORMAL; nerrors += test_id_limits(fapl, &small_cparam); nerrors += test_filtered_create(fapl, &small_cparam); nerrors += test_size(fapl, &small_cparam); + nerrors += test_reopen_hdr(fapl, &small_cparam); #else /* QAK */ HDfprintf(stderr, "Uncomment tests!\n"); #endif /* QAK */ diff --git a/test/filter_fail.c b/test/filter_fail.c new file mode 100644 index 0000000..abb25cd --- /dev/null +++ b/test/filter_fail.c @@ -0,0 +1,382 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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: Raymond Lu <songyulu@hdfgroup.org> + * 7 September 2010 + * + * Purpose: Make sure dataset, file, and library can close properly when a + * mandatory filter fails. + */ + +#include "h5test.h" +#include "H5srcdir.h" + +#define DSET_NAME "dset_fail" +#define ONE_MB 1048576 +#define H5Z_FILTER_FAIL_TEST 312 +#define DIM 10 +#define FILTER_CHUNK_DIM 2 + +const char *FILENAME[] = { + "filter_fail", + NULL +}; + +static size_t filter_fail(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + +/* This message derives from H5Z */ +const H5Z_class2_t H5Z_FAIL_TEST[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_FAIL_TEST, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "filter_fail_test", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_fail, /* The actual filter function */ +}}; + + +/*------------------------------------------------------------------------- + * Function: filter_fail + * + * Purpose: For testing library's behavior when a mandatory filter + * fails to write a chunk. + * + * Return: Success: Data chunk size + * Failure: 0 + * + * Programmer: Raymond Lu + * 7 September 2010 + * + *------------------------------------------------------------------------- + */ +static size_t +filter_fail(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, + size_t *buf_size, void **buf) +{ + int *dst = (int*)(*buf); + unsigned int offset; + unsigned int length; + unsigned int value; + size_t ret_value = 0; + + if(flags & H5Z_FLAG_REVERSE) { /* do nothing during read */ + *buf_size = nbytes; + ret_value = nbytes; + } /* end if */ + else { /* Write data */ + /* If it's the last chunk, pretend to fail. Otherwise, do nothing. */ + if(*dst == 8 || *dst == 9) { + ret_value = 0; + } else { + *buf_size = nbytes; + ret_value = *buf_size; + } + } /* end else */ + +error: + return ret_value; +} /* end filter_fail() */ + + +/*------------------------------------------------------------------------- + * Function: test_filter_write_failure + * + * Purpose: Tests the library's behavior when a mandate filter returns + * failure. There're only 5 chunks with each of them having + * 2 integers. The filter will fail in the last chunk. The + * dataset should release all resources even though the last + * chunk can't be flushed to file. The file should close + * successfully. + * + * Return: + * Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 25 August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filter_write(char *file_name, hid_t my_fapl) +{ + char filename[1024]; + hid_t file = -1; + hid_t dataset=-1; /* dataset ID */ + hid_t sid=-1; /* dataspace ID */ + hid_t dcpl=-1; /* dataset creation property list ID */ + hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/ + hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/ + int nfilters; /* number of filters in DCPL */ + unsigned flags; /* flags for filter */ + int points[DIM]; /* Data */ + int rbuf[DIM]; /* Data */ + herr_t ret; /* generic return value */ + int i; + + TESTING("data writing when a mandatory filter fails"); + + /* Create file */ + if((file = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) TEST_ERROR + + /* create the data space */ + if((sid = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + + /* Create dcpl and register the filter */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR + + if(H5Pset_chunk(dcpl, 1, chunk_dims) < 0) TEST_ERROR + + if(H5Zregister (H5Z_FAIL_TEST) < 0) TEST_ERROR + + /* Check that the filter was registered */ + if(TRUE != H5Zfilter_avail(H5Z_FILTER_FAIL_TEST)) FAIL_STACK_ERROR + + /* Enable the filter as mandatory */ + if(H5Pset_filter(dcpl, H5Z_FILTER_FAIL_TEST, 0, (size_t)0, NULL) < 0) + TEST_ERROR + + /* create a dataset */ + if((dataset = H5Dcreate2(file, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Initialize the write buffer */ + for(i = 0; i < DIM; i++) + points[i] = i; + + /* Write data */ + if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, points) < 0) TEST_ERROR + + /* clean up objects used for this test */ + if(H5Pclose (dcpl) < 0) TEST_ERROR + if(H5Sclose (sid) < 0) TEST_ERROR + + /* Dataset closing should fail */ + H5E_BEGIN_TRY { + ret = H5Dclose (dataset); + } H5E_END_TRY; + if(ret >= 0) { + H5_FAILED(); + puts(" Dataset is supposed to fail because the chunk can't be flushed to file."); + TEST_ERROR + } + + /* Even though H5Dclose fails, it should release all resources. + * So the file should close successfully. */ + if(H5Fclose (file) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Sclose(sid); + H5Dclose(dataset); + H5Fclose(file); + } H5E_END_TRY; + return -1; +} /* end test_filter_write() */ + + +/*------------------------------------------------------------------------- + * Function: test_filter_read + * + * Purpose: Tests the library's behavior when a mandate filter returns + * failure. The first 4 chunks should be in the file. The + * last chunk should not. + * + * Return: + * Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 25 August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filter_read(char *file_name, hid_t my_fapl) +{ + hid_t file = -1; + hid_t dataset=-1; /* dataset ID */ + hid_t sid = -1; + hid_t mspace = -1; + hsize_t dims[1]={DIM}; /* dataspace dimension - 10*/ + hsize_t chunk_dims[1]={FILTER_CHUNK_DIM}; /* chunk dimension - 2*/ + int rbuf[DIM]; /* Data */ + hsize_t dset_size = 0; /* Dataset storage size */ + hsize_t hs_offset[H5S_MAX_RANK]; + hsize_t hs_size[H5S_MAX_RANK]; + hsize_t stride[1] = {2}; + hsize_t zero[8]; + hsize_t nelmts = DIM/2; + int i; + + TESTING("data reading when a mandatory filter fails"); + + /* Open file */ + if((file = H5Fopen(file_name, H5F_ACC_RDONLY, my_fapl)) < 0) TEST_ERROR + + /* Open dataset */ + if((dataset = H5Dopen2(file, DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR + + /* Verify the storage size is equal to 4 chunks */ + if((dset_size = H5Dget_storage_size(dataset)) == 0) TEST_ERROR + + if(dset_size != 4 * FILTER_CHUNK_DIM * sizeof(int)) TEST_ERROR + + /* Read the chunks */ + HDmemset(rbuf, 0, DIM * sizeof(int)); + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + + /* Check that the values read are the same as the values written. + * The last chunk should not be in the file. */ + for(i = 0; i < DIM; i++) { + if(i < DIM-2 && rbuf[i] != i) { + H5_FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %d\n", i); + printf(" rbuf[%d]=%d\n", i, rbuf[i]); + TEST_ERROR + } else if(i >= DIM-2 && rbuf[i] != 0) { + H5_FAILED(); + printf(" No value should be read.\n"); + printf(" At index %d\n", i); + printf(" rbuf[%d]=%d\n", i, rbuf[i]); + TEST_ERROR + } + } + + /* Try to read in hyperslab simulating the h5dump's way of printing data */ + if((sid = H5Dget_space(dataset)) < 0) TEST_ERROR + + HDmemset(hs_offset, 0, sizeof(hs_offset)); + HDmemset(hs_size, 0, sizeof(hs_size)); + hs_size[0] = DIM/2; + + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, stride, hs_size, NULL) < 0) + TEST_ERROR + + /* create the data space */ + if((mspace = H5Screate_simple(1, dims, NULL)) < 0) TEST_ERROR + + HDmemset(zero, 0, sizeof zero); + + if(H5Sselect_hyperslab(mspace, H5S_SELECT_SET, zero, stride, &nelmts, NULL) < 0) + TEST_ERROR + + HDmemset(rbuf, 0, DIM * sizeof(int)); + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, sid, H5P_DEFAULT, rbuf) < 0) + TEST_ERROR + + /* Check that the values read are the same as the values written. + * The last chunk should not be in the file. */ + for(i = 0; i < DIM; i+=2) { + if(i < DIM-2 && rbuf[i] != i) { + H5_FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %d\n", i); + printf(" rbuf[%d]=%d\n", i, rbuf[i]); + TEST_ERROR + } else if(i >= DIM-2 && rbuf[i] != 0) { + H5_FAILED(); + printf(" No value should be read.\n"); + printf(" At index %d\n", i); + printf(" rbuf[%d]=%d\n", i, rbuf[i]); + TEST_ERROR + } + } + + if(H5Sclose (sid) < 0) TEST_ERROR + if(H5Sclose (mspace) < 0) TEST_ERROR + if(H5Dclose (dataset) < 0) TEST_ERROR + if(H5Fclose (file) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Sclose(sid); + H5Sclose(mspace); + H5Dclose(dataset); + H5Fclose(file); + } H5E_END_TRY; + return -1; +} /* end test_filter_read() */ + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests the library's behavior when a mandate filter returns + * failure. + * + * Return: Success: exit(0) + * Failure: exit(1) + * + * Programmer: Raymond Lu + * 25 August 2010 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int main(void) +{ + hid_t fapl; + int mdc_nelmts = 0; + size_t rdcc_nelmts = 521; + size_t rdcc_nbytes = ONE_MB; + double rdcc_w0 = 0.75; + char filename[1024]; + unsigned nerrors = 0; + + h5_reset(); + fapl = h5_fileaccess(); + + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + /* Make sure the chunk cache is used. All values are default. */ + if(H5Pset_cache(fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) + TEST_ERROR + + nerrors += (test_filter_write(filename, fapl) < 0 ? 1 : 0); + nerrors += (test_filter_read(filename, fapl) < 0 ? 1 : 0); + + h5_cleanup(FILENAME, fapl); + + /* Make sure we can close the library */ + if(H5close() < 0) TEST_ERROR + + if (nerrors) TEST_ERROR + + return 0; + +error: + if (nerrors) { + printf("***** %u FAILURE%s! *****\n", + nerrors, 1==nerrors?"":"S"); + HDexit(1); + } +} diff --git a/test/tfile.c b/test/tfile.c index 3b717eb..041522f 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -3054,6 +3054,66 @@ test_filespace_compatible(void) /**************************************************************** ** +** test_libver_bounds(): +** Verify that a file created with "LATEST, LATEST" can be +** opened later, with no setting. (Further testing welcome) +** +****************************************************************/ +static void +test_libver_bounds(void) +{ + hid_t file, group; /* Handles */ + hid_t fapl; /* File access property list */ + herr_t ret; /* Return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing setting library version bounds\n")); + + /* + * Create a new file using the default properties. + */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + file = H5Fcreate("tfile5.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); + CHECK(file, FAIL, "H5Fcreate"); + + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + file = H5Fopen("tfile5.h5", H5F_ACC_RDWR, fapl); + CHECK(file, FAIL, "H5Fopen"); + + /* + * Create a group named "G1" in the file. + */ + group = H5Gcreate2(file, "/G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group, FAIL, "H5Gcreate"); + + ret = H5Gclose(group); + CHECK(ret, FAIL, "H5Gclose"); + + /* + * Create a group named "/G1/G3" in the file. + */ + group = H5Gcreate2(file, "/G1/G3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(group, FAIL, "H5Gcreate"); + + ret = H5Gclose(group); + CHECK(ret, FAIL, "H5Gclose"); + + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); +} /* test_libver_bounds() */ + +/**************************************************************** +** ** test_swmr_write(): low-level file test routine. ** This test checks that the H5F_ACC_SWMR_WRITE access flag is ** working properly. @@ -3427,6 +3487,7 @@ test_file(void) test_filespace_sects(); /* Test file free space section information */ test_filespace_info(); /* Test file creation public routines:H5Pget/set_file_space */ test_filespace_compatible();/* Test compatibility for file space management */ + test_libver_bounds(); /* Test compatibility for file space management */ test_swmr_write(); /* Tests for SWMR write access flag */ test_swmr_read(); /* Tests for SWMR read access flag */ #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -361,7 +361,7 @@ static int test_is_valid(void) CHECK(ret, FAIL, "H5I_inc_ref"); if (ret < 0) goto out; - ret = H5I_dec_ref(dtype, TRUE); + ret = H5I_dec_app_ref(dtype); CHECK(ret, FAIL, "H5I_dec_ref"); if (ret < 0) goto out; @@ -377,7 +377,7 @@ static int test_is_valid(void) CHECK(nmembs1, FAIL, "H5I_nmembers"); if (nmembs1 < 0) goto out; - ret = H5I_dec_ref(dtype, FALSE); + ret = H5I_dec_ref(dtype); CHECK(ret, FAIL, "H5I_dec_ref"); if (ret < 0) goto out; diff --git a/test/ttsafe.c b/test/ttsafe.c index 1fadd95..253470b 100644 --- a/test/ttsafe.c +++ b/test/ttsafe.c @@ -89,11 +89,14 @@ int main(int argc, char *argv[]) /* Initialize testing framework */ TestInit(argv[0], NULL, NULL); - /* Tests are generally arranged from least to most complexity... */ - AddTest("dcreate", tts_dcreate, cleanup_dcreate, "multi-dataset creation", NULL); - AddTest("error", tts_error, cleanup_error, "per-thread error stacks", NULL); - AddTest("cancel", tts_cancel, cleanup_cancel, "thread cancellation safety test", NULL); - AddTest("acreate", tts_acreate, cleanup_acreate, "multi-attribute creation", NULL); + /* Tests are generally arranged from least to most complexity... */ + AddTest("dcreate", tts_dcreate, cleanup_dcreate, "multi-dataset creation", NULL); + AddTest("error", tts_error, cleanup_error, "per-thread error stacks", NULL); +#ifdef H5_HAVE_PTHREAD_H + /* Thread cancellability only supported with pthreads ... */ + AddTest("cancel", tts_cancel, cleanup_cancel, "thread cancellation safety test", NULL); +#endif /* H5_HAVE_PTHREAD_H */ + AddTest("acreate", tts_acreate, cleanup_acreate, "multi-attribute creation", NULL); /* Display testing information */ TestInfo(argv[0]); diff --git a/test/ttsafe.h b/test/ttsafe.h index 482e1b2..b4826fc 100644 --- a/test/ttsafe.h +++ b/test/ttsafe.h @@ -33,7 +33,9 @@ #ifdef H5_HAVE_THREADSAFE /* Include pthread library for threadsafe tests */ +#ifdef H5_HAVE_PTHREAD_H #include <pthread.h> +#endif /* H5_HAVE_PTHREAD_H */ /* Prototypes for the support routines */ extern char* gen_name(int); diff --git a/test/ttsafe_acreate.c b/test/ttsafe_acreate.c index 0e2c7c8..0efd02c 100644 --- a/test/ttsafe_acreate.c +++ b/test/ttsafe_acreate.c @@ -68,8 +68,8 @@ typedef struct acreate_data_struct { void tts_acreate(void) { - /* Pthread declarations */ - pthread_t threads[NUM_THREADS]; + /* Thread declarations */ + H5TS_thread_t threads[NUM_THREADS]; /* HDF5 data declarations */ hid_t file, dataset; @@ -118,13 +118,11 @@ void tts_acreate(void) attrib_data->datatype = datatype; attrib_data->dataspace = dataspace; attrib_data->current_index = i; - ret = pthread_create(&threads[i], NULL, tts_acreate_thread, attrib_data); - assert(ret == 0); + threads[i] = H5TS_create_thread(tts_acreate_thread, NULL, attrib_data); } /* end for */ for(i = 0; i < NUM_THREADS; i++) { - ret = pthread_join(threads[i], NULL); - assert(ret == 0); + H5TS_wait_for_thread(threads[i]); } /* end for */ diff --git a/test/ttsafe_cancel.c b/test/ttsafe_cancel.c index 1cc2e8c..8264403 100644 --- a/test/ttsafe_cancel.c +++ b/test/ttsafe_cancel.c @@ -47,6 +47,7 @@ #include "ttsafe.h" #ifdef H5_HAVE_THREADSAFE +#ifndef H5_HAVE_WIN_THREADS #define FILENAME "ttsafe_cancel.h5" #define DATASETNAME "commonname" @@ -253,4 +254,5 @@ void cleanup_cancel(void) HDunlink(FILENAME); } +#endif /*H5_HAVE_WIN_THREADS*/ #endif /*H5_HAVE_THREADSAFE*/ diff --git a/test/ttsafe_dcreate.c b/test/ttsafe_dcreate.c index 35453ad..f83332d 100644 --- a/test/ttsafe_dcreate.c +++ b/test/ttsafe_dcreate.c @@ -88,21 +88,21 @@ thread_info thread_out[NUM_THREAD]; */ void tts_dcreate(void) { - /* Pthread definitions */ - pthread_t threads[NUM_THREAD]; + /* thread definitions */ + H5TS_thread_t threads[NUM_THREAD]; /* HDF5 data definitions */ hid_t file, dataset; int datavalue, i; - pthread_attr_t attribute; + H5TS_attr_t attribute; int ret; /* set pthread attribute to perform global scheduling */ - ret=pthread_attr_init(&attribute); - assert(ret==0); + H5TS_attr_init(&attribute); + + /* set thread scope to system */ #ifdef H5_HAVE_SYSTEM_SCOPE_THREADS - ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); - assert(ret==0); + H5TS_attr_setscope(&attribute, H5TS_SCOPE_SYSTEM); #endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */ /* @@ -117,13 +117,11 @@ void tts_dcreate(void) thread_out[i].id = i; thread_out[i].file = file; thread_out[i].dsetname = dsetname[i]; - ret=pthread_create(&threads[i], NULL, tts_dcreate_creator, &thread_out[i]); - assert(ret==0); + threads[i] = H5TS_create_thread(tts_dcreate_creator, NULL, &thread_out[i]); } /* end for */ for(i = 0;i < NUM_THREAD; i++) { - ret = pthread_join(threads[i], NULL); - assert(ret == 0); + H5TS_wait_for_thread(threads[i]); } /* end for */ /* compare data to see if it is written correctly */ @@ -157,8 +155,7 @@ void tts_dcreate(void) assert(ret >= 0); /* Destroy the thread attribute */ - ret=pthread_attr_destroy(&attribute); - assert(ret==0); + H5TS_attr_destroy(&attribute); } void *tts_dcreate_creator(void *_thread_data) diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index b3d056f..f55afdc 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -71,12 +71,12 @@ err_num_t expected[8]; int error_flag = 0; int error_count = 0; -pthread_mutex_t error_mutex; +H5TS_mutex_simple_t error_mutex; void tts_error(void) { - pthread_t threads[NUM_THREAD]; - pthread_attr_t attribute; + H5TS_thread_t threads[NUM_THREAD]; + H5TS_attr_t attribute; hid_t dataset; int value, i; int ret; @@ -104,16 +104,15 @@ void tts_error(void) expected[6].min_num = H5E_EXISTS; /* set up mutex for global count of errors */ - ret=pthread_mutex_init(&error_mutex, NULL); - assert(ret==0); + H5TS_mutex_init(&error_mutex); /* make thread scheduling global */ - ret=pthread_attr_init(&attribute); - assert(ret==0); + H5TS_attr_init(&attribute); + + /* set thread scope to system */ #ifdef H5_HAVE_SYSTEM_SCOPE_THREADS - ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); - assert(ret==0); + H5TS_attr_setscope(&attribute, H5TS_SCOPE_SYSTEM); #endif /* H5_HAVE_SYSTEM_SCOPE_THREADS */ /* @@ -124,13 +123,11 @@ void tts_error(void) assert(error_file>=0); for (i = 0; i < NUM_THREAD; i++){ - ret=pthread_create(&threads[i], &attribute, tts_error_thread, NULL); - assert(ret==0); + threads[i] = H5TS_create_thread(tts_error_thread, &attribute, NULL); } for (i = 0; i < NUM_THREAD; i++){ - ret=pthread_join(threads[i],NULL); - assert(ret==0); + H5TS_wait_for_thread(threads[i]); } if (error_flag) @@ -153,9 +150,7 @@ void tts_error(void) ret=H5Fclose(error_file); assert(ret>=0); - /* Destroy the thread attribute */ - ret=pthread_attr_destroy(&attribute); - assert(ret==0); + H5TS_attr_destroy(&attribute); } static @@ -208,11 +203,9 @@ herr_t error_callback(hid_t estack_id, void *client_data) { int ret; - ret=pthread_mutex_lock(&error_mutex); - assert(ret==0); + H5TS_mutex_lock_simple(&error_mutex); error_count++; - ret=pthread_mutex_unlock(&error_mutex); - assert(ret==0); + H5TS_mutex_unlock_simple(&error_mutex); return H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, client_data); } |