diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2012-03-21 15:10:17 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2012-03-21 15:10:17 (GMT) |
commit | eb89d7b53ab95623ab454186a602e1cafc7391f0 (patch) | |
tree | ceafe458b3011e38853e765352d3c7e59bbecce1 /test | |
parent | 3e468e6ff65d540a439e99ea568a6bff7add7cea (diff) | |
download | hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.zip hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.tar.gz hdf5-eb89d7b53ab95623ab454186a602e1cafc7391f0.tar.bz2 |
[svn-r22105] Description:
Bring r20557:22085 from trunk to this branch, also fixing some other
issues/failures in the branch simultaneously. The h5repack tests are still
failing, but Neil will be checking into those, so the branch can be fully
functional again.
Tested on:
Mac OSX/64 10.7.3 (amazon) w/debug
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 149 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.in | 62 | ||||
-rw-r--r-- | test/be_data.h5 | bin | 40320 -> 72368 bytes | |||
-rw-r--r-- | test/big.c | 578 | ||||
-rwxr-xr-x | test/cross_read.c | 932 | ||||
-rw-r--r-- | test/dsets.c | 129 | ||||
-rw-r--r-- | test/dt_arith.c | 18 | ||||
-rw-r--r-- | test/dtransform.c | 180 | ||||
-rw-r--r-- | test/dtypes.c | 658 | ||||
-rw-r--r-- | test/enum.c | 3 | ||||
-rw-r--r-- | test/error_test.c | 95 | ||||
-rw-r--r-- | test/filter_error.h5 | bin | 0 -> 3576 bytes | |||
-rw-r--r-- | test/flush2.c | 4 | ||||
-rwxr-xr-x | test/gen_cross.c | 608 | ||||
-rw-r--r-- | test/gen_filters.c | 157 | ||||
-rw-r--r-- | test/getname.c | 26 | ||||
-rw-r--r-- | test/h5test.c | 650 | ||||
-rw-r--r-- | test/h5test.h | 54 | ||||
-rw-r--r-- | test/le_data.h5 | bin | 40320 -> 72368 bytes | |||
-rw-r--r-- | test/links.c | 464 | ||||
-rw-r--r-- | test/mount.c | 22 | ||||
-rw-r--r-- | test/multi_file_v16-r.h5 | bin | 0 -> 65536 bytes | |||
-rw-r--r-- | test/multi_file_v16-s.h5 | bin | 0 -> 2048 bytes | |||
-rw-r--r-- | test/ntypes.c | 6 | ||||
-rwxr-xr-x | test/objcopy.c | 1044 | ||||
-rw-r--r-- | test/stab.c | 98 | ||||
-rw-r--r-- | test/tattr.c | 342 | ||||
-rw-r--r-- | test/testfiles/error_test_1 | 24 | ||||
-rw-r--r-- | test/testlinks_env.sh.in | 2 | ||||
-rw-r--r-- | test/tfile.c | 152 | ||||
-rw-r--r-- | test/th5o.c | 2 | ||||
-rw-r--r-- | test/th5s.c | 962 | ||||
-rw-r--r-- | test/tmisc.c | 168 | ||||
-rw-r--r-- | test/trefer.c | 152 | ||||
-rw-r--r-- | test/tskiplist.c | 284 | ||||
-rw-r--r-- | test/tunicode.c | 4 | ||||
-rw-r--r-- | test/unlink.c | 12 | ||||
-rw-r--r-- | test/vfd.c | 299 | ||||
-rw-r--r-- | test/vms_data.h5 | bin | 40320 -> 0 bytes |
40 files changed, 5531 insertions, 2814 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9ff9614..a2577b9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.6) PROJECT (HDF5_TEST) #----------------------------------------------------------------------------- @@ -29,8 +29,8 @@ IF (MINGW) TARGET_LINK_LIBRARIES (${HDF5_TEST_LIB_TARGET} "wsock32.lib") ENDIF (MINGW) TARGET_LINK_LIBRARIES (${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) -SET_GLOBAL_VARIABLE (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TEST_LIB_TARGET}") H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} ${LIB_TYPE}) +SET_TARGET_PROPERTIES (${HDF5_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test) # -------------------------------------------------------------------- # Copy all the HDF5 files from the test directory into the source directory @@ -88,11 +88,14 @@ SET (HDF5_REFERENCE_TEST_FILES filespace_1_6.h5 filespace_1_8.h5 fill_old.h5 + filter_error.h5 group_old.h5 le_data.h5 le_extlink1.h5 le_extlink2.h5 mergemsg.h5 + multi_file_v16-r.h5 + multi_file_v16-s.h5 noencoder.h5 specmetaread.h5 tarrold.h5 @@ -105,7 +108,6 @@ SET (HDF5_REFERENCE_TEST_FILES tmtimen.h5 tmtimeo.h5 tsizeslheap.h5 - vms_data.h5 ) FOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) @@ -151,8 +153,31 @@ SET (testhdf5_SRCS ADD_EXECUTABLE (testhdf5 ${testhdf5_SRCS}) TARGET_NAMING (testhdf5 ${LIB_TYPE}) TARGET_LINK_LIBRARIES (testhdf5 ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) +SET_TARGET_PROPERTIES (testhdf5 PROPERTIES FOLDER test) +# Remove any output file left over from previous test run +ADD_TEST ( + NAME h5test-clear-testhdf5-objects + COMMAND ${CMAKE_COMMAND} + -E remove + coord.h5 + sys_file1 + tattr.h5 + tfile1.h5 + tfile2.h5 + tfile3.h5 + tfile4.h5 + tfile5.h5 + tfile6.h5 + th5o_file + th5s1.h5 + tselect.h5 + tsohm.h5 + tsohm_dst.h5 + tsohm_src.h5 +) ADD_TEST (NAME testhdf5 COMMAND $<TARGET_FILE:testhdf5>) +SET_TESTS_PROPERTIES(testhdf5 PROPERTIES DEPENDS h5test-clear-testhdf5-objects) ############################################################################## ############################################################################## @@ -164,6 +189,7 @@ MACRO (ADD_H5_TEST file) ADD_EXECUTABLE (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) TARGET_NAMING (${file} ${LIB_TYPE}) TARGET_LINK_LIBRARIES (${file} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + SET_TARGET_PROPERTIES (${file} PROPERTIES FOLDER test) ADD_TEST (NAME ${file} COMMAND $<TARGET_FILE:${file}>) ENDMACRO (ADD_H5_TEST file) @@ -173,8 +199,6 @@ ADD_TEST ( NAME h5test-clear-objects COMMAND ${CMAKE_COMMAND} -E remove - cache_test.h5 - coord.h5 dt_arith1.h5 dt_arith2.h5 dtransform.h5 @@ -224,24 +248,10 @@ ADD_TEST ( extlinks19B00027.h5 extlinks19B00028.h5 fheap.h5 - objcopy_ext.h5 - sys_file1 - tattr.h5 + new_multi_file_v16-r.h5 + new_multi_file_v16-s.h5 + objcopy_ext.dat testmeta.h5 - tfile1.h5 - tfile2.h5 - tfile3.h5 - tfile4.h5 - tfile5.h5 - th5o_file - th5s1.h5 - th5s2.h5 - th5s3.h5 - tnullspace.h5 - tselect.h5 - tsohm.h5 - tsohm_dst.h5 - tsohm_src.h5 tstint1.h5 tstint2.h5 ) @@ -316,23 +326,47 @@ SET_TESTS_PROPERTIES(flush2 PROPERTIES DEPENDS flush1) ADD_EXECUTABLE (cache ${HDF5_TEST_SOURCE_DIR}/cache.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) TARGET_NAMING (cache ${LIB_TYPE}) TARGET_LINK_LIBRARIES (cache ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - +SET_TARGET_PROPERTIES (cache PROPERTIES FOLDER test) +ADD_TEST ( + NAME h5test-clear-cache-objects + COMMAND ${CMAKE_COMMAND} + -E remove + cache_test.h5 +) ADD_TEST (NAME cache COMMAND $<TARGET_FILE:cache>) -SET_TESTS_PROPERTIES(cache PROPERTIES DEPENDS h5test-clear-objects) +SET_TESTS_PROPERTIES(cache PROPERTIES DEPENDS h5test-clear-cache-objects) #-- Adding test for cache_api ADD_EXECUTABLE (cache_api ${HDF5_TEST_SOURCE_DIR}/cache_api.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) TARGET_NAMING (cache_api ${LIB_TYPE}) TARGET_LINK_LIBRARIES (cache_api ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) +SET_TARGET_PROPERTIES (cache_api PROPERTIES FOLDER test) +ADD_TEST ( + NAME h5test-clear-cache_api-objects + COMMAND ${CMAKE_COMMAND} + -E remove + cache_api_test.h5 +) ADD_TEST (NAME cache_api COMMAND $<TARGET_FILE:cache_api>) +SET_TESTS_PROPERTIES(cache_api PROPERTIES DEPENDS h5test-clear-cache_api-objects) #-- Adding test for cache_tagging ADD_EXECUTABLE (cache_tagging ${HDF5_TEST_SOURCE_DIR}/cache_tagging.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) TARGET_NAMING (cache_tagging ${LIB_TYPE}) TARGET_LINK_LIBRARIES (cache_tagging ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) +SET_TARGET_PROPERTIES (cache_tagging PROPERTIES FOLDER test) +ADD_TEST ( + NAME h5test-clear-cache_tagging-objects + COMMAND ${CMAKE_COMMAND} + -E remove + tagging_test.h5 + tagging_ext_test.h5 +) ADD_TEST (NAME cache_tagging COMMAND $<TARGET_FILE:cache_tagging>) +SET_TESTS_PROPERTIES(cache_tagging PROPERTIES DEPENDS h5test-clear-cache_tagging-objects) + #-- Adding test for ttsafe ADD_EXECUTABLE (ttsafe ${HDF5_TEST_SOURCE_DIR}/ttsafe.c @@ -343,15 +377,34 @@ ADD_EXECUTABLE (ttsafe ) TARGET_NAMING (ttsafe ${LIB_TYPE}) TARGET_LINK_LIBRARIES (ttsafe ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) +SET_TARGET_PROPERTIES (ttsafe PROPERTIES FOLDER test) +ADD_TEST ( + NAME h5test-clear-ttsafe-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ttsafe_error.h5 + ttsafe_dcreate.h5 + ttsafe_cancel.h5 + ttsafe_acreate.h5 +) ADD_TEST (NAME ttsafe COMMAND $<TARGET_FILE:ttsafe>) +SET_TESTS_PROPERTIES(ttsafe PROPERTIES DEPENDS h5test-clear-ttsafe-objects) #-- Adding test for err_compat IF (HDF5_ENABLE_DEPRECATED_SYMBOLS) ADD_EXECUTABLE (err_compat ${HDF5_TEST_SOURCE_DIR}/err_compat.c) TARGET_NAMING (err_compat ${LIB_TYPE}) TARGET_LINK_LIBRARIES (err_compat ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + SET_TARGET_PROPERTIES (err_compat PROPERTIES FOLDER test) + ADD_TEST ( + NAME h5test-clear-err_compat-objects + COMMAND ${CMAKE_COMMAND} + -E remove + err_compat.txt + err_compat.txt.err + ) ADD_TEST (NAME err_compat COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:err_compat>" -D "TEST_ARGS:STRING=" @@ -362,13 +415,22 @@ IF (HDF5_ENABLE_DEPRECATED_SYMBOLS) -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) + SET_TESTS_PROPERTIES(err_compat PROPERTIES DEPENDS h5test-clear-err_compat-objects) ENDIF (HDF5_ENABLE_DEPRECATED_SYMBOLS) #-- Adding test for error_test ADD_EXECUTABLE (error_test ${HDF5_TEST_SOURCE_DIR}/error_test.c) TARGET_NAMING (error_test ${LIB_TYPE}) TARGET_LINK_LIBRARIES (error_test ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) +SET_TARGET_PROPERTIES (error_test PROPERTIES FOLDER test) +ADD_TEST ( + NAME h5test-clear-error_test-objects + COMMAND ${CMAKE_COMMAND} + -E remove + error_test.txt + error_test.txt.err +) ADD_TEST (NAME error_test COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:error_test>" -D "TEST_ARGS:STRING=" @@ -379,12 +441,24 @@ ADD_TEST (NAME error_test COMMAND "${CMAKE_COMMAND}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) +SET_TESTS_PROPERTIES(error_test PROPERTIES DEPENDS h5test-clear-error_test-objects) #-- Adding test for links_env ADD_EXECUTABLE (links_env ${HDF5_TEST_SOURCE_DIR}/links_env.c) TARGET_NAMING (links_env ${LIB_TYPE}) TARGET_LINK_LIBRARIES (links_env ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) +SET_TARGET_PROPERTIES (links_env PROPERTIES FOLDER test) +ADD_TEST ( + NAME h5test-clear-links_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + links_env.txt + links_env.txt.err + extlinks_env0.h5 + extlinks_env1.h5 + tmp/extlinks_env1.h5 +) ADD_TEST (NAME links_env COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:links_env>" -D "TEST_ARGS:STRING=" @@ -396,6 +470,27 @@ ADD_TEST (NAME links_env COMMAND "${CMAKE_COMMAND}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -P "${HDF5_RESOURCES_DIR}/runTest.cmake" ) +SET_TESTS_PROPERTIES(links_env PROPERTIES DEPENDS h5test-clear-links_env-objects) + +#-- Adding test for libinfo +SET (GREP_RUNNER ${PROJECT_BINARY_DIR}/GrepRunner.cmake) +FILE (WRITE ${GREP_RUNNER} + "FILE (STRINGS \${TEST_PROGRAM} TEST_RESULT REGEX \"SUMMARY OF THE HDF5 CONFIGURATION\") +IF (\${TEST_RESULT} STREQUAL \"0\") + MESSAGE (FATAL_ERROR \"Failed: The output: \${TEST_RESULT} of \${TEST_PROGRAM} did not contain SUMMARY OF THE HDF5 CONFIGURATION\") +ELSE (\${TEST_RESULT} STREQUAL \"0\") + MESSAGE (STATUS \"COMMAND Result: \${TEST_RESULT}\") +ENDIF (\${TEST_RESULT} STREQUAL \"0\") +" +) + +ADD_TEST (NAME testlibinfo COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$<TARGET_FILE:${HDF5_LIB_TARGET}>" -P "${GREP_RUNNER}") + +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## IF (HDF5_TEST_VFD) @@ -513,6 +608,7 @@ IF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) ADD_EXECUTABLE (${genfile} ${HDF5_TEST_SOURCE_DIR}/${genfile}.c) TARGET_NAMING (${genfile} ${LIB_TYPE}) TARGET_LINK_LIBRARIES (${genfile} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + SET_TARGET_PROPERTIES (${genfile} PROPERTIES FOLDER generator/test) ENDMACRO (ADD_H5_GENERATOR genfile) # generator executables @@ -537,10 +633,7 @@ IF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) ) FOREACH (gen ${H5_GENERATORS}) - ADD_EXECUTABLE (${gen} ${HDF5_TEST_SOURCE_DIR}/${gen}.c) - TARGET_NAMING (${gen} ${LIB_TYPE}) - TARGET_LINK_LIBRARIES (${gen} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) + ADD_H5_GENERATOR (${gen}) ENDFOREACH (gen ${H5_GENERATORS}) ENDIF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) - diff --git a/test/Makefile.am b/test/Makefile.am index 7c8eeed..df093b7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -119,7 +119,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.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 \ - stdio.h5 sec2.h5 dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 \ + stdio.h5 sec2.h5 dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 \ tselect.h5 mtime.h5 unlink.h5 unicode.h5 coord.h5 \ fillval_[0-9].h5 fillval.raw mount_[0-9].h5 testmeta.h5 ttime.h5 \ trefer[1-3].h5 tvltypes.h5 tvlstr.h5 tvlstr2.h5 flush.h5 \ @@ -132,7 +132,8 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log swmr_data.h5 \ + earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \ + new_multi_file_v16-s.h5 swmr_data.h5 \ flushrefresh.h5 flushrefresh_VERIFICATION_START \ flushrefresh_VERIFICATION_CHECKPOINT1 flushrefresh_VERIFICATION_CHECKPOINT2 \ flushrefresh_VERIFICATION_DONE diff --git a/test/Makefile.in b/test/Makefile.in index 23c6ca8..d462da7 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -59,7 +59,9 @@ DIST_COMMON = $(srcdir)/H5srcdir_str.h.in $(srcdir)/Makefile.am \ $(top_srcdir)/config/commence.am \ $(top_srcdir)/config/conclude.am COPYING bin_PROGRAMS = swmr_generator$(EXEEXT) swmr_reader$(EXEEXT) \ - swmr_writer$(EXEEXT) swmr_remove_reader$(EXEEXT) swmr_remove_writer$(EXEEXT) swmr_addrem_writer$(EXEEXT) swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) + swmr_writer$(EXEEXT) swmr_remove_reader$(EXEEXT) \ + swmr_remove_writer$(EXEEXT) swmr_addrem_writer$(EXEEXT) \ + swmr_sparse_reader$(EXEEXT) swmr_sparse_writer$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT) \ links_env$(EXEEXT) flushrefresh$(EXEEXT) @@ -368,6 +370,10 @@ stab_SOURCES = stab.c stab_OBJECTS = stab.$(OBJEXT) stab_LDADD = $(LDADD) stab_DEPENDENCIES = libh5test.la $(LIBHDF5) +swmr_addrem_writer_SOURCES = swmr_addrem_writer.c +swmr_addrem_writer_OBJECTS = swmr_addrem_writer.$(OBJEXT) +swmr_addrem_writer_LDADD = $(LDADD) +swmr_addrem_writer_DEPENDENCIES = libh5test.la $(LIBHDF5) swmr_generator_SOURCES = swmr_generator.c swmr_generator_OBJECTS = swmr_generator.$(OBJEXT) swmr_generator_LDADD = $(LDADD) @@ -376,10 +382,6 @@ swmr_reader_SOURCES = swmr_reader.c swmr_reader_OBJECTS = swmr_reader.$(OBJEXT) swmr_reader_LDADD = $(LDADD) swmr_reader_DEPENDENCIES = libh5test.la $(LIBHDF5) -swmr_writer_SOURCES = swmr_writer.c -swmr_writer_OBJECTS = swmr_writer.$(OBJEXT) -swmr_writer_LDADD = $(LDADD) -swmr_writer_DEPENDENCIES = libh5test.la $(LIBHDF5) swmr_remove_reader_SOURCES = swmr_remove_reader.c swmr_remove_reader_OBJECTS = swmr_remove_reader.$(OBJEXT) swmr_remove_reader_LDADD = $(LDADD) @@ -388,10 +390,6 @@ swmr_remove_writer_SOURCES = swmr_remove_writer.c swmr_remove_writer_OBJECTS = swmr_remove_writer.$(OBJEXT) swmr_remove_writer_LDADD = $(LDADD) swmr_remove_writer_DEPENDENCIES = libh5test.la $(LIBHDF5) -swmr_addrem_writer_SOURCES = swmr_addrem_writer.c -swmr_addrem_writer_OBJECTS = swmr_addrem_writer.$(OBJEXT) -swmr_addrem_writer_LDADD = $(LDADD) -swmr_addrem_writer_DEPENDENCIES = libh5test.la $(LIBHDF5) swmr_sparse_reader_SOURCES = swmr_sparse_reader.c swmr_sparse_reader_OBJECTS = swmr_sparse_reader.$(OBJEXT) swmr_sparse_reader_LDADD = $(LDADD) @@ -400,6 +398,10 @@ swmr_sparse_writer_SOURCES = swmr_sparse_writer.c swmr_sparse_writer_OBJECTS = swmr_sparse_writer.$(OBJEXT) swmr_sparse_writer_LDADD = $(LDADD) swmr_sparse_writer_DEPENDENCIES = libh5test.la $(LIBHDF5) +swmr_writer_SOURCES = swmr_writer.c +swmr_writer_OBJECTS = swmr_writer.$(OBJEXT) +swmr_writer_LDADD = $(LDADD) +swmr_writer_DEPENDENCIES = libh5test.la $(LIBHDF5) tcheck_version_SOURCES = tcheck_version.c tcheck_version_OBJECTS = tcheck_version.$(OBJEXT) tcheck_version_LDADD = $(LDADD) @@ -473,7 +475,9 @@ SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c bittests.c \ gen_udlinks.c getname.c gheap.c hyperslab.c istore.c lheap.c \ links.c links_env.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 swmr_remove_reader.c swmr_remove_writer.c swmr_addrem_writer.c swmr_sparse_reader.c swmr_sparse_writer.c tcheck_version.c \ + swmr_addrem_writer.c swmr_generator.c swmr_reader.c \ + swmr_remove_reader.c swmr_remove_writer.c swmr_sparse_reader.c \ + swmr_sparse_writer.c swmr_writer.c tcheck_version.c \ $(testhdf5_SOURCES) testmeta.c $(ttsafe_SOURCES) unlink.c \ vfd.c DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \ @@ -489,8 +493,10 @@ DIST_SOURCES = $(libh5test_la_SOURCES) accum.c app_ref.c big.c \ gen_specmetaread.c gen_udlinks.c getname.c gheap.c hyperslab.c \ istore.c lheap.c links.c links_env.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 swmr_remove_reader.c swmr_remove_writer.c swmr_addrem_writer.c swmr_sparse_reader.c swmr_sparse_writer.c tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ + space_overflow.c stab.c swmr_addrem_writer.c swmr_generator.c \ + swmr_reader.c swmr_remove_reader.c swmr_remove_writer.c \ + swmr_sparse_reader.c swmr_sparse_writer.c swmr_writer.c \ + tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ $(ttsafe_SOURCES) unlink.c vfd.c ETAGS = etags CTAGS = ctags @@ -562,6 +568,7 @@ F9XMODEXT = @F9XMODEXT@ F9XMODFLAG = @F9XMODFLAG@ F9XSUFFIXFLAG = @F9XSUFFIXFLAG@ FC = @FC@ +FC2003 = @FC2003@ FCFLAGS = @FCFLAGS@ FCFLAGS_f90 = @FCFLAGS_f90@ FCLIBS = @FCLIBS@ @@ -582,10 +589,12 @@ H5_LONE_COLON = @H5_LONE_COLON@ H5_VERSION = @H5_VERSION@ HADDR_T = @HADDR_T@ HAVE_DMALLOC = @HAVE_DMALLOC@ +HAVE_FORTRAN_2003 = @HAVE_FORTRAN_2003@ HDF5_HL = @HDF5_HL@ HDF5_INTERFACES = @HDF5_INTERFACES@ HDF_CXX = @HDF_CXX@ HDF_FORTRAN = @HDF_FORTRAN@ +HDF_FORTRAN2003 = @HDF_FORTRAN2003@ HID_T = @HID_T@ HL = @HL@ HL_FOR = @HL_FOR@ @@ -790,7 +799,7 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.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 stdio.h5 sec2.h5 \ - dtypes[1-8].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \ + dtypes[0-9].h5 dt_arith[1-2].h5 tattr.h5 tselect.h5 mtime.h5 \ unlink.h5 unicode.h5 coord.h5 fillval_[0-9].h5 fillval.raw \ mount_[0-9].h5 testmeta.h5 ttime.h5 trefer[1-3].h5 tvltypes.h5 \ tvlstr.h5 tvlstr2.h5 flush.h5 enum1.h5 titerate.h5 ttsafe.h5 \ @@ -803,7 +812,8 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \ tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \ objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \ app_ref.h5 farray.h5 earray.h5 efc[0-5].h5 log_vfd_out.log \ - swmr_data.h5 flushrefresh.h5 flushrefresh_VERIFICATION_START \ + new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 swmr_data.h5 \ + flushrefresh.h5 flushrefresh_VERIFICATION_START \ flushrefresh_VERIFICATION_CHECKPOINT1 \ flushrefresh_VERIFICATION_CHECKPOINT2 \ flushrefresh_VERIFICATION_DONE @@ -1199,30 +1209,30 @@ space_overflow$(EXEEXT): $(space_overflow_OBJECTS) $(space_overflow_DEPENDENCIES stab$(EXEEXT): $(stab_OBJECTS) $(stab_DEPENDENCIES) @rm -f stab$(EXEEXT) $(AM_V_CCLD)$(LINK) $(stab_OBJECTS) $(stab_LDADD) $(LIBS) +swmr_addrem_writer$(EXEEXT): $(swmr_addrem_writer_OBJECTS) $(swmr_addrem_writer_DEPENDENCIES) + @rm -f swmr_addrem_writer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(swmr_addrem_writer_OBJECTS) $(swmr_addrem_writer_LDADD) $(LIBS) swmr_generator$(EXEEXT): $(swmr_generator_OBJECTS) $(swmr_generator_DEPENDENCIES) @rm -f swmr_generator$(EXEEXT) $(AM_V_CCLD)$(LINK) $(swmr_generator_OBJECTS) $(swmr_generator_LDADD) $(LIBS) swmr_reader$(EXEEXT): $(swmr_reader_OBJECTS) $(swmr_reader_DEPENDENCIES) @rm -f swmr_reader$(EXEEXT) $(AM_V_CCLD)$(LINK) $(swmr_reader_OBJECTS) $(swmr_reader_LDADD) $(LIBS) -swmr_writer$(EXEEXT): $(swmr_writer_OBJECTS) $(swmr_writer_DEPENDENCIES) - @rm -f swmr_writer$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(swmr_writer_OBJECTS) $(swmr_writer_LDADD) $(LIBS) -swmr_remove_reader$(EXEEXT): $(swmr_remove_reader_OBJECTS) $(swmr_remove_reader_DEPENDENCIES) +swmr_remove_reader$(EXEEXT): $(swmr_remove_reader_OBJECTS) $(swmr_remove_reader_DEPENDENCIES) @rm -f swmr_remove_reader$(EXEEXT) $(AM_V_CCLD)$(LINK) $(swmr_remove_reader_OBJECTS) $(swmr_remove_reader_LDADD) $(LIBS) -swmr_remove_writer$(EXEEXT): $(swmr_remove_writer_OBJECTS) $(swmr_remove_writer_DEPENDENCIES) +swmr_remove_writer$(EXEEXT): $(swmr_remove_writer_OBJECTS) $(swmr_remove_writer_DEPENDENCIES) @rm -f swmr_remove_writer$(EXEEXT) $(AM_V_CCLD)$(LINK) $(swmr_remove_writer_OBJECTS) $(swmr_remove_writer_LDADD) $(LIBS) -swmr_addrem_writer$(EXEEXT): $(swmr_addrem_writer_OBJECTS) $(swmr_addrem_writer_DEPENDENCIES) - @rm -f swmr_addrem_writer$(EXEEXT) - $(AM_V_CCLD)$(LINK) $(swmr_addrem_writer_OBJECTS) $(swmr_addrem_writer_LDADD) $(LIBS) -swmr_sparse_reader$(EXEEXT): $(swmr_sparse_reader_OBJECTS) $(swmr_sparse_reader_DEPENDENCIES) +swmr_sparse_reader$(EXEEXT): $(swmr_sparse_reader_OBJECTS) $(swmr_sparse_reader_DEPENDENCIES) @rm -f swmr_sparse_reader$(EXEEXT) $(AM_V_CCLD)$(LINK) $(swmr_sparse_reader_OBJECTS) $(swmr_sparse_reader_LDADD) $(LIBS) -swmr_sparse_writer$(EXEEXT): $(swmr_sparse_writer_OBJECTS) $(swmr_sparse_writer_DEPENDENCIES) +swmr_sparse_writer$(EXEEXT): $(swmr_sparse_writer_OBJECTS) $(swmr_sparse_writer_DEPENDENCIES) @rm -f swmr_sparse_writer$(EXEEXT) $(AM_V_CCLD)$(LINK) $(swmr_sparse_writer_OBJECTS) $(swmr_sparse_writer_LDADD) $(LIBS) +swmr_writer$(EXEEXT): $(swmr_writer_OBJECTS) $(swmr_writer_DEPENDENCIES) + @rm -f swmr_writer$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(swmr_writer_OBJECTS) $(swmr_writer_LDADD) $(LIBS) tcheck_version$(EXEEXT): $(tcheck_version_OBJECTS) $(tcheck_version_DEPENDENCIES) @rm -f tcheck_version$(EXEEXT) $(AM_V_CCLD)$(LINK) $(tcheck_version_OBJECTS) $(tcheck_version_LDADD) $(LIBS) @@ -1315,15 +1325,15 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/set_extent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/space_overflow.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stab.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_addrem_writer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_common.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_generator.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_reader.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_writer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_remove_reader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_remove_writer.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_addrem_writer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_sparse_reader.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_sparse_writer.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/swmr_writer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tarray.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tattr.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tcheck_version.Po@am__quote@ diff --git a/test/be_data.h5 b/test/be_data.h5 Binary files differindex 0feefa3..e6629d3 100644 --- a/test/be_data.h5 +++ b/test/be_data.h5 @@ -22,14 +22,14 @@ /* * The purpose of this test is to verify if a virtual file driver can handle: * a. Large file (2GB) - * This should exceed 32bits I/O system since offset is a signed - * integral type (in order to support negative offset with respect to - * end of file). + * This should exceed 32bits I/O system since offset is a signed + * integral type (in order to support negative offset with respect to + * end of file). * b. Extra Large file (4GB) - * This definite exceeds 32bit I/O and file systems. + * This definite exceeds 32bit I/O and file systems. * c. Huge file (tens of GB) - * This verifies the HDF5 library handles big logical file size - * correctly. + * This verifies the HDF5 library handles big logical file size + * correctly. * In practice, if a VFD can handle a big file size, there is no need to * test the smaller file sizes. E.g., If it can handle the Huge file, * there is no need to test the Extra large or Large files. Therefore the @@ -81,15 +81,15 @@ typedef enum vfd_t { SEC2_VFD, STDIO_VFD, FAMILY_VFD } vfd_t; fsizes_t file_size= NOFILE; const char *FILENAME[] = { - "big", - "sec2", - "stdio", - NULL + "big", + "sec2", + "stdio", + NULL }; -int cflag=1; /* check file system before test */ -int sparse_support=0; /* sparse file supported, default false */ -int have_space=0; /* enough space for huge file test, default false */ -hsize_t family_size_def=FAMILY_SIZE; /* default family file size */ +int cflag=1; /* check file system before test */ +int sparse_support=0; /* sparse file supported, default false */ +int have_space=0; /* enough space for huge file test, default false */ +hsize_t family_size_def=FAMILY_SIZE; /* default family file size */ /* Protocols */ static void usage(void); @@ -216,55 +216,55 @@ supports_big(vfd_t vfd) case FAMILY_VFD: case SEC2_VFD: case STDIO_VFD: - if ((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) - goto error; - - /* Write a few byte at the beginning */ - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = SFILE; - - /* Write a few bytes at 2GB */ - if (HDlseek(fd, 2*GB, SEEK_SET)!=2*GB) - goto quit; - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = LFILE; - - /* Write a few bytes at 4GB */ - if (HDlseek(fd, 4*GB, SEEK_SET) != 4*GB) - goto quit; - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = XLFILE; - - /* If this supports sparse_file, write a few bytes at 32GB */ - if (!sparse_support) - goto quit; - if (HDlseek(fd, 32*GB, SEEK_SET) != 32*GB) - goto quit; - if (5!=HDwrite(fd, "hello", (size_t)5)) - goto quit; - fsize = HUGEFILE; - - break; + if ((fd=HDopen("y.h5", O_RDWR|O_TRUNC|O_CREAT, 0666)) < 0) + goto error; + + /* Write a few byte at the beginning */ + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = SFILE; + + /* Write a few bytes at 2GB */ + if (HDlseek(fd, 2*GB, SEEK_SET)!=2*GB) + goto quit; + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = LFILE; + + /* Write a few bytes at 4GB */ + if (HDlseek(fd, 4*GB, SEEK_SET) != 4*GB) + goto quit; + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = XLFILE; + + /* If this supports sparse_file, write a few bytes at 32GB */ + if (!sparse_support) + goto quit; + if (HDlseek(fd, 32*GB, SEEK_SET) != 32*GB) + goto quit; + if (5!=HDwrite(fd, "hello", (size_t)5)) + goto quit; + fsize = HUGEFILE; + + break; default: - /* unknown or unsupported VFD */ - goto error; - break; + /* unknown or unsupported VFD */ + goto error; + break; } - + quit: if (HDclose(fd) < 0) - goto error; + goto error; if (HDremove("y.h5") < 0) - goto error; + goto error; return(fsize); error: if (fd >= 0){ - HDclose(fd); - HDremove("y.h5"); + HDclose(fd); + HDremove("y.h5"); } return (fsize); } @@ -300,30 +300,30 @@ enough_room(hid_t fapl) for (i=0; i<NELMTS(fd); i++) fd[i] = -1; /* Get file name template */ - assert(H5FD_FAMILY==H5Pget_driver(fapl)); + HDassert(H5FD_FAMILY==H5Pget_driver(fapl)); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); /* Create files */ for (i=0; i<NELMTS(fd); i++) { - HDsnprintf(name, sizeof name, filename, i); - if ((fd[i]=HDopen(name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) { - goto done; - } - if ((off_t)size != HDlseek(fd[i], (off_t)size, SEEK_SET)) { - goto done; - } - if (1!=HDwrite(fd[i], "X", (size_t)1)) { - goto done; - } + HDsnprintf(name, sizeof name, filename, i); + if ((fd[i]=HDopen(name, O_RDWR|O_CREAT|O_TRUNC, 0666)) < 0) { + goto done; + } + if ((off_t)size != HDlseek(fd[i], (off_t)size, SEEK_SET)) { + goto done; + } + if (1!=HDwrite(fd[i], "X", (size_t)1)) { + goto done; + } } ret_value = 1; - done: +done: for (i=0; i<NELMTS(fd) && fd[i]>=0; i++) { - HDsnprintf(name, sizeof name, filename, i); - if(HDclose(fd[i]) < 0) + HDsnprintf(name, sizeof name, filename, i); + if(HDclose(fd[i]) < 0) ret_value=0; - HDremove(name); + HDremove(name); } return ret_value; @@ -356,43 +356,43 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) hsize_t hs_start[1]; hsize_t hs_size[1]; hid_t file=-1, space1=-1, space2=-1, mem_space=-1, d1=-1, d2=-1; - int *buf = (int*)malloc (sizeof(int) * WRT_SIZE); + int *buf = (int*)HDmalloc (sizeof(int) * WRT_SIZE); int i, j; - FILE *out = fopen(DNAME, "w"); + FILE *out = HDfopen(DNAME, "w"); hid_t dcpl; switch(testsize){ case LFILE: - TESTING("Large dataset write(2GB)"); - /* reduce size1 to produce a 2GB dataset */ - size1[1] = 1024/16; - size2[0] /= 16; - break; + TESTING("Large dataset write(2GB)"); + /* reduce size1 to produce a 2GB dataset */ + size1[1] = 1024/16; + size2[0] /= 16; + break; case XLFILE: - TESTING("Extra large dataset write(4GB)"); - /* reduce size1 to produce a 4GB dataset */ - size1[1] = 1024/8; - size2[0] /= 8; - break; + TESTING("Extra large dataset write(4GB)"); + /* reduce size1 to produce a 4GB dataset */ + size1[1] = 1024/8; + size2[0] /= 8; + break; case HUGEFILE: - TESTING("Huge dataset write"); - /* Leave size1 as 32GB */ - break; + TESTING("Huge dataset write"); + /* Leave size1 as 32GB */ + break; case SFILE: - TESTING("small dataset write(1GB)"); - /* reduce size1 to produce a 1GB dataset */ - size1[1] = 1024/32; - size2[0] /= 32; - break; + TESTING("small dataset write(1GB)"); + /* reduce size1 to produce a 1GB dataset */ + size1[1] = 1024/32; + size2[0] /= 32; + break; case NOFILE: - /* what to do?? */ - HDfprintf(stdout, "Unexpected file size of NOFILE\n"); - goto error; - break; + /* what to do?? */ + HDfprintf(stdout, "Unexpected file size of NOFILE\n"); + goto error; + break; } /* @@ -400,30 +400,30 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) * which is a family of files. Each member of the family will be 1GB */ if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { - goto error; + goto error; } /* Create simple data spaces according to the size specified above. */ if ((space1 = H5Screate_simple (4, size1, size1)) < 0 || - (space2 = H5Screate_simple (1, size2, size2)) < 0) { - goto error; + (space2 = H5Screate_simple (1, size2, size2)) < 0) { + goto error; } /* Create the datasets */ -/* - * The fix below is provided for bug#921 - * H5Dcreate with H5P_DEFAULT creation properties - * will create a set of solid 1GB files; test will crash if quotas are enforced - * or it will take some time to write a file. - * We should create a dataset allocating space late and never writing fill values. - * EIP 4/8/03 -*/ + /* + * The fix below is provided for bug#921 + * H5Dcreate with H5P_DEFAULT creation properties + * will create a set of solid 1GB files; test will crash if quotas are enforced + * or it will take some time to write a file. + * We should create a dataset allocating space late and never writing fill values. + * EIP 4/8/03 + */ dcpl = H5Pcreate(H5P_DATASET_CREATE); H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE); H5Pset_fill_time(dcpl, H5D_FILL_TIME_NEVER); if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, space1, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0 || - (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { - goto error; + (d2 = H5Dcreate2(file, "d2", H5T_NATIVE_INT, space2, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) { + goto error; } @@ -431,15 +431,15 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) hs_size[0] = WRT_SIZE; if ((mem_space = H5Screate_simple (1, hs_size, hs_size)) < 0) goto error; for (i=0; i<wrt_n; i++) { - hs_start[0] = randll (size2[0], i); - HDfprintf (out, "#%03d 0x%016Hx\n", i, hs_start[0]); - if (H5Sselect_hyperslab (space2, H5S_SELECT_SET, hs_start, NULL, - hs_size, NULL) < 0) goto error; - for (j=0; j<WRT_SIZE; j++) { - buf[j] = i+1; - } - if (H5Dwrite (d2, H5T_NATIVE_INT, mem_space, space2, - H5P_DEFAULT, buf) < 0) goto error; + hs_start[0] = randll (size2[0], i); + HDfprintf (out, "#%03d 0x%016Hx\n", i, hs_start[0]); + if (H5Sselect_hyperslab (space2, H5S_SELECT_SET, hs_start, NULL, + hs_size, NULL) < 0) goto error; + for (j=0; j<WRT_SIZE; j++) { + buf[j] = i+1; + } + if (H5Dwrite (d2, H5T_NATIVE_INT, mem_space, space2, + H5P_DEFAULT, buf) < 0) goto error; } if (H5Dclose (d1) < 0) goto error; @@ -448,22 +448,22 @@ writer (char* filename, hid_t fapl, fsizes_t testsize, int wrt_n) if (H5Sclose (space1) < 0) goto error; if (H5Sclose (space2) < 0) goto error; if (H5Fclose (file) < 0) goto error; - free (buf); - fclose(out); + HDfree (buf); + HDfclose(out); PASSED(); return 0; - error: +error: H5E_BEGIN_TRY { - H5Dclose(d1); - H5Dclose(d2); - H5Sclose(space1); - H5Sclose(space2); - H5Sclose(mem_space); - H5Fclose(file); + H5Dclose(d1); + H5Dclose(d2); + H5Sclose(space1); + H5Sclose(space2); + H5Sclose(mem_space); + H5Fclose(file); } H5E_END_TRY; - if (buf) free(buf); - if (out) fclose(out); + if (buf) HDfree(buf); + if (out) HDfclose(out); return 1; } @@ -492,11 +492,11 @@ reader(char *filename, hid_t fapl) char ln[128], *s; hsize_t hs_offset[1]; hsize_t hs_size[1] = {WRT_SIZE}; - int *buf = (int *)malloc(sizeof(int) * WRT_SIZE); + int *buf = (int *)HDmalloc(sizeof(int) * WRT_SIZE); int i, j, zero, wrong, nerrors = 0; /* Open script file */ - script = fopen(DNAME, "r"); + script = HDfopen(DNAME, "r"); /* Open HDF5 file */ if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR @@ -509,58 +509,58 @@ reader(char *filename, hid_t fapl) if((mspace = H5Screate_simple(1, hs_size, hs_size)) < 0) FAIL_STACK_ERROR /* Read each region */ - while(fgets(ln, (int)sizeof(ln), script)) { - if('#' != ln[0]) + while(HDfgets(ln, (int)sizeof(ln), script)) { + if('#' != ln[0]) break; - i = (int)strtol(ln + 1, &s, 10); - hs_offset[0] = HDstrtoll(s, NULL, 0); - HDfprintf(stdout, "#%03d 0x%016Hx%47s", i, hs_offset[0], ""); - fflush(stdout); - - if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, - hs_size, NULL) < 0) FAIL_STACK_ERROR - if(H5Dread(d2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) - FAIL_STACK_ERROR - - /* Check */ - for(j = zero = wrong = 0; j < WRT_SIZE; j++) { - if(0 == buf[j]) - zero++; - else if(buf[j] != i + 1) - wrong++; - } - if(zero) { - H5_FAILED(); - printf(" %d zero%s\n", zero, 1 == zero ? "" : "s"); - } else if(wrong) { - SKIPPED(); - puts(" Possible overlap with another region."); - nerrors++; - } else { - PASSED(); - } + i = (int)HDstrtol(ln + 1, &s, 10); + hs_offset[0] = HDstrtoll(s, NULL, 0); + HDfprintf(stdout, "#%03d 0x%016Hx%47s", i, hs_offset[0], ""); + HDfflush(stdout); + + if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, NULL, + hs_size, NULL) < 0) FAIL_STACK_ERROR + if(H5Dread(d2, H5T_NATIVE_INT, mspace, fspace, H5P_DEFAULT, buf) < 0) + FAIL_STACK_ERROR + + /* Check */ + for(j = zero = wrong = 0; j < WRT_SIZE; j++) { + if(0 == buf[j]) + zero++; + else if(buf[j] != i + 1) + wrong++; + } + if(zero) { + H5_FAILED(); + printf(" %d zero%s\n", zero, 1 == zero ? "" : "s"); + } else if(wrong) { + SKIPPED(); + HDputs(" Possible overlap with another region."); + nerrors++; + } else { + PASSED(); + } } if(H5Dclose(d2) < 0) FAIL_STACK_ERROR - if(H5Sclose(mspace) < 0) FAIL_STACK_ERROR - if(H5Sclose(fspace) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR - free(buf); - fclose(script); + if(H5Sclose(mspace) < 0) FAIL_STACK_ERROR + if(H5Sclose(fspace) < 0) FAIL_STACK_ERROR + if(H5Fclose(file) < 0) FAIL_STACK_ERROR + HDfree(buf); + HDfclose(script); return nerrors; error: H5E_BEGIN_TRY { - H5Dclose(d2); - H5Sclose(mspace); - H5Sclose(fspace); - H5Fclose(file); + H5Dclose(d2); + H5Sclose(mspace); + H5Sclose(fspace); + H5Fclose(file); } H5E_END_TRY; if(buf) - free(buf); + HDfree(buf); if(script) - fclose(script); + HDfclose(script); return 1; } @@ -584,21 +584,21 @@ static void usage(void) { HDfprintf(stdout, - "Usage: big [-h] [-c] [-fsize <fsize>}\n" - "\t-h\tPrint the help page\n" - "\t-c\tFile system Checking skipped. Caution: this test generates\n" - "\t\tmany big files and may fill up the file system.\n" - "\t-fsize\tChange family size default to <fsize> where <fsize> is\n" - "\t\ta positive float point number. Default value is %Hu.\n" - "Examples:\n" - "\tbig -fsize 2.1e9 \t# test with file size just under 2GB\n" - "\tbig -fsize 2.2e9 \t# test with file size just above 2GB\n" - "\tBe sure the file system can support the file size requested\n" - , (hsize_t)FAMILY_SIZE); + "Usage: big [-h] [-c] [-fsize <fsize>}\n" + "\t-h\tPrint the help page\n" + "\t-c\tFile system Checking skipped. Caution: this test generates\n" + "\t\tmany big files and may fill up the file system.\n" + "\t-fsize\tChange family size default to <fsize> where <fsize> is\n" + "\t\ta positive float point number. Default value is %Hu.\n" + "Examples:\n" + "\tbig -fsize 2.1e9 \t# test with file size just under 2GB\n" + "\tbig -fsize 2.2e9 \t# test with file size just above 2GB\n" + "\tBe sure the file system can support the file size requested\n" + , (hsize_t)FAMILY_SIZE); } - + /* Flush stdout at the end of this test routine to ensure later output to */ /* stderr will not come out before it.*/ int testvfd(vfd_t vfd) @@ -611,107 +611,107 @@ int testvfd(vfd_t vfd) switch(vfd){ case FAMILY_VFD: - /* Test huge file with the family driver */ - puts("Testing big file with the Family Driver "); - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - - if (H5Pset_fapl_family(fapl, family_size_def, H5P_DEFAULT) < 0) - goto error; - - if (cflag){ - /* - * We shouldn't run this test if the file system doesn't support holes - * because we would generate multi-gigabyte files. - */ - puts("Checking if file system is adequate for this test..."); - if (sizeof(long long)<8 || 0==GB8LL) { - puts("Test skipped because sizeof(long long) is too small. This"); - puts("hardware apparently doesn't support 64-bit integer types."); - usage(); - goto quit; - } - if (!sparse_support) { - puts("Test skipped because file system does not support holes."); - usage(); - goto quit; - } - if (!enough_room(fapl)) { - puts("Test skipped because of quota (file size or num open files)."); - usage(); - goto quit; - } - } - - /* Do the test with the Family Driver */ - h5_fixname(FILENAME[0], fapl, filename, sizeof filename); - - if (writer(filename, fapl, HUGEFILE, WRT_N)) goto error; - if (reader(filename, fapl)) goto error; - - puts("Test passed with the Family Driver."); - break; + /* Test huge file with the family driver */ + HDputs("Testing big file with the Family Driver "); + if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + + if (H5Pset_fapl_family(fapl, family_size_def, H5P_DEFAULT) < 0) + goto error; + + if (cflag){ + /* + * We shouldn't run this test if the file system doesn't support holes + * because we would generate multi-gigabyte files. + */ + HDputs("Checking if file system is adequate for this test..."); + if (sizeof(long long)<8 || 0==GB8LL) { + HDputs("Test skipped because sizeof(long long) is too small. This"); + HDputs("hardware apparently doesn't support 64-bit integer types."); + usage(); + goto quit; + } + if (!sparse_support) { + HDputs("Test skipped because file system does not support holes."); + usage(); + goto quit; + } + if (!enough_room(fapl)) { + HDputs("Test skipped because of quota (file size or num open files)."); + usage(); + goto quit; + } + } + + /* Do the test with the Family Driver */ + h5_fixname(FILENAME[0], fapl, filename, sizeof filename); + + if (writer(filename, fapl, HUGEFILE, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; + + HDputs("Test passed with the Family Driver."); + break; case SEC2_VFD: - testsize = supports_big(SEC2_VFD); - if (testsize == NOFILE) { - HDfprintf(stdout, "Test for sec2 is skipped because file system does not support big files.\n"); - goto quit; - } - /* Test big file with the SEC2 driver */ - puts("Testing big file with the SEC2 Driver "); + testsize = supports_big(SEC2_VFD); + if (testsize == NOFILE) { + HDfprintf(stdout, "Test for sec2 is skipped because file system does not support big files.\n"); + goto quit; + } + /* Test big file with the SEC2 driver */ + HDputs("Testing big file with the SEC2 Driver "); - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - if(H5Pset_fapl_sec2(fapl) < 0) - goto error; + if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_sec2(fapl) < 0) + goto error; - h5_fixname(FILENAME[1], fapl, filename, sizeof filename); + h5_fixname(FILENAME[1], fapl, filename, sizeof filename); - if (writer(filename, fapl, testsize, WRT_N)) goto error; - if (reader(filename, fapl)) goto error; + if (writer(filename, fapl, testsize, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; - puts("Test passed with the SEC2 Driver."); - break; + HDputs("Test passed with the SEC2 Driver."); + break; case STDIO_VFD: - testsize = supports_big(STDIO_VFD); - if (testsize == NOFILE) { - HDfprintf(stdout, "Test for stdio is skipped because file system does not support big files.\n"); - goto quit; - } - puts("\nTesting big file with the STDIO Driver "); + testsize = supports_big(STDIO_VFD); + if (testsize == NOFILE) { + HDfprintf(stdout, "Test for stdio is skipped because file system does not support big files.\n"); + goto quit; + } + HDputs("\nTesting big file with the STDIO Driver "); - if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) - goto error; - if(H5Pset_fapl_stdio(fapl) < 0) - goto error; + if ((fapl=H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_stdio(fapl) < 0) + goto error; - h5_fixname(FILENAME[2], fapl, filename, sizeof filename); + h5_fixname(FILENAME[2], fapl, filename, sizeof filename); - if (writer(filename, fapl, testsize, WRT_N)) goto error; - if (reader(filename, fapl)) goto error; - puts("Test passed with the STDIO Driver."); - break; + if (writer(filename, fapl, testsize, WRT_N)) goto error; + if (reader(filename, fapl)) goto error; + HDputs("Test passed with the STDIO Driver."); + break; default: - puts("Unsupprted VFD"); - usage(); - goto error;; + HDputs("Unsupprted VFD"); + usage(); + goto error;; } /* end of switch (vfd) */ quit: /* End with normal return code */ /* Clean up the test file */ if (h5_cleanup(FILENAME, fapl)) HDremove(DNAME); - fflush(stdout); + HDfflush(stdout); return 0; error: if (fapl>=0) H5Pclose(fapl); - puts("*** TEST FAILED ***"); - fflush(stdout); + HDputs("*** TEST FAILED ***"); + HDfflush(stdout); return 1; } @@ -748,58 +748,58 @@ main (int ac, char **av) /* parameters setup */ while (--ac > 0){ - av++; - if (strcmp("-fsize", *av)==0){ - /* specify a different family file size */ - ac--; av++; - if (ac > 0) { - family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0); - } - else{ - printf("***Missing fsize value***\n"); - usage(); - return 1; - } - } - else if (strcmp("-c", *av)==0){ - /* turn off file system check before test */ - cflag=0; - } - else if (strcmp("-h", *av)==0){ - usage(); - return 0; - }else{ - usage(); - return 1; - } + av++; + if (HDstrcmp("-fsize", *av)==0){ + /* specify a different family file size */ + ac--; av++; + if (ac > 0) { + family_size_def = (hsize_t)HDstrtoull(*av, NULL, 0); + } + else{ + printf("***Missing fsize value***\n"); + usage(); + return 1; + } + } + else if (HDstrcmp("-c", *av)==0){ + /* turn off file system check before test */ + cflag=0; + } + else if (HDstrcmp("-h", *av)==0){ + usage(); + return 0; + }else{ + usage(); + return 1; + } } /* check sparse file support unless cflag is not set. */ if (cflag) - sparse_support = is_sparse(); + sparse_support = is_sparse(); /* Choose random # seed */ seed = (unsigned long)HDtime(NULL); #ifdef QAK -/* seed = (unsigned long)1155438845; */ -HDfprintf(stderr, "Random # seed was: %lu\n", seed); + /* seed = (unsigned long)1155438845; */ + HDfprintf(stderr, "Random # seed was: %lu\n", seed); #endif /* QAK */ HDsrandom(seed); -/*=================================================*/ + /*=================================================*/ if (testvfd(FAMILY_VFD) != 0) - goto error; + goto error; if (testvfd(SEC2_VFD) != 0) - goto error; + goto error; if (testvfd(STDIO_VFD) != 0) - goto error; + goto error; /* End with normal exit code */ return 0; error: - puts("*** TEST FAILED ***"); + HDputs("*** TEST FAILED ***"); return 1; } diff --git a/test/cross_read.c b/test/cross_read.c index 6588031..308a0c1 100755 --- a/test/cross_read.c +++ b/test/cross_read.c @@ -17,7 +17,7 @@ * Programmer: Raymond Lu <slu@ncsa.uiuc.edu> * Thursday, March 23, 2006 * - * Purpose: Check if floating-point data created on OpenVMS, big-endian, and + * Purpose: Check if floating-point data created on big-endian and * little-endian machines can be read on the machine running this test. */ @@ -31,7 +31,8 @@ const char *FILENAME[] = { NULL }; -#define DATASETNAME "Array" +#define DATASETNAME "Array_le" +#define DATASETNAME1 "Array_be" #define DATASETNAME2 "Scale_offset_float_data_le" #define DATASETNAME3 "Scale_offset_float_data_be" #define DATASETNAME4 "Scale_offset_double_data_le" @@ -44,94 +45,112 @@ const char *FILENAME[] = { #define DATASETNAME11 "Scale_offset_int_data_be" #define DATASETNAME12 "Scale_offset_long_long_data_le" #define DATASETNAME13 "Scale_offset_long_long_data_be" + +#define DATASETNAME14 "Fletcher_float_data_le" +#define DATASETNAME15 "Fletcher_float_data_be" +#define DATASETNAME16 "Deflate_float_data_le" +#define DATASETNAME17 "Deflate_float_data_be" +#define DATASETNAME18 "Szip_float_data_le" +#define DATASETNAME19 "Szip_float_data_be" +#define DATASETNAME20 "Shuffle_float_data_le" +#define DATASETNAME21 "Shuffle_float_data_be" +#define DATASETNAME22 "Nbit_float_data_le" +#define DATASETNAME23 "Nbit_float_data_be" + #define NX 6 #define NY 6 /*------------------------------------------------------------------------- - * Function: read_data + * Function: open_dataset * - * Purpose: Read data from a data file. + * Purpose: Read and compare the data from a dataset. * * Return: Success: 0 - * Failure: -1 + * Failure: 1 * * Programmer: Raymond Lu - * 21 January 2011 + * 17 May 2011 * * Modifications: * *------------------------------------------------------------------------- */ -static int read_data(char *fname) +static int check_data(const char *dsetname, hid_t fid, hbool_t floating_number) { - const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */ - hid_t file, dataset; /* handles */ + hid_t dataset; /* handles */ double data_in[NX+1][NY]; /* input buffer */ double data_out[NX+1][NY]; /* output buffer */ long long int_data_in[NX+1][NY]; /* input buffer */ long long int_data_out[NX+1][NY]; /* output buffer */ int i, j; unsigned nerrors = 0; - const char *not_supported= " Scaleoffset filter is not enabled."; - - /* - * Open the file. - */ - if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - TEST_ERROR; - - TESTING("regular dataset"); /* * Open the regular dataset. */ - if((dataset = H5Dopen2(file, DATASETNAME, H5P_DEFAULT)) < 0) + if((dataset = H5Dopen2(fid, dsetname, H5P_DEFAULT)) < 0) TEST_ERROR; /* * Data and output buffer initialization. */ for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - data_in[j][i] = i + j; - data_out[j][i] = 0; + for (i = 0; i < NY; i++) { + data_in[j][i] = ((double)(i + j + 1))/3; + data_out[j][i] = 0; + + int_data_in[j][i] = i + j; + int_data_out[j][i] = 0; } } for (i = 0; i < NY; i++) { data_in[NX][i] = -2.2; data_out[NX][i] = 0; + + int_data_in[NX][i] = -2; + int_data_out[NX][i] = 0; } - /* - * 0 1 2 3 4 5 - * 1 2 3 4 5 6 - * 2 3 4 5 6 7 - * 3 4 5 6 7 8 - * 4 5 6 7 8 9 - * 5 6 7 8 9 10 - * -2.2 -2.2 -2.2 -2.2 -2.2 -2.2 - */ /* * Read data from hyperslab in the file into the hyperslab in * memory and display. */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - /* if (data_out[j][i] != data_in[j][i]) { */ - if (!FLT_ABS_EQUAL(data_out[j][i], data_in[j][i])) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %g but should have been %g\n", - j, i, data_out[j][i], data_in[j][i]); - } - } - } + if(floating_number) { + if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, + data_out) < 0) + TEST_ERROR; + + /* Check results */ + for (j=0; j<(NX+1); j++) { + for (i=0; i<NY; i++) { + if (!DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001)) { + if (!nerrors++) { + H5_FAILED(); + printf("element [%d][%d] is %g but should have been %g\n", + j, i, data_out[j][i], data_in[j][i]); + } + } + } + } + } else { + if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, + int_data_out) < 0) + TEST_ERROR; + + /* Check results */ + for (j=0; j<(NX+1); j++) { + for (i=0; i<NY; i++) { + if (int_data_out[j][i] != int_data_in[j][i]) { + if (!nerrors++) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been %d\n", + j, i, (int)int_data_out[j][i], + (int)int_data_in[j][i]); + } + } + } + } } /* @@ -147,766 +166,225 @@ static int read_data(char *fname) } PASSED(); + return 0; - TESTING("dataset of LE FLOAT with scale-offset filter"); - -#ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME2, H5P_DEFAULT)) < 0) - TEST_ERROR; +error: + H5E_BEGIN_TRY { + H5Dclose(dataset); + } H5E_END_TRY; + return 1; +} - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - data_in[j][i] = ((double)(i + j + 1))/3; - data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - data_in[NX][i] = -2.2; - data_out[NX][i] = 0; - } + +/*------------------------------------------------------------------------- + * Function: open_dataset + * + * Purpose: Handle each dataset from the data file. + * + * Return: Success: 0 + * Failure: Number of failures + * + * Programmer: Raymond Lu + * 21 January 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int open_dataset(char *fname) +{ + const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */ + hid_t file; /* handles */ + unsigned nerrors = 0; + const char *not_supported= " filter is not enabled."; /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. + * Open the file. */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data_out) < 0) + if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR; - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (!DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001)) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %g but should have been %g\n", - j, i, data_out[j][i], data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR + TESTING("regular dataset of LE DOUBLE"); + nerrors += check_data(DATASETNAME, file, TRUE); - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } + TESTING("regular dataset of BE DOUBLE"); + nerrors += check_data(DATASETNAME1, file, TRUE); - PASSED(); + TESTING("dataset of LE FLOAT with scale-offset filter"); +#ifdef H5_HAVE_FILTER_SCALEOFFSET + nerrors += check_data(DATASETNAME2, file, TRUE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of BE FLOAT with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME3, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - data_in[j][i] = ((double)(i + j + 1))/3; - data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - data_in[NX][i] = -2.2; - data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (!DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001)) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %g but should have been %g\n", - j, i, data_out[j][i], data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); + nerrors += check_data(DATASETNAME3, file, TRUE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ TESTING("dataset of LE DOUBLE with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME4, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - data_in[j][i] = ((double)(i + j + 1))/3; - data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - data_in[NX][i] = -2.2; - data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (!DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001)) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %g but should have been %g\n", - j, i, data_out[j][i], data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); + nerrors += check_data(DATASETNAME4, file, TRUE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of BE DOUBLE with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME5, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - data_in[j][i] = ((double)(i + j + 1))/3; - data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - data_in[NX][i] = -2.2; - data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, - data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (!DBL_REL_EQUAL(data_out[j][i], data_in[j][i], 0.001)) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %g but should have been %g\n", - j, i, data_out[j][i], data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); + nerrors += check_data(DATASETNAME5, file, TRUE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of LE CHAR with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME6, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME6, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of BE CHAR with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME7, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME7, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of LE SHORT with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME8, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME8, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of BE SHORT with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME9, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME9, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ TESTING("dataset of LE INT with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME10, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME10, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of BE INT with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME11, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME11, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ TESTING("dataset of LE LONG LONG with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME12, H5P_DEFAULT)) < 0) - TEST_ERROR; - - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } - - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; - - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } - - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR - - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } - - PASSED(); - + nerrors += check_data(DATASETNAME12, file, FALSE); #else /*H5_HAVE_FILTER_SCALEOFFSET*/ SKIPPED(); puts(not_supported); #endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - + TESTING("dataset of BE LONG LONG with scale-offset filter"); - #ifdef H5_HAVE_FILTER_SCALEOFFSET - /* - * Open the dataset with scale-offset filter. - */ - if((dataset = H5Dopen2(file, DATASETNAME13, H5P_DEFAULT)) < 0) - TEST_ERROR; + nerrors += check_data(DATASETNAME13, file, FALSE); +#else /*H5_HAVE_FILTER_SCALEOFFSET*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_SCALEOFFSET*/ - /* - * Data and output buffer initialization. - */ - for (j = 0; j < NX; j++) { - for (i = 0; i < NY; i++) { - int_data_in[j][i] = i + j; - int_data_out[j][i] = 0; - } - } - for (i = 0; i < NY; i++) { - int_data_in[NX][i] = -2; - int_data_out[NX][i] = 0; - } + TESTING("dataset of LE FLOAT with Fletcher32 filter"); +#ifdef H5_HAVE_FILTER_FLETCHER32 + nerrors += check_data(DATASETNAME14, file, TRUE); +#else /*H5_HAVE_FILTER_FLETCHER32*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_FLETCHER32*/ + + TESTING("dataset of BE FLOAT with Fletcher32 filter"); +#ifdef H5_HAVE_FILTER_FLETCHER32 + nerrors += check_data(DATASETNAME15, file, TRUE); +#else /*H5_HAVE_FILTER_FLETCHER32*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_FLETCHER32*/ + + TESTING("dataset of LE FLOAT with Deflate filter"); +#ifdef H5_HAVE_FILTER_DEFLATE + nerrors += check_data(DATASETNAME16, file, TRUE); +#else /*H5_HAVE_FILTER_DEFLATE*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_DEFLATE*/ - /* - * Read data from hyperslab in the file into the hyperslab in - * memory and display. - */ - if(H5Dread(dataset, H5T_NATIVE_LLONG, H5S_ALL, H5S_ALL, H5P_DEFAULT, - int_data_out) < 0) - TEST_ERROR; + TESTING("dataset of BE FLOAT with Deflate filter"); +#ifdef H5_HAVE_FILTER_DEFLATE + nerrors += check_data(DATASETNAME17, file, TRUE); +#else /*H5_HAVE_FILTER_DEFLATE*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_DEFLATE*/ - /* Check results */ - for (j=0; j<(NX+1); j++) { - for (i=0; i<NY; i++) { - if (int_data_out[j][i] != int_data_in[j][i]) { - if (!nerrors++) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been %d\n", - j, i, (int)int_data_out[j][i], - (int)int_data_in[j][i]); - } - } - } - } + TESTING("dataset of LE FLOAT with Szip filter"); +#ifdef H5_HAVE_FILTER_SZIP + nerrors += check_data(DATASETNAME18, file, TRUE); +#else /*H5_HAVE_FILTER_SZIP*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_SZIP*/ - /* - * Close/release resources. - */ - if(H5Dclose(dataset) < 0) - TEST_ERROR + TESTING("dataset of BE FLOAT with Szip filter"); +#ifdef H5_HAVE_FILTER_SZIP + nerrors += check_data(DATASETNAME19, file, TRUE); +#else /*H5_HAVE_FILTER_SZIP*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_SZIP*/ - /* Failure */ - if (nerrors) { - printf("total of %d errors out of %d elements\n", nerrors, NX*NY); - return 1; - } + TESTING("dataset of LE FLOAT with Shuffle filter"); +#ifdef H5_HAVE_FILTER_SHUFFLE + nerrors += check_data(DATASETNAME20, file, TRUE); +#else /*H5_HAVE_FILTER_SHUFFLE*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_SHUFFLE*/ - PASSED(); + TESTING("dataset of BE FLOAT with Shuffle filter"); +#ifdef H5_HAVE_FILTER_SHUFFLE + nerrors += check_data(DATASETNAME21, file, TRUE); +#else /*H5_HAVE_FILTER_SHUFFLE*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_SHUFFLE*/ -#else /*H5_HAVE_FILTER_SCALEOFFSET*/ + TESTING("dataset of LE FLOAT with Nbit filter"); +#ifdef H5_HAVE_FILTER_NBIT + nerrors += check_data(DATASETNAME22, file, TRUE); +#else /*H5_HAVE_FILTER_NBIT*/ SKIPPED(); puts(not_supported); -#endif /*H5_HAVE_FILTER_SCALEOFFSET*/ +#endif /*H5_HAVE_FILTER_NBIT*/ + + TESTING("dataset of BE FLOAT with Nbit filter"); +#ifdef H5_HAVE_FILTER_NBIT + nerrors += check_data(DATASETNAME23, file, TRUE); +#else /*H5_HAVE_FILTER_NBIT*/ + SKIPPED(); + puts(not_supported); +#endif /*H5_HAVE_FILTER_NBIT*/ if(H5Fclose(file)) TEST_ERROR @@ -916,20 +394,20 @@ error: H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; - return 1; + return nerrors; } /*------------------------------------------------------------------------- * Function: main * - * Purpose: Tests the basic features of Virtual File Drivers + * Purpose: Tests reading files created on LE and BE systems. * * Return: Success: exit(0) * Failure: exit(1) * * Programmer: Raymond Lu - * Tuesday, Sept 24, 2002 + * Thursday, March 23, 2006 * *------------------------------------------------------------------------- */ @@ -940,17 +418,13 @@ int main(void) h5_reset(); - puts("Testing reading data created on OpenVMS"); - h5_fixname(FILENAME[0], H5P_DEFAULT, filename, sizeof filename); - nerrors += read_data(filename); - puts("Testing reading data created on Linux"); h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof filename); - nerrors += read_data(filename); + nerrors += open_dataset(filename); puts("Testing reading data created on Solaris"); h5_fixname(FILENAME[2], H5P_DEFAULT, filename, sizeof filename); - nerrors += read_data(filename); + nerrors += open_dataset(filename); if (nerrors) { printf("***** %u FAILURE%s! *****\n", diff --git a/test/dsets.c b/test/dsets.c index c483ffe..a397150 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -3750,7 +3750,18 @@ test_nbit_compound_2(hid_t file) /* Check that the values read are the same as the values written * Use mask for checking the significant bits, ignoring the padding bits */ - i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]); + /* The original code + * i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]); + * left shift a 32-bit integer for 32-bit. The result is undefined by C language. A user + * discovered it using clang compiler with -fcatch-undefined-behavior option (see Issue 7674 + * in Jira). So I changed it in a funny way as below to avoid it. SLU - 2011/8/11 + */ + if(sizeof(unsigned) > 4) + i_mask = ~((unsigned)~0 << (precision[0] + offset[0])) & ((unsigned)~0 << offset[0]); + else { + i_mask = 0xffffffff; + i_mask = i_mask & ((unsigned)~0 << offset[0]); + } c_mask = ~((unsigned)~0 << (precision[1] + offset[1])) & ((unsigned)~0 << offset[1]); s_mask = ~((unsigned)~0 << (precision[2] + offset[2])) & ((unsigned)~0 << offset[2]); b_mask = ~((unsigned)~0 << (precision[4] + offset[4])) & ((unsigned)~0 << offset[4]); @@ -9770,6 +9781,121 @@ error: /*------------------------------------------------------------------------- + * Function: test_large_chunk_shrink + * + * Purpose: Tests support for shrinking a chunk larger than 1 MB by a + * size greater than 1 MB. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Neil Fortner + * Monday, November 31, 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_large_chunk_shrink(hid_t fapl) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t scalar_sid = -1;/* Scalar dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */ + hsize_t hs_offset; /* Hyperslab offset */ + hsize_t hs_size; /* Hyperslab size */ + unsigned write_elem, read_elem; /* Element written/read */ + + TESTING("shrinking large chunk"); + + h5_fixname(FILENAME[10], fapl, filename, sizeof filename); + + /* Create file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + + /* Create dataset creation property list */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR + + /* Set 2 MB chunk size */ + chunk_dim = 2 * 1024 * 1024 / sizeof(unsigned); + if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR + + /* Create scalar dataspace */ + if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + + /* Create 1-D dataspace */ + dim = 2 * 1024 * 1024 / sizeof(unsigned); + max_dim = H5S_UNLIMITED; + if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) FAIL_STACK_ERROR + + /* Create 2 MB chunked dataset */ + if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + + /* Select last element in the dataset */ + hs_offset = dim - 1; + hs_size = 1; + if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR + + /* Read (unwritten) element from dataset */ + read_elem = 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify unwritten element is fill value (0) */ + if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read"); + + /* Write element to dataset */ + write_elem = 2; + if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR + + /* Read element from dataset */ + read_elem = write_elem + 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify written element is read in */ + if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read"); + + /* Shrink dataset to 512 KB */ + dim = 512 * 1024 / sizeof(unsigned); + if(H5Dset_extent(dsid, &dim) < 0) FAIL_STACK_ERROR + + /* Expand dataset back to 2MB */ + dim = 2 * 1024 * 1024 / sizeof(unsigned); + if(H5Dset_extent(dsid, &dim) < 0) FAIL_STACK_ERROR + + /* Read element from dataset */ + read_elem = 1; + if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR + + /* Verify element is now 0 */ + if(read_elem != 0) FAIL_PUTS_ERROR("invalid element read"); + + /* Close everything */ + if(H5Sclose(sid) < 0) FAIL_STACK_ERROR + if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR + if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dsid); + H5Sclose(sid); + H5Sclose(scalar_sid); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* end test_large_chunk_shrink() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the dataset interface (H5D) @@ -9900,6 +10026,7 @@ main(void) nerrors += (test_fixed_array(my_fapl) < 0 ? 1 : 0); nerrors += (test_idx_compatible() < 0 ? 1 : 0); nerrors += (test_unfiltered_edge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_large_chunk_shrink(my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; diff --git a/test/dt_arith.c b/test/dt_arith.c index 078242d..054f069 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -121,7 +121,7 @@ static int without_hardware_g = 0; TYPE value2 = 0; \ \ /* Allocate buffers */ \ - NELMTS=(SRC_PREC-1)*3+1; \ + NELMTS=SRC_PREC*3; \ BUF = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ SAVED = (unsigned char*)aligned_malloc(NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ HDmemset(BUF, 0, NELMTS*MAX(SRC_SIZE, DST_SIZE)); \ @@ -132,7 +132,7 @@ static int without_hardware_g = 0; \ /*positive values, ascending order. VALUE1 starts from 00000001, to 00000010, until 10000000*/ \ /*VALUE2 ascends from 00000000, to 00000011, 00000111,..., until 11111111.*/ \ - for(n=0; n<SRC_PREC-1; n++) { \ + for(n=0; n<SRC_PREC; n++) { \ if(value1<=SRC_MAX && value1>=SRC_MIN) { \ memcpy(buf_p, &value1, SRC_SIZE); \ memcpy(saved_p, &value1, SRC_SIZE); \ @@ -146,20 +146,26 @@ static int without_hardware_g = 0; saved_p += SRC_SIZE; \ } \ \ - value1 <<= 1; \ - value2 = (value1 - 1) | value1; \ + if(n<SRC_PREC-2) { \ + value1 <<= 1; \ + value2 = (value1 - 1) | value1; \ + } else if(n==SRC_PREC-2) { /*to avoid overflow of negative values for signed integer*/ \ + value1 <<= 1; \ + value2 = (~value1) | value1; \ + } \ } \ \ /* negative values for signed; descending positive values for unsigned */ \ /* VALUE2 descends from 11111111 to 11111110, 11111100, ..., until 10000000. */ \ - for(n=0; n<SRC_PREC; n++) { \ + for(n=0; n<SRC_PREC-1; n++) { \ if(value2<=SRC_MAX && value2>=SRC_MIN) { \ memcpy(buf_p, &value2, SRC_SIZE); \ memcpy(saved_p, &value2, SRC_SIZE); \ buf_p += SRC_SIZE; \ saved_p += SRC_SIZE; \ } \ - value2 <<= 1; \ + if(n<SRC_PREC-1) \ + value2 <<= 1; \ } \ } diff --git a/test/dtransform.c b/test/dtransform.c index 5d5cefe..2bcbe8c 100644 --- a/test/dtransform.c +++ b/test/dtransform.c @@ -23,6 +23,7 @@ static int init_test(hid_t file_id); static int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy); static int test_trivial(const hid_t dxpl_id_simple); static int test_poly(const hid_t dxpl_id_polynomial); +static int test_specials(hid_t file); static int test_set(void); static int test_getset(const hid_t dxpl_id_simple); @@ -50,14 +51,14 @@ const float windchillFfloat[ROWS][COLS] = const int transformData[ROWS][COLS] = { {36, 31, 25, 19, 13, 7, 1, 5, 11, 16, 22, 28, 34, 40, 46, 52, 57, 63 }, - {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 0 } , - {32, 25, 19, 13, 6, 0, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 }, + {34, 27, 21, 15, 9, 3, 4, 10, 16, 22, 28, 35, 41, 47, 53, 59, 66, 1 } , + {32, 25, 19, 13, 6, 2, 7, 13, 19, 26, 32, 39, 45, 51, 58, 64, 71, 5 }, {30, 24, 17, 11, 4, 2, 9, 15, 22, 29, 35, 42, 48, 55, 61, 68, 2, 9 }, {29, 23, 16, 9, 3, 4, 11, 17, 24, 31, 37, 44, 51, 58, 64, 71, 6, 12 }, {28, 22, 15, 8, 1, 5, 12, 19, 26, 33, 39, 46, 53, 60, 67, 1, 8, 15 }, - {28, 21, 14, 7, 0, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 }, + {28, 21, 14, 7, 6, 7, 14, 21, 27, 34, 41, 48, 55, 62, 69, 4, 10, 17 }, {27, 20, 13, 6, 1, 8, 15, 22, 29, 36, 43, 50, 57, 64, 71, 6, 12, 19 }, - {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 0, 7, 14, 21 }, + {26, 19, 12, 5, 2, 9, 16, 23, 30, 37, 44, 51, 58, 65, 5, 7, 14, 21 }, {26, 19, 12, 4, 3, 10, 17, 24, 31, 38, 45, 52, 60, 67, 2, 9, 16, 23}, {25, 18, 11, 4, 3, 11, 18, 25, 32, 39, 46, 54, 61, 68, 3, 10, 17, 25}, {25, 17, 10, 3, 4, 11, 19, 26, 33, 40, 48, 55, 62, 69, 4, 12, 19, 26} @@ -97,6 +98,22 @@ const int transformData[ROWS][COLS] = PASSED(); \ } +#define COMPARE_INT(VAR1,VAR2) \ +{ \ + size_t i,j; \ + \ + for(i=0; i<ROWS; i++) \ + for(j=0; j<COLS; j++) \ + { \ + if( (VAR1)[i][j] != (VAR2)[i][j] ) \ + { \ + H5_FAILED(); \ + fprintf(stderr, " ERROR: data failed to match computed data\n"); \ + goto error; \ + } \ + } \ +} + #define TEST_TYPE_CONTIG(XFORM, TYPE, HDF_TYPE, TEST_STR, COMPARE_DATA, SIGNED) \ { \ TYPE array[ROWS][COLS]; \ @@ -332,6 +349,7 @@ int main(void) if(test_trivial(dxpl_id_simple) < 0) TEST_ERROR; if(test_poly(dxpl_id_polynomial) < 0) TEST_ERROR; if(test_getset(dxpl_id_c_to_f) < 0) TEST_ERROR; + if(test_specials(file_id) < 0) TEST_ERROR; /* Close the objects we opened/created */ if(H5Dclose(dset_id_int) < 0) TEST_ERROR; @@ -502,6 +520,160 @@ error: } static int +test_specials(hid_t file) +{ + hid_t dxpl_id, dset_id, dataspace; + hsize_t dim[2] = { ROWS, COLS }; + int read_buf[ROWS][COLS]; + int data_res[ROWS][COLS]; + int row, col; + const char* special1 = "x*-100"; + const char* special2 = "100-x"; + const char* special3 = "1000/x"; + const char* special4 = "-x"; + const char* special5 = "+x"; + + TESTING("data transform of some special cases") + + if((dataspace = H5Screate_simple(2, dim, NULL)) < 0) + TEST_ERROR + + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; + + /*----------------------------- + * Operation 1: x*-100 + *----------------------------*/ + if(H5Pset_data_transform(dxpl_id, special1) < 0) TEST_ERROR; + + for(row = 0; row < ROWS; row++) + for(col = 0; col < COLS; col++) + data_res[row][col] = transformData[row][col] * -100; + + if((dset_id = H5Dcreate2(file, "/special1", H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + dxpl_id, transformData) < 0) + TEST_ERROR + if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) + TEST_ERROR + + COMPARE_INT(read_buf, data_res) + + if(H5Dclose(dset_id) < 0) + TEST_ERROR + + /*----------------------------- + * Operation 2: 100-x + *----------------------------*/ + if(H5Pset_data_transform(dxpl_id, special2) < 0) TEST_ERROR; + + for(row = 0; row < ROWS; row++) + for(col = 0; col < COLS; col++) + data_res[row][col] = 100 - transformData[row][col]; + + if((dset_id = H5Dcreate2(file, "/special2", H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + dxpl_id, transformData) < 0) + TEST_ERROR + if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) + TEST_ERROR + + COMPARE_INT(read_buf, data_res) + + if(H5Dclose(dset_id) < 0) + TEST_ERROR + + /*----------------------------- + * Operation 3: 1000/x + *----------------------------*/ + if(H5Pset_data_transform(dxpl_id, special3) < 0) TEST_ERROR; + + for(row = 0; row < ROWS; row++) + for(col = 0; col < COLS; col++) + data_res[row][col] = 1000 / transformData[row][col]; + + if((dset_id = H5Dcreate2(file, "/special3", H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + dxpl_id, transformData) < 0) + TEST_ERROR + if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) + TEST_ERROR + + COMPARE_INT(read_buf, data_res) + + if(H5Dclose(dset_id) < 0) + TEST_ERROR + + /*----------------------------- + * Operation 4: -x + *----------------------------*/ + if(H5Pset_data_transform(dxpl_id, special4) < 0) TEST_ERROR; + + for(row = 0; row < ROWS; row++) + for(col = 0; col < COLS; col++) + data_res[row][col] = -1 * transformData[row][col]; + + if((dset_id = H5Dcreate2(file, "/special4", H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + dxpl_id, transformData) < 0) + TEST_ERROR + if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) + TEST_ERROR + + COMPARE_INT(read_buf, data_res) + + if(H5Dclose(dset_id) < 0) + TEST_ERROR + + /*----------------------------- + * Operation 5: +x + *----------------------------*/ + if(H5Pset_data_transform(dxpl_id, special5) < 0) TEST_ERROR; + + for(row = 0; row < ROWS; row++) + for(col = 0; col < COLS; col++) + data_res[row][col] = transformData[row][col]; + + if((dset_id = H5Dcreate2(file, "/special5", H5T_NATIVE_INT, + dataspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + dxpl_id, transformData) < 0) + TEST_ERROR + if(H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, + H5P_DEFAULT, read_buf) < 0) + TEST_ERROR + + COMPARE_INT(read_buf, data_res) + + if(H5Dclose(dset_id) < 0) + TEST_ERROR + + + if(H5Pclose(dxpl_id) < 0) + TEST_ERROR + if(H5Sclose(dataspace) < 0) + TEST_ERROR + + PASSED(); + return 0; + +error: + return -1; +} + +static int test_copy(const hid_t dxpl_id_c_to_f_copy, const hid_t dxpl_id_polynomial_copy) { int windchillC; diff --git a/test/dtypes.c b/test/dtypes.c index a66a34c..23a7bac 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -71,6 +71,7 @@ } const char *FILENAME[] = { + "dtypes0", "dtypes1", "dtypes2", "dtypes3", @@ -79,6 +80,8 @@ const char *FILENAME[] = { "dtypes6", "dtypes7", "dtypes8", + "dtypes9", + "dtypes10", NULL }; @@ -102,6 +105,17 @@ typedef enum dtype_t { #define COMPOUND13_ARRAY_SIZE 256 #define COMPOUND13_ATTR_NAME "attr" +/* Constants for delete_obj_named test */ +#define DEL_OBJ_NAMED_DATASET "/Dataset" +#define DEL_OBJ_NAMED_NAMED_DTYPE "/Dtype" +#define DEL_OBJ_NAMED_ATTRIBUTE "Attr" + +/* Constant for testing conversion of UTF-8 characters */ +#define UTF8_DATASET "utf8" +#define UTF8_DATASET2 "2nd_utf8" +#define ASCII_DATASET "ascii" +#define ASCII_DATASET2 "2nd_ascii" + /* Count opaque conversions */ static int num_opaque_conversions_g = 0; @@ -516,6 +530,12 @@ test_compound_1(void) if ((complex_id = H5Tcreate(H5T_COMPOUND, sizeof(complex_t))) < 0) goto error; + /* Try to shrink and expand the size */ + if(H5Tset_size(complex_id, sizeof(double)) < 0) + goto error; + if(H5Tset_size(complex_id, sizeof(complex_t)) < 0) + goto error; + /* Attempt to add the new compound datatype as a field within itself */ H5E_BEGIN_TRY { ret=H5Tinsert(complex_id, "compound", (size_t)0, complex_id); @@ -531,6 +551,14 @@ test_compound_1(void) goto error; /* Test some functions that aren't supposed to work for compound type */ + /* Tries to shrink the size and trail the last member */ + H5E_BEGIN_TRY { + ret=H5Tset_size(complex_id, sizeof(double)); + } H5E_END_TRY; + if (ret>=0) { + FAIL_PUTS_ERROR("Operation not allowed for this type."); + } /* end if */ + H5E_BEGIN_TRY { size=H5Tget_precision(complex_id); } H5E_END_TRY; @@ -3210,7 +3238,11 @@ test_compound_18(void) /* Open Generated File */ /* (generated with gen_bad_compound.c) */ +#ifdef H5_VMS + if((file = H5Fopen(TESTFILE, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR +#else if((file = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR +#endif /* Try to open the datatype */ H5E_BEGIN_TRY { @@ -3896,6 +3928,67 @@ mkstr(size_t len, H5T_str_t strpad) /*------------------------------------------------------------------------- + * Function: test_str_create + * + * Purpose: Test string type creation using H5Tcreate + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Raymond Lu + * 19 May 2011 + * + *------------------------------------------------------------------------- + */ +static int +test_str_create(void) +{ + hid_t fixed_str1, fixed_str2; + hid_t vlen_str1, vlen_str2; + htri_t is_vl_str = FALSE; + size_t query_size, str_size = 10; + + TESTING("string type creation using H5Tcreate"); + + /* Create fixed-length string in two ways and make sure they are the same */ + if((fixed_str1 = mkstr(str_size, H5T_STR_NULLTERM)) < 0) goto error; + + if((fixed_str2 = H5Tcreate(H5T_STRING, str_size)) < 0) goto error; + if(H5Tset_strpad(fixed_str2, H5T_STR_NULLTERM) < 0) goto error; + + if(!H5Tequal(fixed_str1, fixed_str2)) goto error; + + if((query_size = H5Tget_size(fixed_str1)) == 0) goto error; + if(query_size != str_size) goto error; + + if((query_size = H5Tget_size(fixed_str2)) == 0) goto error; + if(query_size != str_size) goto error; + + /* Create variable-length string in two ways and make sure they are the same */ + if((vlen_str1 = mkstr((size_t)H5T_VARIABLE, H5T_STR_NULLTERM)) < 0) goto error; + + if((vlen_str2 = H5Tcreate(H5T_STRING, (size_t)H5T_VARIABLE)) < 0) goto error; + if(H5Tset_strpad(vlen_str2, H5T_STR_NULLTERM) < 0) goto error; + + if(!H5Tequal(vlen_str1, vlen_str2)) goto error; + + if((is_vl_str = H5Tis_variable_str(vlen_str1)) < 0) goto error; + if(!is_vl_str) goto error; + + if((is_vl_str = H5Tis_variable_str(vlen_str2)) < 0) goto error; + if(!is_vl_str) goto error; + + + PASSED(); + return 0; + +error: + H5_FAILED(); + return 1; +} + + +/*------------------------------------------------------------------------- * Function: test_conv_str_1 * * Purpose: Test string conversions @@ -4415,8 +4508,6 @@ error: * Failure: number of errors * * Programmer: Robb Matzke, LLNL, 2003-06-09 - * - * Modifications: *------------------------------------------------------------------------- */ static int @@ -4432,7 +4523,7 @@ test_conv_enum_2(void) "PURPLE", "ORANGE", "WHITE" }; - + TESTING("non-native enumeration type conversion"); /* Source enum type */ @@ -6441,6 +6532,353 @@ error: return 1; } /* end test_named_indirect_reopen() */ +static void create_del_obj_named_test_file(const char *filename, hid_t fapl, + hbool_t new_format) +{ + hid_t file; /* File ID */ + hid_t type; /* Datatype ID */ + hid_t space; /* Dataspace ID */ + hid_t attr; /* Attribute ID */ + hid_t dset; /* Dataset ID */ + hid_t fcpl; /* File creation property list ID */ + hid_t my_fapl; /* Copy of file access property list ID */ + hid_t dcpl; /* Dataset creation property list ID */ + herr_t status; /* Generic return value */ + + /* Make copy of FAPL */ + my_fapl = H5Pcopy(fapl); + assert(my_fapl > 0); + + if(new_format) { + /* Use latest version of file format */ + status = H5Pset_libver_bounds(my_fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + assert(status >= 0); + } /* end if */ + + /* Create a file creation property list (used for the root group's creation property list) */ + fcpl = H5Pcreate(H5P_FILE_CREATE); + assert(fcpl > 0); + + if(new_format) { + /* Use dense link storage for all links in root group */ + status = H5Pset_link_phase_change(fcpl, 0, 0); + assert(status >= 0); + } /* end if */ + + /* Create file with attribute that uses committed datatype */ + file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, my_fapl); + assert(file > 0); + + /* Close FCPL */ + status = H5Pclose(fcpl); + assert(status >= 0); + + /* Close FAPL */ + status = H5Pclose(my_fapl); + assert(status >= 0); + + /* Create datatype to commit */ + type = H5Tvlen_create(H5T_NATIVE_INT); + assert(type > 0); + + /* Commit datatype */ + status = H5Tcommit2(file, DEL_OBJ_NAMED_NAMED_DTYPE, type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + assert(status >= 0); + + /* Create scalar dataspace */ + space = H5Screate(H5S_SCALAR); + assert(space > 0); + + /* Create a dataset creation property list */ + dcpl = H5Pcreate(H5P_DATASET_CREATE); + assert(dcpl > 0); + + if(new_format) { + /* Use dense attribute storage for all attributes on dataset */ + status = H5Pset_attr_phase_change(dcpl, 0, 0); + assert(status >= 0); + } /* end if */ + + /* Create dataset */ + dset = H5Dcreate2(file, DEL_OBJ_NAMED_DATASET, type, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); + assert(dset > 0); + + /* Close DCPL */ + status = H5Pclose(dcpl); + assert(status >= 0); + + /* Close dataset */ + status = H5Dclose(dset); + assert(status >= 0); + + /* Create attribute */ + attr = H5Acreate_by_name(file, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, type, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + assert(attr > 0); + + /* Close dataspace */ + status = H5Sclose(space); + assert(status >= 0); + + /* Close datatype */ + status = H5Tclose(type); + assert(status >= 0); + + /* Close attribute */ + status = H5Aclose(attr); + assert(status >= 0); + + /* Close file */ + status = H5Fclose(file); + assert(status >= 0); +} /* end create_del_obj_named_test_file() */ + + +/*------------------------------------------------------------------------- + * Function: test_delete_obj_named + * + * Purpose: Tests that delete objects that use named datatypes through + * different file IDs + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Monday, July 18, 2011 + * + *------------------------------------------------------------------------- + */ +static int +test_delete_obj_named(hid_t fapl) +{ + hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */ + hid_t attr = -1; /* Attribute ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl2 = -1; /* File access property list ID */ + hbool_t new_format; /* Whether to use old or new format */ + char filename[1024], filename2[1024]; + + TESTING("deleting objects that use named datatypes"); + + /* Set up filenames & FAPLs */ + if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2); + + /* Loop over old & new format files */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, new_format); + +/* Test deleting dataset opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + + if(H5Ldelete(filea2, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + + + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, new_format); + +/* Test deleting attribute opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + + if(H5Adelete_by_name(filea2, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + } /* end for */ + + if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(attr); + H5Dclose(dset); + H5Pclose(fapl2); + H5Fclose(filea1); + H5Fclose(filea2); + H5Fclose(fileb); + } H5E_END_TRY; + return 1; +} /* end test_delete_obj_named() */ + + +/*------------------------------------------------------------------------- + * Function: test_delete_obj_named_fileid + * + * Purpose: Tests that objects that use named datatypes through + * different file IDs get the correct file IDs + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Quincey Koziol + * Thursday, July 28, 2011 + * + *------------------------------------------------------------------------- + */ +static int +test_delete_obj_named_fileid(hid_t fapl) +{ + hid_t filea1 = -1, filea2 = -1, fileb = -1; /* File IDs */ + hid_t dset_fid = -1; /* File ID from dataset */ + hid_t type_fid = -1; /* File ID from datatype */ + hid_t attr_fid = -1; /* File ID from attribute */ + hid_t type = -1; /* Datatype ID */ + hid_t attr = -1; /* Attribute ID */ + hid_t dset = -1; /* Dataset ID */ + hid_t fapl2 = -1; /* File access property list ID */ + hbool_t new_format; /* Whether to use old or new format */ + char filename[1024], filename2[1024]; + + TESTING("deleting objects that use named datatypes"); + + /* Set up filenames & FAPLs */ + if((fapl2 = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + h5_fixname(FILENAME[9], fapl2, filename2, sizeof filename2); + + /* Loop over old & new format files */ + for(new_format = FALSE; new_format <= TRUE; new_format++) { + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, new_format); + +/* Test getting file ID for dataset opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Verify file ID from dataset matches correct file */ + dset_fid = H5Iget_file_id(dset); + if(dset_fid != filea1) TEST_ERROR + H5Fclose(dset_fid); + + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Dget_type(dset); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); + + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((dset = H5Dopen2(filea1, DEL_OBJ_NAMED_DATASET, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Verify file ID from dataset matches correct file */ + dset_fid = H5Iget_file_id(dset); + if(dset_fid != filea1) TEST_ERROR + H5Fclose(dset_fid); + + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Dget_type(dset); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); + + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + + + /* Create test file, with attribute that uses committed datatype */ + create_del_obj_named_test_file(filename, fapl, new_format); + +/* Test getting file ID for attribute opened through different file ID */ + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + if((filea2 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Verify file ID from dataset matches correct file */ + attr_fid = H5Iget_file_id(attr); + if(attr_fid != filea1) TEST_ERROR + H5Fclose(attr_fid); + + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Aget_type(attr); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); + + if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + + if((fileb = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl2)) < 0) FAIL_STACK_ERROR + + if((filea1 = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR + + if((attr = H5Aopen_by_name(filea1, DEL_OBJ_NAMED_DATASET, DEL_OBJ_NAMED_ATTRIBUTE, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Verify file ID from dataset matches correct file */ + attr_fid = H5Iget_file_id(attr); + if(attr_fid != filea1) TEST_ERROR + H5Fclose(attr_fid); + + /* Verify file ID from datatype (from dataset) matches correct file */ + type = H5Aget_type(attr); + type_fid = H5Iget_file_id(type); + if(type_fid != filea1) TEST_ERROR + H5Fclose(type_fid); + H5Tclose(type); + + if(H5Aclose(attr) < 0) FAIL_STACK_ERROR + + if(H5Fclose(filea1) < 0) FAIL_STACK_ERROR + if(H5Fclose(filea2) < 0) FAIL_STACK_ERROR + if(H5Fclose(fileb) < 0) FAIL_STACK_ERROR + } /* end for */ + + if(H5Pclose(fapl2) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(attr); + H5Dclose(dset); + H5Pclose(fapl2); + H5Fclose(filea1); + H5Fclose(filea2); + H5Fclose(fileb); + } H5E_END_TRY; + return 1; +} /* end test_delete_obj_named_fileid() */ + /*------------------------------------------------------------------------- * Function: test_deprec @@ -6592,6 +7030,215 @@ error: /*------------------------------------------------------------------------- + * Function: test_utf_ascii_conv + * + * Purpose: Make sure the library doesn't conversion strings between + * ASCII and UTF8. + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Raymond Lu + * 10 November 2011 + *------------------------------------------------------------------------- + */ +int test_utf_ascii_conv(void) +{ + hid_t fid; + hid_t did; + hid_t utf8_vtid, ascii_vtid; + hid_t utf8_tid, ascii_tid; + hid_t sid; + const char *utf8_w = "foo!"; + char *ascii_r = NULL; + const char *ascii_w = "bar!"; + char *utf8_r = NULL; + + char ascii2[4], utf8_2[4]; + herr_t status; + + TESTING("string conversion between ASCII and UTF"); + + /************************************************ + * Test VL string conversion from UTF8 to ASCII + ************************************************/ + /* Create a variable-length string */ + if((utf8_vtid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + + if((status = H5Tset_size(utf8_vtid, H5T_VARIABLE)) < 0) FAIL_STACK_ERROR + + /* Set the character set for the string to UTF-8 */ + if((status = H5Tset_cset(utf8_vtid, H5T_CSET_UTF8)) < 0) FAIL_STACK_ERROR + + /* Create a variable-length string */ + if((ascii_vtid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + + if((status = H5Tset_size(ascii_vtid, H5T_VARIABLE)) < 0) FAIL_STACK_ERROR + + /* Set the character set for the string to ASCII (should already be so) */ + if((status = H5Tset_cset(ascii_vtid, H5T_CSET_ASCII) < 0)) FAIL_STACK_ERROR + + /* Test conversion in memory */ + H5E_BEGIN_TRY { + status = H5Tconvert(utf8_vtid, ascii_vtid, 1, (void *)utf8_w, NULL, H5P_DEFAULT); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Create a file */ + if((fid = H5Fcreate(FILENAME[10], H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Create a scalar dataspace for the dataset */ + if((sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR + + /* Create a dataset of UTF8 string type */ + if((did = H5Dcreate2(fid, UTF8_DATASET, utf8_vtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Write the UTF8 string, as UTF8 */ + if((status = H5Dwrite(did, utf8_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_w)) < 0) FAIL_STACK_ERROR + + /* Read the UTF8 string, as ASCII, supposed to fail */ + H5E_BEGIN_TRY { + status = H5Dread(did, ascii_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_r); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Close the dataset */ + if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + + /************************************************ + * Test VL string conversion from ASCII to UTF8 + ************************************************/ + /* Test conversion in memory */ + H5E_BEGIN_TRY { + status = H5Tconvert(ascii_vtid, utf8_vtid, 1, (void *)ascii_w, NULL, H5P_DEFAULT); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Create a dataset of ASCII string type */ + if((did = H5Dcreate2(fid, ASCII_DATASET, ascii_vtid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Write the ASCII string, as ASCII */ + if((status = H5Dwrite(did, ascii_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_w)) < 0) FAIL_STACK_ERROR + + /* Read the ASCII string, as UTF8, supposed to fail */ + H5E_BEGIN_TRY { + status = H5Dread(did, utf8_vtid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_r); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Close the dataset */ + if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + + /* Close the UTF8 VL-string datatype */ + if((status = H5Tclose(utf8_vtid)) < 0) FAIL_STACK_ERROR + + /* Close the ASCII VL-string datatype */ + if((status = H5Tclose(ascii_vtid)) < 0) FAIL_STACK_ERROR + + /********************************************************** + * Test fixed-length string conversion from UTF8 to ASCII + **********************************************************/ + /* Create a fixed-length UTF8 string */ + if((utf8_tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + + if((status = H5Tset_size(utf8_tid, 4)) < 0) FAIL_STACK_ERROR + + /* Set the character set for the string to UTF-8 */ + if((status = H5Tset_cset(utf8_tid, H5T_CSET_UTF8)) < 0) FAIL_STACK_ERROR + + /* Create a fixed-length ASCII string */ + if((ascii_tid = H5Tcopy(H5T_C_S1)) < 0) FAIL_STACK_ERROR + + if((status = H5Tset_size(ascii_tid, 4)) < 0) FAIL_STACK_ERROR + + /* Set the character set for the string to ASCII (should already be so) */ + if((status = H5Tset_cset(ascii_tid, H5T_CSET_ASCII) < 0)) FAIL_STACK_ERROR + + /* Test conversion in memory */ + H5E_BEGIN_TRY { + status = H5Tconvert(utf8_tid, ascii_tid, 1, utf8_2, NULL, H5P_DEFAULT); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Create a dataset */ + if((did = H5Dcreate2(fid, UTF8_DATASET2, utf8_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Write the UTF8 string, as UTF8 */ + if((status = H5Dwrite(did, utf8_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_w)) < 0) FAIL_STACK_ERROR + + /* Read the UTF8 string as ASCII, supposed to fail */ + H5E_BEGIN_TRY { + status = H5Dread(did, ascii_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii2); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Close the dataset */ + if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + + /********************************************************** + * Test fixed-length string conversion from ASCII to UTF8 + **********************************************************/ + /* Test conversion in memory */ + H5E_BEGIN_TRY { + status = H5Tconvert(ascii_tid, utf8_tid, 1, ascii2, NULL, H5P_DEFAULT); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Create a dataset */ + if((did = H5Dcreate2(fid, ASCII_DATASET2, ascii_tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Write the ASCII string, as ASCII */ + if((status = H5Dwrite(did, ascii_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &ascii_w)) < 0) FAIL_STACK_ERROR + + /* Read the UTF8 string as ASCII, supposed to fail */ + H5E_BEGIN_TRY { + status = H5Dread(did, utf8_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &utf8_2); + } H5E_END_TRY + if(status >= 0) + FAIL_STACK_ERROR + + /* Close the dataset */ + if((status = H5Dclose(did)) < 0) FAIL_STACK_ERROR + + /* Close the UTF8 string datatype */ + if((status = H5Tclose(utf8_tid)) < 0) FAIL_STACK_ERROR + + /* Close the ASCII string datatype */ + if((status = H5Tclose(ascii_tid)) < 0) FAIL_STACK_ERROR + + /* Close the dataspace */ + if((status = H5Sclose(sid)) < 0) FAIL_STACK_ERROR + + /* Close the file */ + if((status = H5Fclose(fid)) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(utf8_vtid); + H5Tclose(ascii_vtid); + H5Tclose(utf8_tid); + H5Tclose(ascii_tid); + H5Dclose(did); + H5Sclose(sid); + H5Fclose(fid); + } H5E_END_TRY; + return 1; +} + + + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test the datatype interface. @@ -6635,7 +7282,10 @@ main(void) nerrors += test_latest(); nerrors += test_int_float_except(); nerrors += test_named_indirect_reopen(fapl); + nerrors += test_delete_obj_named(fapl); + nerrors += test_delete_obj_named_fileid(fapl); nerrors += test_set_order_compound(fapl); + nerrors += test_str_create(); #ifndef H5_NO_DEPRECATED_SYMBOLS nerrors += test_deprec(fapl); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -6668,6 +7318,7 @@ main(void) nerrors += test_bitfield_funcs(); nerrors += test_opaque(); nerrors += test_set_order(); + nerrors += test_utf_ascii_conv(); if(nerrors) { printf("***** %lu FAILURE%s! *****\n", @@ -6679,4 +7330,3 @@ main(void) return 0; } - diff --git a/test/enum.c b/test/enum.c index e9f607d..3684102 100644 --- a/test/enum.c +++ b/test/enum.c @@ -119,9 +119,6 @@ test_named(hid_t file) * * Programmer: Robb Matzke * Monday, January 4, 1999 - * - * Modifications: - * *------------------------------------------------------------------------- */ static int diff --git a/test/error_test.c b/test/error_test.c index 52dcc0c..1ca9686 100644 --- a/test/error_test.c +++ b/test/error_test.c @@ -20,11 +20,12 @@ * Purpose: Tests the error API routines. */ #include "h5test.h" +#include "H5srcdir.h" #ifdef H5_USE_16_API int main(void) { - printf("Test skipped because backward compatbility with v1.6 is configured in\n"); + HDfprintf(stderr, "Test skipped because backward compatbility with v1.6 is configured in\n"); return 0; } #else /* H5_USE_16_API */ @@ -34,6 +35,8 @@ const char *FILENAME[] = { NULL }; +#define DATAFILE "filter_error" + #define DIM0 100 #define DIM1 200 @@ -74,6 +77,8 @@ hid_t ERR_MIN_GETNUM; #define MSG_SIZE 64 #define LONG_DESC_SIZE 8192 +#define DSET_FILTER_NAME "dataset_with_filter" + static herr_t custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void *client_data); @@ -102,8 +107,7 @@ test_error(hid_t file) H5E_auto2_t old_func; void *old_data; - TESTING("error API based on data I/O"); - printf("\n"); + HDfprintf(stderr, "\nTesting error API based on data I/O\n"); /* Create the data space */ dims[0] = DIM0; @@ -359,8 +363,9 @@ test_long_desc(void) /* Push an error with a long description */ if(H5Epush(H5E_DEFAULT, __FILE__, test_FUNC, __LINE__, ERR_CLS, ERR_MAJ_TEST, ERR_MIN_SUBROUTINE, format, long_desc) < 0) TEST_ERROR; - /* Create the string that should be in the description */ - HDsnprintf(full_desc, LONG_DESC_SIZE + 128, format, long_desc); + /* Create the string that should be in the description. Must use HDsnprintf here + * because snprintf is _snprintf on Windows */ + HDsnprintf(full_desc, (size_t)(LONG_DESC_SIZE + 128), format, long_desc); /* Make certain that the description is correct */ if(H5Ewalk2(H5E_DEFAULT, H5E_WALK_UPWARD, long_desc_cb, full_desc) < 0) TEST_ERROR; @@ -401,12 +406,12 @@ static herr_t dump_error(hid_t estack) { /* Print errors in library default way */ - fprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); + HDfprintf(stderr, "********* Print error stack in HDF5 default way *********\n"); if(H5Eprint2(estack, stderr) < 0) TEST_ERROR; /* Customized way to print errors */ - fprintf(stderr, "\n********* Print error stack in customized way *********\n"); + HDfprintf(stderr, "\n********* Print error stack in customized way *********\n"); if(H5Ewalk2(estack, H5E_WALK_UPWARD, custom_print_cb, stderr) < 0) TEST_ERROR; @@ -450,12 +455,12 @@ custom_print_cb(unsigned n, const H5E_error2_t *err_desc, void* client_data) if(H5Eget_msg(err_desc->min_num, NULL, min, MSG_SIZE) < 0) TEST_ERROR; - fprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", + HDfprintf(stream, "%*serror #%03d: %s in %s(): line %u\n", indent, "", n, err_desc->file_name, err_desc->func_name, err_desc->line); - fprintf(stream, "%*sclass: %s\n", indent * 2, "", cls); - fprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); - fprintf(stream, "%*sminor: %s\n", indent * 2, "", min); + HDfprintf(stream, "%*sclass: %s\n", indent * 2, "", cls); + HDfprintf(stream, "%*smajor: %s\n", indent * 2, "", maj); + HDfprintf(stream, "%*sminor: %s\n", indent * 2, "", min); return 0; @@ -534,7 +539,6 @@ 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 */ @@ -618,6 +622,57 @@ error: /*------------------------------------------------------------------------- + * Function: test_filter_error + * + * Purpose: Make sure the error message prints out the filter name + * when the existent file is opened but the filter isn't + * registered. The existent file was created with + * gen_filters.c. + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * 2 June 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_filter_error(const char *fname) +{ + const char *pathname = H5_get_srcdir_filename(fname); /* Corrected test file name */ + hid_t file, dataset; /* handles */ + int buf[20]; + + HDfprintf(stderr, "\nTesting error message during data reading when filter isn't registered\n"); + + /* Open the file */ + if((file = H5Fopen(pathname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Open the regular dataset */ + if((dataset = H5Dopen2(file, DSET_FILTER_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) >= 0) + TEST_ERROR; + + /* Close/release resources */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + if(H5Fclose(file) < 0) + TEST_ERROR + + return 0; + +error: + return -1; +} + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Test error API. @@ -635,7 +690,7 @@ main(void) char filename[1024]; const char *FUNC_main = "main"; - fprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); + HDfprintf(stderr, " This program tests the Error API. There're supposed to be some error messages\n"); /* Initialize errors */ if(init_error() < 0) @@ -689,17 +744,25 @@ main(void) if(test_copy() < 0) TEST_ERROR; if(H5Fclose(file) < 0) TEST_ERROR; - h5_cleanup(FILENAME, fapl); /* Close error information */ if(close_error() < 0) TEST_ERROR; - printf("All error API tests passed.\n"); + /* Test error message during data reading when filter isn't registered + * Use default FAPL to avoid some VFD drivers by the check-vfd test because + * the test file was pre-generated. */ + h5_fixname(DATAFILE, H5P_DEFAULT, filename, sizeof filename); + if(test_filter_error(filename) < 0) + TEST_ERROR; + + h5_cleanup(FILENAME, fapl); + + HDfprintf(stderr, "\nAll error API tests passed.\n"); return 0; error: - printf("***** ERROR TEST FAILED! *****\n"); + HDfprintf(stderr, "\n***** ERROR TEST FAILED (real problem)! *****\n"); return 1; } #endif /* H5_USE_16_API */ diff --git a/test/filter_error.h5 b/test/filter_error.h5 Binary files differnew file mode 100644 index 0000000..370cc1c --- /dev/null +++ b/test/filter_error.h5 diff --git a/test/flush2.c b/test/flush2.c index 5675856..06dd086 100644 --- a/test/flush2.c +++ b/test/flush2.c @@ -186,7 +186,7 @@ main(void) PASSED() else { -#if defined _WIN32 && defined _HDF5USEDLL_ +#if defined H5_HAVE_WIN32_API && defined _HDF5USEDLL_ SKIPPED(); puts(" DLL will flush the file even when calling _exit, skip this test temporarily"); #elif defined H5_VMS @@ -209,7 +209,7 @@ main(void) PASSED() else { -#if defined _WIN32 && defined _HDF5USEDLL_ +#if defined H5_HAVE_WIN32_API && defined _HDF5USEDLL_ SKIPPED(); puts(" DLL will flush the file even when calling _exit, skip this test temporarily"); #elif defined H5_VMS diff --git a/test/gen_cross.c b/test/gen_cross.c index 32be867..d960499 100755 --- a/test/gen_cross.c +++ b/test/gen_cross.c @@ -27,7 +27,8 @@ #include "h5test.h" #define H5FILE_NAME "data.h5" -#define DATASETNAME "Array" +#define DATASETNAME "Array_le" +#define DATASETNAME1 "Array_be" #define DATASETNAME2 "Scale_offset_float_data_le" #define DATASETNAME3 "Scale_offset_float_data_be" #define DATASETNAME4 "Scale_offset_double_data_le" @@ -40,6 +41,18 @@ #define DATASETNAME11 "Scale_offset_int_data_be" #define DATASETNAME12 "Scale_offset_long_long_data_le" #define DATASETNAME13 "Scale_offset_long_long_data_be" + +#define DATASETNAME14 "Fletcher_float_data_le" +#define DATASETNAME15 "Fletcher_float_data_be" +#define DATASETNAME16 "Deflate_float_data_le" +#define DATASETNAME17 "Deflate_float_data_be" +#define DATASETNAME18 "Szip_float_data_le" +#define DATASETNAME19 "Szip_float_data_be" +#define DATASETNAME20 "Shuffle_float_data_le" +#define DATASETNAME21 "Shuffle_float_data_be" +#define DATASETNAME22 "Nbit_float_data_le" +#define DATASETNAME23 "Nbit_float_data_be" + #define NX 6 #define NY 6 #define RANK 2 @@ -53,6 +66,11 @@ int create_scale_offset_dsets_char(hid_t fid, hid_t fsid, hid_t msid); int create_scale_offset_dsets_short(hid_t fid, hid_t fsid, hid_t msid); int create_scale_offset_dsets_int(hid_t fid, hid_t fsid, hid_t msid); int create_scale_offset_dsets_long_long(hid_t fid, hid_t fsid, hid_t msid); +int create_fletcher_dsets_float(hid_t fid, hid_t fsid, hid_t msid); +int create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid); +int create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid); +int create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid); +int create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid); /*------------------------------------------------------------------------- @@ -84,15 +102,15 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid) */ for (j = 0; j < NX; j++) { for (i = 0; i < NY; i++) - data[j][i] = i + j; + data[j][i] = ((float)(i + j + 1)) / 3; } /* - * 0 1 2 3 4 5 - * 1 2 3 4 5 6 - * 2 3 4 5 6 7 - * 3 4 5 6 7 8 - * 4 5 6 7 8 9 - * 5 6 7 8 9 10 + * 1/3 2/3 3/3 4/3 5/3 6/3 + * 2/3 3/3 4/3 5/3 6/3 7/3 + * 3/3 4/3 5/3 6/3 7/3 8/3 + * 4/3 5/3 6/3 7/3 8/3 9/3 + * 5/3 6/3 7/3 8/3 9/3 10/3 + * 6/3 7/3 8/3 9/3 10/3 11/3 * -2.2 -2.2 -2.2 -2.2 -2.2 -2.2 */ @@ -106,9 +124,9 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid) /* * Create a new dataset within the file using defined dataspace and - * datatype and default dataset creation properties. + * little-endian datatype and default dataset creation properties. */ - if((dataset = H5Dcreate2(fid, DATASETNAME, H5T_NATIVE_DOUBLE, fsid, + if((dataset = H5Dcreate2(fid, DATASETNAME, H5T_IEEE_F64LE, fsid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) TEST_ERROR @@ -118,14 +136,38 @@ create_normal_dset(hid_t fid, hid_t fsid, hid_t msid) if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR + /* + * Close dataset + */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + /* - * Close/release resources. + * Create a new dataset within the file using defined dataspace and + * big-endian datatype and default dataset creation properties. */ - if(H5Pclose(dcpl) < 0) + if((dataset = H5Dcreate2(fid, DATASETNAME1, H5T_IEEE_F64BE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Write the data to the dataset using default transfer properties. + */ + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) TEST_ERROR + + /* + * Close dataset + */ if(H5Dclose(dataset) < 0) TEST_ERROR + /* + * Close/release resources. + */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + return 0; #ifdef H5_HAVE_FILTER_SCALEOFFSET @@ -774,6 +816,527 @@ error: /*------------------------------------------------------------------------- + * Function: create_fletcher_dsets_float + * + * Purpose: Create a dataset of FLOAT datatype with fletcher filter + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 29 March 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +create_fletcher_dsets_float(hid_t fid, hid_t fsid, hid_t msid) +{ +#ifdef H5_HAVE_FILTER_FLETCHER32 + hid_t dataset; /* dataset handles */ + hid_t dcpl; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; + + /* + * Data and output buffer initialization. + */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = ((float)(i + j + 1))/3; + } + + /* + * Create the dataset creation property list, add the Scale-Offset + * filter, set the chunk size, and set the fill value. + */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if(H5Pset_filter(dcpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL) < 0) + TEST_ERROR + if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + TEST_ERROR + if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + TEST_ERROR + + /* + * Create a new dataset within the file using defined dataspace, little + * endian datatype and default dataset creation properties. + */ + if((dataset = H5Dcreate2(fid, DATASETNAME14, H5T_IEEE_F32LE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Write the data to the dataset using default transfer properties. + */ + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + + /* Close dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Now create a dataset with a big-endian type */ + if((dataset = H5Dcreate2(fid, DATASETNAME15, H5T_IEEE_F32BE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* + * Close/release resources. + */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + +#else /* H5_HAVE_FILTER_FLETCHER32 */ + const char *not_supported= "Fletcher filter is not enabled. Can't create the dataset."; + + puts(not_supported); +#endif /* H5_HAVE_FILTER_FLETCHER32 */ + + return 0; + +#ifdef H5_HAVE_FILTER_FLETCHER32 +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dataset); + } H5E_END_TRY; + + return -1; +#endif /* H5_HAVE_FILTER_FLETCHER32 */ +} + + +/*------------------------------------------------------------------------- + * Function: create_deflate_dsets_float + * + * Purpose: Create a dataset of FLOAT datatype with deflate filter + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 29 March 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +create_deflate_dsets_float(hid_t fid, hid_t fsid, hid_t msid) +{ +#ifdef H5_HAVE_FILTER_DEFLATE + hid_t dataset; /* dataset handles */ + hid_t dcpl; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; + + /* + * Data and output buffer initialization. + */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = ((float)(i + j + 1))/3; + } + + /* + * Create the dataset creation property list, add the Scale-Offset + * filter, set the chunk size, and set the fill value. + */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if(H5Pset_deflate (dcpl, 6) < 0) + TEST_ERROR + if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + TEST_ERROR + if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + TEST_ERROR + + /* + * Create a new dataset within the file using defined dataspace, little + * endian datatype and default dataset creation properties. + */ + if((dataset = H5Dcreate2(fid, DATASETNAME16, H5T_IEEE_F32LE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Write the data to the dataset using default transfer properties. + */ + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + + /* Close dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Now create a dataset with a big-endian type */ + if((dataset = H5Dcreate2(fid, DATASETNAME17, H5T_IEEE_F32BE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* + * Close/release resources. + */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + +#else /* H5_HAVE_FILTER_DEFLATE */ + const char *not_supported= "Deflate filter is not enabled. Can't create the dataset."; + + puts(not_supported); +#endif /* H5_HAVE_FILTER_DEFLATE */ + + return 0; + +#ifdef H5_HAVE_FILTER_DEFLATE +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dataset); + } H5E_END_TRY; + + return -1; +#endif /* H5_HAVE_FILTER_DEFLATE */ +} + + +/*------------------------------------------------------------------------- + * Function: create_szip_dsets_float + * + * Purpose: Create a dataset of FLOAT datatype with szip filter + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 29 March 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +create_szip_dsets_float(hid_t fid, hid_t fsid, hid_t msid) +{ +#ifdef H5_HAVE_FILTER_SZIP + hid_t dataset; /* dataset handles */ + hid_t dcpl; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; + + /* + * Data and output buffer initialization. + */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = ((float)(i + j + 1))/3; + } + + /* + * Create the dataset creation property list, add the Scale-Offset + * filter, set the chunk size, and set the fill value. + */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if(H5Pset_szip(dcpl, H5_SZIP_NN_OPTION_MASK, 4) < 0) + TEST_ERROR + if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + TEST_ERROR + if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + TEST_ERROR + + /* + * Create a new dataset within the file using defined dataspace, little + * endian datatype and default dataset creation properties. + */ + if((dataset = H5Dcreate2(fid, DATASETNAME18, H5T_IEEE_F32LE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Write the data to the dataset using default transfer properties. + */ + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + + /* Close dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Now create a dataset with a big-endian type */ + if((dataset = H5Dcreate2(fid, DATASETNAME19, H5T_IEEE_F32BE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* + * Close/release resources. + */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + +#else /* H5_HAVE_FILTER_SZIP */ + const char *not_supported= "Szip filter is not enabled. Can't create the dataset."; + + puts(not_supported); +#endif /* H5_HAVE_FILTER_SZIP */ + + return 0; + +#ifdef H5_HAVE_FILTER_SZIP +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dataset); + } H5E_END_TRY; + + return -1; +#endif /* H5_HAVE_FILTER_SZIP */ +} + + +/*------------------------------------------------------------------------- + * Function: create_shuffle_dsets_float + * + * Purpose: Create a dataset of FLOAT datatype with shuffle filter + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 29 March 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +create_shuffle_dsets_float(hid_t fid, hid_t fsid, hid_t msid) +{ +#ifdef H5_HAVE_FILTER_SHUFFLE + hid_t dataset; /* dataset handles */ + hid_t dcpl; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; + + /* + * Data and output buffer initialization. + */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = ((float)(i + j + 1))/3; + } + + /* + * Create the dataset creation property list, add the Scale-Offset + * filter, set the chunk size, and set the fill value. + */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if(H5Pset_shuffle (dcpl) < 0) + TEST_ERROR + if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + TEST_ERROR + if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + TEST_ERROR + + /* + * Create a new dataset within the file using defined dataspace, little + * endian datatype and default dataset creation properties. + */ + if((dataset = H5Dcreate2(fid, DATASETNAME20, H5T_IEEE_F32LE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Write the data to the dataset using default transfer properties. + */ + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + + /* Close dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Now create a dataset with a big-endian type */ + if((dataset = H5Dcreate2(fid, DATASETNAME21, H5T_IEEE_F32BE, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* + * Close/release resources. + */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + +#else /* H5_HAVE_FILTER_SHUFFLE */ + const char *not_supported= "Shuffle filter is not enabled. Can't create the dataset."; + + puts(not_supported); +#endif /* H5_HAVE_FILTER_SHUFFLE */ + + return 0; + +#ifdef H5_HAVE_FILTER_SHUFFLE +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dataset); + } H5E_END_TRY; + + return -1; +#endif /* H5_HAVE_FILTER_SHUFFLE */ +} + + +/*------------------------------------------------------------------------- + * Function: create_nbit_dsets_float + * + * Purpose: Create a dataset of FLOAT datatype with nbit filter + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 29 March 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +create_nbit_dsets_float(hid_t fid, hid_t fsid, hid_t msid) +{ +#ifdef H5_HAVE_FILTER_NBIT + hid_t dataset; /* dataset handles */ + hid_t datatype; + hid_t dcpl; + size_t precision, offset; + float data[NX][NY]; /* data to write */ + float fillvalue = -2.2; + hsize_t chunk[RANK] = {CHUNK0, CHUNK1}; + int i, j; + + /* + * Data and output buffer initialization. + */ + for (j = 0; j < NX; j++) { + for (i = 0; i < NY; i++) + data[j][i] = ((float)(i + j + 1))/3; + } + + /* + * Create the dataset creation property list, add the Scale-Offset + * filter, set the chunk size, and set the fill value. + */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + if(H5Pset_nbit(dcpl) < 0) + TEST_ERROR + if(H5Pset_chunk(dcpl, RANK, chunk) < 0) + TEST_ERROR + if(H5Pset_fill_value(dcpl, H5T_NATIVE_FLOAT, &fillvalue) < 0) + TEST_ERROR + + /* Define user-defined single-precision floating-point type for dataset. + * A 20-bit little-endian data type. */ + if((datatype = H5Tcopy(H5T_IEEE_F32LE)) < 0) + TEST_ERROR + if(H5Tset_fields(datatype, (size_t)26, (size_t)20, (size_t)6, (size_t)7, (size_t)13) < 0) + TEST_ERROR + offset = 7; + if(H5Tset_offset(datatype,offset) < 0) + TEST_ERROR + precision = 20; + if(H5Tset_precision(datatype,precision) < 0) + TEST_ERROR + if(H5Tset_size(datatype, (size_t)4) < 0) + TEST_ERROR + if(H5Tset_ebias(datatype, (size_t)31) < 0) + TEST_ERROR + + /* + * Create a new dataset within the file using defined dataspace, + * user-defined datatype, and default dataset creation properties. + */ + if((dataset = H5Dcreate2(fid, DATASETNAME22, datatype, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* + * Write the data to the dataset using default transfer properties. + */ + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + + /* Close dataset */ + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* Now create a dataset with a big-endian type */ + if(H5Tset_order(datatype, H5T_ORDER_BE) < 0) + TEST_ERROR + if((dataset = H5Dcreate2(fid, DATASETNAME23, datatype, fsid, + H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dwrite(dataset, H5T_NATIVE_FLOAT, msid, fsid, H5P_DEFAULT, data) < 0) + TEST_ERROR + if(H5Dclose(dataset) < 0) + TEST_ERROR + + /* + * Close/release resources. + */ + if(H5Pclose(dcpl) < 0) + TEST_ERROR + +#else /* H5_HAVE_FILTER_NBIT */ + const char *not_supported= "Nbit filter is not enabled. Can't create the dataset."; + + puts(not_supported); +#endif /* H5_HAVE_FILTER_NBIT */ + + return 0; + +#ifdef H5_HAVE_FILTER_NBIT +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dataset); + } H5E_END_TRY; + + return -1; +#endif /* H5_HAVE_FILTER_NBIT */ +} + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Create a file for cross_read.c test. @@ -853,6 +1416,27 @@ main (void) if(create_scale_offset_dsets_long_long(file, filespace, memspace) < 0) {H5_FAILED(); AT(); return 1;} + /* Create a dataset of FLOAT with fletcher filter */ + if(create_fletcher_dsets_float(file, filespace, memspace) < 0) + {H5_FAILED(); AT(); return 1;} + + /* Create a dataset of FLOAT with deflate filter */ + if(create_deflate_dsets_float(file, filespace, memspace) < 0) + {H5_FAILED(); AT(); return 1;} + + /* Create a dataset of FLOAT with szip filter */ + if(create_szip_dsets_float(file, filespace, memspace) < 0) + {H5_FAILED(); AT(); return 1;} + + /* Create a dataset of FLOAT with shuffle filter */ + if(create_shuffle_dsets_float(file, filespace, memspace) < 0) + {H5_FAILED(); AT(); return 1;} + + /* Create a dataset of FLOAT with nbit filter */ + if(create_nbit_dsets_float(file, filespace, memspace) < 0) + {H5_FAILED(); AT(); return 1;} + + /* * Close/release resources. */ diff --git a/test/gen_filters.c b/test/gen_filters.c index 6d24fb3..58400d5 100644 --- a/test/gen_filters.c +++ b/test/gen_filters.c @@ -13,20 +13,38 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* +#include "h5test.h" + +#define TESTFILE1 "test_filters.h5" +#define TESTFILE2 "filter_error.h5" +#define DSETNAME "dataset_with_filter" + +/* Temporary filter IDs used for testing */ +#define H5Z_FILTER_BOGUS 305 + +/* Local prototypes for filter functions */ +static size_t filter_bogus(unsigned int flags, size_t cd_nelmts, + const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf); + + +/*------------------------------------------------------------------------- + * Function: create_file_with_bogus_filter + * + * Purpose: Create a dataset with the fletcher filter. + * This function is used to create the test file `test_filters.h5' + * which has a dataset with the "fletcher" I/O filter. This dataset + * will be used to verify the correct behavior of the library in + * the test "dsets" + * + * Return: Success: 0 + * + * Failure: -1 + * * Programmer: Pedro Vicente <pvn@ncsa.uiuc.edu> * Thursday, March 25, 2004 * - * Purpose: Create a dataset with the fletcher filter. - * This program is used to create the test file `test_filters.h5' which has - * a dataset with the "fletcher" I/O filter. This dataset will - * be used to verify the correct behavior of the library in the test "dsets" + *------------------------------------------------------------------------- */ -#include "hdf5.h" - -#define TESTFILE "test_filters.h5" - - static herr_t test_filters_endianess(void) { @@ -45,7 +63,7 @@ test_filters_endianess(void) buf[i] = 1; /* create a file using default properties */ - if((fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + if((fid = H5Fcreate(TESTFILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; /* create a data space */ if((sid = H5Screate_simple(rank, dims, NULL)) < 0) goto error; @@ -82,7 +100,109 @@ error: #endif /* H5_HAVE_FILTER_FLETCHER32 */ } /* end test_filters_endianess() */ +/* This message derives from H5Z */ +const H5Z_class2_t H5Z_BOGUS[1] = {{ + H5Z_CLASS_T_VERS, /* H5Z_class_t version */ + H5Z_FILTER_BOGUS, /* Filter id number */ + 1, 1, /* Encoding and decoding enabled */ + "bogus", /* Filter name for debugging */ + NULL, /* The "can apply" callback */ + NULL, /* The "set local" callback */ + filter_bogus, /* The actual filter function */ +}}; + +/*------------------------------------------------------------------------- + * Function: filter_bogus + * + * Purpose: A bogus compression method that doesn't do anything. + * + * Return: Success: Data chunk size + * + * Failure: 0 + * + * Programmer: Raymond Lu + * 2 June 2011 + * + *------------------------------------------------------------------------- + */ +static size_t +filter_bogus(unsigned int UNUSED flags, size_t UNUSED cd_nelmts, + const unsigned int UNUSED *cd_values, size_t nbytes, + size_t UNUSED *buf_size, void UNUSED **buf) +{ + return nbytes; +} + + +/*------------------------------------------------------------------------- + * Function: create_file_with_bogus_filter + * + * Purpose: Create a file and a dataset with a bogus filter enabled + * + * Return: Success: 0 + * + * Failure: -1 + * + * Programmer: Raymond Lu + * 2 June 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +create_file_with_bogus_filter(void) +{ + hid_t fid = -1; /* file ID */ + hid_t dsid = -1; /* dataset ID */ + hid_t sid = -1; /* dataspace ID */ + hid_t dcpl = -1; /* dataset creation property list ID */ + hsize_t dims[1] = {20}; /* dataspace dimensions */ + hsize_t chunk_dims[1] = {10}; /* chunk dimensions */ + int buf[20]; + int rank = 1; + int i; + + for(i = 0; i < 20; i++) + buf[i] = 1; + + /* create a file using default properties */ + if((fid = H5Fcreate(TESTFILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; + + /* create a data space */ + if((sid = H5Screate_simple(rank, dims, NULL)) < 0) goto error; + + /* create dcpl */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; + + /* create chunking */ + if(H5Pset_chunk(dcpl, rank, chunk_dims) < 0) goto error; + + /* register bogus filter */ + if(H5Zregister (H5Z_BOGUS) < 0) goto error; + if(H5Pset_filter(dcpl, H5Z_FILTER_BOGUS, 0, (size_t)0, NULL) < 0) goto error; + + /* create a dataset */ + if((dsid = H5Dcreate2(fid, DSETNAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) goto error; + + if(H5Dwrite(dsid, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) goto error; + + /* close */ + if(H5Pclose(dcpl) < 0) goto error; + if(H5Dclose(dsid) < 0) goto error; + if(H5Sclose(sid) < 0) goto error; + if(H5Fclose(fid) < 0) goto error; + + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl); + H5Dclose(dsid); + H5Sclose(sid); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /*------------------------------------------------------------------------- @@ -99,7 +219,20 @@ error: int main(void) { - test_filters_endianess(); + int nerrors = 0; + + nerrors += test_filters_endianess() < 0 ? 1 : 0; + nerrors += create_file_with_bogus_filter() < 0 ? 1 : 0; + + if(nerrors) + goto error; + printf("All tests passed.\n"); + return 0; + +error: + nerrors = MAX(1, nerrors); + printf("***** %d GEN_FILTERS FAILURES *****\n", nerrors); + return 1; } diff --git a/test/getname.c b/test/getname.c index 1e50dcc..fbad220 100644 --- a/test/getname.c +++ b/test/getname.c @@ -72,7 +72,7 @@ check_name(hid_t id, const char *chk_name, const char *chk_user_path) /* Get user path */ *user_path = '\0'; - if(H5G_user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) TEST_ERROR + if(H5G__user_path_test(id, user_path, &user_path_len, &user_path_hidden) < 0) TEST_ERROR /* Check on name from H5Iget_name() */ if(HDstrcmp(name, chk_name)) goto error; @@ -2518,7 +2518,7 @@ test_obj_ref(hid_t fapl) FAIL_STACK_ERROR TESTING("getting path to normal dataset in root group"); - if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[0])) < 0) FAIL_STACK_ERROR + if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[0])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR @@ -2530,7 +2530,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in /Group1"); - if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR + if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR @@ -2542,7 +2542,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to /Group1"); - if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[2])) < 0) FAIL_STACK_ERROR + if((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[2])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(group, (char*)buf, sizeof(buf)); if(H5Gclose(group) < 0) FAIL_STACK_ERROR @@ -2554,7 +2554,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to datatype in /Group1"); - if((tid1 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[3])) < 0) FAIL_STACK_ERROR + if((tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[3])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(tid1, (char*)buf, sizeof(buf)); if(H5Tclose(tid1) < 0) FAIL_STACK_ERROR @@ -2566,7 +2566,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset in nested group"); - if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR + if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR @@ -2578,7 +2578,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to nested group"); - if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[5])) < 0) FAIL_STACK_ERROR + if((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[5])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(group, (char*)buf, sizeof(buf)); if(H5Gclose(group) < 0) FAIL_STACK_ERROR @@ -2590,7 +2590,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to dataset created via hard link"); - if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[6])) < 0) FAIL_STACK_ERROR + if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[6])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR @@ -2602,7 +2602,7 @@ test_obj_ref(hid_t fapl) HDmemset(buf, 0, sizeof(buf)); TESTING("getting path to root group"); - if((group = H5Rdereference(dataset, H5R_OBJECT, &wbuf[7])) < 0) FAIL_STACK_ERROR + if((group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[7])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(group, (char*)buf, sizeof(buf)); if(H5Gclose(group) < 0) FAIL_STACK_ERROR @@ -2617,7 +2617,7 @@ test_obj_ref(hid_t fapl) FAIL_STACK_ERROR TESTING("getting path to dataset hidden by a mounted file"); - if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR + if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[4])) < 0) FAIL_STACK_ERROR *buf = '\0'; i = H5Iget_name(dataset2, (char*)buf, sizeof(buf)); if(H5Dclose(dataset2) < 0) FAIL_STACK_ERROR @@ -2628,7 +2628,7 @@ test_obj_ref(hid_t fapl) PASSED() /* Now we try unlinking dataset2 from the file and searching for it. It shouldn't be found */ - if((dataset2 = H5Rdereference(dataset, H5R_OBJECT, &wbuf[1])) < 0) + if((dataset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &wbuf[1])) < 0) FAIL_STACK_ERROR if(H5Ldelete(fid1, "/Group1/Dataset2", H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -2768,7 +2768,7 @@ test_reg_ref(hid_t fapl) TESTING("H5Iget_name to get name from region reference(hyperslab)"); /* Dereference the first reference */ - dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[0]); + dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[0]); /* Get name of the dataset the first region reference points using H5Iget_name */ *buf2 = '\0'; @@ -2789,7 +2789,7 @@ test_reg_ref(hid_t fapl) TESTING("H5Iget_name to get name from region reference(pnt selec)"); /* Dereference the second reference */ - if((dsetv_id = H5Rdereference(dsetr_id, H5R_DATASET_REGION, &ref_out[1])) < 0) TEST_ERROR + if((dsetv_id = H5Rdereference2(dsetr_id, H5P_DEFAULT, H5R_DATASET_REGION, &ref_out[1])) < 0) TEST_ERROR /* Get name of the dataset the first region reference points using H5Iget_name */ *buf2 = '\0'; diff --git a/test/h5test.c b/test/h5test.c index ae864f0..7faba81 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -17,11 +17,11 @@ * Programmer: Robb Matzke <matzke@llnl.gov> * Thursday, November 19, 1998 * - * Purpose: Provides support functions for most of the hdf5 tests cases. + * Purpose: Provides support functions for most of the hdf5 tests cases. * */ -#undef NDEBUG /*override -DNDEBUG */ +#undef NDEBUG /*override -DNDEBUG */ #include <sys/types.h> #include <sys/stat.h> #include "h5test.h" @@ -32,35 +32,33 @@ #define H5G_TESTING #include "H5Gpkg.h" -#ifdef H5_HAVE_WINSOCK_H +#ifdef H5_HAVE_WIN32_API #include <process.h> -#include <direct.h> -#include <winsock2.h> -#endif /* H5_HAVE_WINSOCK_H */ +#endif /* H5_HAVE_WIN32_API */ /* * Define these environment variables or constants to influence functions in * this test support library. The environment variable is used in preference * to the cpp constant. If neither is defined then use some default value. * - * HDF5_DRIVER: This string describes what low level file driver to - * use for HDF5 file access. The first word in the - * value is the name of the driver and subsequent data - * is interpreted according to the driver. See - * h5_fileaccess() for details. - * - * HDF5_PREFIX: A string to add to the beginning of all serial test - * file names. This can be used to run tests in a - * different file system (e.g., "/tmp" or "/tmp/myname"). - * The prefix will be separated from the base file name - * by a slash. See h5_fixname() for details. - * - * HDF5_PARAPREFIX: A string to add to the beginning of all parallel test - * file names. This can be used to tell MPIO what driver - * to use (e.g., "gfs:", "ufs:", or "nfs:") or to use a - * different file system (e.g., "/tmp" or "/tmp/myname"). - * The prefix will be separated from the base file name - * by a slash. See h5_fixname() for details. + * HDF5_DRIVER: This string describes what low level file driver to + * use for HDF5 file access. The first word in the + * value is the name of the driver and subsequent data + * is interpreted according to the driver. See + * h5_fileaccess() for details. + * + * HDF5_PREFIX: A string to add to the beginning of all serial test + * file names. This can be used to run tests in a + * different file system (e.g., "/tmp" or "/tmp/myname"). + * The prefix will be separated from the base file name + * by a slash. See h5_fixname() for details. + * + * HDF5_PARAPREFIX: A string to add to the beginning of all parallel test + * file names. This can be used to tell MPIO what driver + * to use (e.g., "gfs:", "ufs:", or "nfs:") or to use a + * different file system (e.g., "/tmp" or "/tmp/myname"). + * The prefix will be separated from the base file name + * by a slash. See h5_fixname() for details. * */ /* @@ -72,7 +70,7 @@ #ifndef HDF5_PARAPREFIX #define HDF5_PARAPREFIX "" #endif -char *paraprefix = NULL; /* for command line option para-prefix */ +char *paraprefix = NULL; /* for command line option para-prefix */ #ifdef H5_HAVE_PARALLEL MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ #endif @@ -84,13 +82,13 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ * These are the letters that are appended to the file name when generating * names for the split and multi drivers. They are: * - * m: All meta data when using the split driver. - * s: The userblock, superblock, and driver info block - * b: B-tree nodes - * r: Dataset raw data - * g: Global heap - * l: local heap (object names) - * o: object headers + * m: All meta data when using the split driver. + * s: The userblock, superblock, and driver info block + * b: B-tree nodes + * r: Dataset raw data + * g: Global heap + * l: local heap (object names) + * o: object headers */ static const char *multi_letters = "msbrglo"; @@ -98,16 +96,16 @@ static herr_t h5_errors(hid_t estack, void *client_data); /*------------------------------------------------------------------------- - * Function: h5_errors + * Function: h5_errors * - * Purpose: Displays the error stack after printing "*FAILED*". + * Purpose: Displays the error stack after printing "*FAILED*". * - * Return: Success: 0 + * Return: Success: 0 * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke - * Wednesday, March 4, 1998 + * Programmer: Robb Matzke + * Wednesday, March 4, 1998 * * Modifications: * @@ -123,50 +121,50 @@ h5_errors(hid_t estack, void UNUSED *client_data) /*------------------------------------------------------------------------- - * Function: h5_cleanup + * Function: h5_cleanup * - * Purpose: Cleanup temporary test files. - * base_name contains the list of test file names. - * The file access property list is also closed. + * Purpose: Cleanup temporary test files. + * base_name contains the list of test file names. + * The file access property list is also closed. * - * Return: Non-zero if cleanup actions were performed; zero otherwise. + * Return: Non-zero if cleanup actions were performed; zero otherwise. * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * May 28, 1998 * * Modifications: - * Albert Cheng, 2000-09-09 - * Added the explicite base_name argument to replace the - * global variable FILENAME. + * Albert Cheng, 2000-09-09 + * Added the explicite base_name argument to replace the + * global variable FILENAME. * *------------------------------------------------------------------------- */ int h5_cleanup(const char *base_name[], hid_t fapl) { - char filename[1024]; - char temp[2048]; - int i, j; - int retval=0; - hid_t driver; + char filename[1024]; + char temp[2048]; + int i, j; + int retval=0; + hid_t driver; if (GetTestCleanup()){ - for (i = 0; base_name[i]; i++) { - if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) - continue; + for (i = 0; base_name[i]; i++) { + if (h5_fixname(base_name[i], fapl, filename, sizeof(filename)) == NULL) + continue; driver = H5Pget_driver(fapl); - if (driver == H5FD_FAMILY) { - for (j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); + if (driver == H5FD_FAMILY) { + for (j = 0; /*void*/; j++) { + HDsnprintf(temp, sizeof temp, filename, j); - if (HDaccess(temp, F_OK) < 0) + if (HDaccess(temp, F_OK) < 0) break; - HDremove(temp); - } - } else if (driver == H5FD_CORE) { + HDremove(temp); + } + } else if (driver == H5FD_CORE) { hbool_t backing; /* Whether the core file has backing store */ H5Pget_fapl_core(fapl,NULL,&backing); @@ -175,21 +173,21 @@ h5_cleanup(const char *base_name[], hid_t fapl) if(backing) HDremove(filename); - } else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; - assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - - for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", - filename, multi_letters[mt]); - HDremove(temp); /*don't care if it fails*/ - } - } else { - HDremove(filename); - } - } - - retval = 1; + } else if (driver == H5FD_MULTI) { + H5FD_mem_t mt; + assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + + for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { + HDsnprintf(temp, sizeof temp, "%s-%c.h5", + filename, multi_letters[mt]); + HDremove(temp); /*don't care if it fails*/ + } + } else { + HDremove(filename); + } + } + + retval = 1; } H5Pclose(fapl); @@ -198,13 +196,13 @@ h5_cleanup(const char *base_name[], hid_t fapl) /*------------------------------------------------------------------------- - * Function: h5_reset + * Function: h5_reset * - * Purpose: Reset the library by closing it. + * Purpose: Reset the library by closing it. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: @@ -230,7 +228,7 @@ h5_reset(void) */ #ifdef OLD_WAY { - char filename[1024]; + char filename[1024]; /* * Cause the library to emit some diagnostics early so they don't @@ -238,12 +236,12 @@ h5_reset(void) */ sprintf(filename, "/tmp/h5emit-%05d.h5", HDgetpid()); H5E_BEGIN_TRY { - hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, - H5P_DEFAULT); - hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(grp); - H5Fclose(file); - HDunlink(filename); + hid_t file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, + H5P_DEFAULT); + hid_t grp = H5Gcreate2(file, "emit", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + H5Gclose(grp); + H5Fclose(file); + HDunlink(filename); } H5E_END_TRY; } #endif /* OLD_WAY */ @@ -251,34 +249,34 @@ h5_reset(void) /*------------------------------------------------------------------------- - * Function: h5_fixname + * Function: h5_fixname * - * Purpose: Create a file name from a file base name like `test' and - * return it through the FULLNAME (at most SIZE characters - * counting the null terminator). The full name is created by - * prepending the contents of HDF5_PREFIX (separated from the - * base name by a slash) and appending a file extension based on - * the driver supplied, resulting in something like - * `ufs:/u/matzke/test.h5'. + * Purpose: Create a file name from a file base name like `test' and + * return it through the FULLNAME (at most SIZE characters + * counting the null terminator). The full name is created by + * prepending the contents of HDF5_PREFIX (separated from the + * base name by a slash) and appending a file extension based on + * the driver supplied, resulting in something like + * `ufs:/u/matzke/test.h5'. * - * Return: Success: The FULLNAME pointer. + * Return: Success: The FULLNAME pointer. * - * Failure: NULL if BASENAME or FULLNAME is the null - * pointer or if FULLNAME isn't large enough for - * the result. + * Failure: NULL if BASENAME or FULLNAME is the null + * pointer or if FULLNAME isn't large enough for + * the result. * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, November 19, 1998 * * Modifications: - * Robb Matzke, 1999-08-03 - * Modified to use the virtual file layer. + * Robb Matzke, 1999-08-03 + * Modified to use the virtual file layer. * - * Albert Cheng, 2000-01-25 - * Added prefix for parallel test files. + * Albert Cheng, 2000-01-25 + * Added prefix for parallel test files. * - * Albert Cheng, 2003-05-08 - * Changed the default parallel prefix back to NULL but added + * Albert Cheng, 2003-05-08 + * Changed the default parallel prefix back to NULL but added * an explanation remark of $HDF5_PARAPREFIX. *------------------------------------------------------------------------- */ @@ -290,7 +288,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) char *ptr, last = '\0'; size_t i, j; hid_t driver = -1; - int isppdriver = 0; /* if the driver is MPI parallel */ + int isppdriver = 0; /* if the driver is MPI parallel */ if (!base_name || !fullname || size < 1) return NULL; @@ -299,20 +297,20 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* figure out the suffix */ if (H5P_DEFAULT != fapl) { - if ((driver = H5Pget_driver(fapl)) < 0) + if ((driver = H5Pget_driver(fapl)) < 0) return NULL; - if (H5FD_FAMILY == driver) - suffix = "%05d.h5"; - else if (H5FD_MULTI == driver) - suffix = NULL; + if (H5FD_FAMILY == driver) + suffix = "%05d.h5"; + else if (H5FD_MULTI == driver) + suffix = NULL; } /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX * could be of value -1 if it is not defined. */ isppdriver = H5P_DEFAULT != fapl && - (H5FD_MPIO==driver || H5FD_MPIPOSIX==driver); + (H5FD_MPIO==driver || H5FD_MPIPOSIX==driver); /* Check HDF5_NOCLEANUP environment setting. * (The #ifdef is needed to prevent compile failure in case MPI is not @@ -320,12 +318,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) */ if (isppdriver){ #ifdef H5_HAVE_PARALLEL - if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) - SetTestNoCleanup(); + if (getenv_all(MPI_COMM_WORLD, 0, "HDF5_NOCLEANUP")) + SetTestNoCleanup(); #endif /* H5_HAVE_PARALLEL */ }else{ - if (HDgetenv("HDF5_NOCLEANUP")) - SetTestNoCleanup(); + if (HDgetenv("HDF5_NOCLEANUP")) + SetTestNoCleanup(); } /* Check what prefix to use for test files. Process HDF5_PARAPREFIX and @@ -336,52 +334,52 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) */ if (isppdriver){ #ifdef H5_HAVE_PARALLEL - /* + /* * For parallel: * First use command line option, then the environment * variable, then try the constant - */ + */ static int explained = 0; - prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); + prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); - if (!prefix && !explained) { - /* print hint by process 0 once. */ - int mpi_rank; + if (!prefix && !explained) { + /* print hint by process 0 once. */ + int mpi_rank; - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - if (mpi_rank == 0) - printf("*** Hint ***\n" - "You can use environment variable HDF5_PARAPREFIX to " - "run parallel test files in a\n" - "different directory or to add file type prefix. E.g.,\n" - " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" - " export HDF5_PARAPREFIX\n" - "*** End of Hint ***\n"); + if (mpi_rank == 0) + printf("*** Hint ***\n" + "You can use environment variable HDF5_PARAPREFIX to " + "run parallel test files in a\n" + "different directory or to add file type prefix. E.g.,\n" + " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" + " export HDF5_PARAPREFIX\n" + "*** End of Hint ***\n"); - explained = TRUE; + explained = TRUE; #ifdef HDF5_PARAPREFIX prefix = HDF5_PARAPREFIX; #endif /* HDF5_PARAPREFIX */ - } + } #endif /* H5_HAVE_PARALLEL */ } else { - /* + /* * For serial: * First use the environment variable, then try the constant - */ - prefix = HDgetenv("HDF5_PREFIX"); + */ + prefix = HDgetenv("HDF5_PREFIX"); #ifdef HDF5_PREFIX - if (!prefix) + if (!prefix) prefix = HDF5_PREFIX; #endif /* HDF5_PREFIX */ } /* Prepend the prefix value to the base name */ if (prefix && *prefix) { - if (isppdriver){ + if (isppdriver){ /* This is a parallel system */ char *subdir; @@ -441,18 +439,18 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) return NULL; } } else if (HDstrlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; + /* Buffer is too small */ + return NULL; } else { - HDstrcpy(fullname, base_name); + HDstrcpy(fullname, base_name); } /* Append a suffix */ if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) + if (HDstrlen(fullname) + HDstrlen(suffix) >= size) return NULL; - HDstrcat(fullname, suffix); + HDstrcat(fullname, suffix); } /* Remove any double slashes in the filename */ @@ -468,19 +466,19 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /*------------------------------------------------------------------------- - * Function: h5_rmprefix + * Function: h5_rmprefix * - * Purpose: This "removes" the MPIO driver prefix part of the file name - * by returning a pointer that points at the non-prefix component + * Purpose: This "removes" the MPIO driver prefix part of the file name + * by returning a pointer that points at the non-prefix component * part of the file name. E.g., - * Input Return - * pfs:/scratch1/dataX /scratch1/dataX - * /scratch2/dataY /scratch2/dataY - * Note that there is no change to the original file name. + * Input Return + * pfs:/scratch1/dataX /scratch1/dataX + * /scratch2/dataY /scratch2/dataY + * Note that there is no change to the original file name. * - * Return: Success: a pointer at the non-prefix part. + * Return: Success: a pointer at the non-prefix part. * - * Programmer: Albert Cheng; Jun 1, 2006 + * Programmer: Albert Cheng; Jun 1, 2006 * *------------------------------------------------------------------------- */ @@ -490,26 +488,26 @@ h5_rmprefix(const char *filename) const char *ret_ptr; if ((ret_ptr = HDstrstr(filename, ":")) == NULL) - ret_ptr = filename; + ret_ptr = filename; else - ret_ptr++; + ret_ptr++; return(ret_ptr); } /*------------------------------------------------------------------------- - * Function: h5_fileaccess + * Function: h5_fileaccess * - * Purpose: Returns a file access template which is the default template - * but with a file driver set according to the constant or - * environment variable HDF5_DRIVER + * Purpose: Returns a file access template which is the default template + * but with a file driver set according to the constant or + * environment variable HDF5_DRIVER * - * Return: Success: A file access property list + * Return: Success: A file access property list * - * Failure: -1 + * Failure: -1 * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, November 19, 1998 * * Modifications: @@ -519,8 +517,8 @@ h5_rmprefix(const char *filename) hid_t h5_fileaccess(void) { - const char *val = NULL; - const char *name; + const char *val = NULL; + const char *name; char s[1024]; hid_t fapl = -1; @@ -538,53 +536,53 @@ h5_fileaccess(void) if (NULL==(name=HDstrtok(s, " \t\n\r"))) return fapl; if (!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl)<0) return -1; + /* Unix read() and write() system calls */ + if (H5Pset_fapl_sec2(fapl)<0) return -1; } else if (!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl)<0) return -1; + /* Standard C fread() and fwrite() system calls */ + if (H5Pset_fapl_stdio(fapl)<0) return -1; } else if (!HDstrcmp(name, "core")) { - /* In-core temporary file with 1MB increment */ - if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1; + /* In-core temporary file with 1MB increment */ + if (H5Pset_fapl_core(fapl, (size_t)1, TRUE)<0) return -1; } else if (!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if (H5Pset_fapl_split(fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT)<0) - return -1; + /* Split meta data and raw data each using default driver */ + if (H5Pset_fapl_split(fapl, + "-m.h5", H5P_DEFAULT, + "-r.h5", H5P_DEFAULT)<0) + return -1; } else if (!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); - - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { - memb_fapl[mt] = H5P_DEFAULT; - sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); - } /* end for */ - - if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE)<0) { - return -1; - } + /* Multi-file driver, general case of the split driver */ + H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][1024]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + H5FD_mem_t mt; + + HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_fapl, 0, sizeof memb_fapl); + HDmemset(memb_name, 0, sizeof memb_name); + HDmemset(memb_addr, 0, sizeof memb_addr); + + HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { + memb_fapl[mt] = H5P_DEFAULT; + sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); + memb_name[mt] = sv[mt]; + memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); + } /* end for */ + + if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, + memb_addr, FALSE)<0) { + return -1; + } } else if (!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ - /* Family of files, each 1MB and using the default driver */ - if ((val=HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) + /* Family of files, each 1MB and using the default driver */ + if ((val=HDstrtok(NULL, " \t\n\r"))) + fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); + if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) return -1; } else if (!HDstrcmp(name, "log")) { unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; @@ -594,20 +592,20 @@ h5_fileaccess(void) log_flags = (unsigned)HDstrtol(val, NULL, 0); if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) - return -1; + return -1; } else if (!HDstrcmp(name, "direct")) { #ifdef H5_HAVE_DIRECT - /* Linux direct read() and write() system calls. Set memory boundary, file block size, - * and copy buffer size to the default values. */ - if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1; + /* Linux direct read() and write() system calls. Set memory boundary, file block size, + * and copy buffer size to the default values. */ + if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1; #endif } else if(!HDstrcmp(name, "latest")) { - /* use the latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + /* use the latest format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) return -1; } else { - /* Unknown driver */ - return -1; + /* Unknown driver */ + return -1; } return fapl; @@ -615,13 +613,13 @@ h5_fileaccess(void) /*------------------------------------------------------------------------- - * Function: h5_no_hwconv + * Function: h5_no_hwconv * - * Purpose: Turn off hardware data type conversions. + * Purpose: Turn off hardware data type conversions. * - * Return: void + * Return: void * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, November 20, 1998 * * Modifications: @@ -636,13 +634,13 @@ h5_no_hwconv(void) /*------------------------------------------------------------------------- - * Function: h5_show_hostname + * Function: h5_show_hostname * - * Purpose: Show hostname. Show process ID if in MPI environment. + * Purpose: Show hostname. Show process ID if in MPI environment. * - * Return: void + * Return: void * - * Programmer: Albert Cheng + * Programmer: Albert Cheng * 2002/04/22 * * Modifications: @@ -652,8 +650,8 @@ h5_no_hwconv(void) void h5_show_hostname(void) { - char hostname[80]; -#ifdef H5_HAVE_WINSOCK_H + char hostname[80]; +#ifdef H5_HAVE_WIN32_API WSADATA wsaData; int err; #endif @@ -661,21 +659,21 @@ h5_show_hostname(void) /* try show the process or thread id in multiple processes cases*/ #ifdef H5_HAVE_PARALLEL { - int mpi_rank, mpi_initialized; - - MPI_Initialized(&mpi_initialized); - if (mpi_initialized){ - MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); - printf("MPI-process %d.", mpi_rank); - }else - printf("thread 0."); + int mpi_rank, mpi_initialized; + + MPI_Initialized(&mpi_initialized); + if (mpi_initialized){ + MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); + printf("MPI-process %d.", mpi_rank); + }else + printf("thread 0."); } #elif defined(H5_HAVE_THREADSAFE) printf("thread %lu.", HDpthread_self_ulong()); #else printf("thread 0."); #endif -#ifdef H5_HAVE_WINSOCK_H +#ifdef H5_HAVE_WIN32_API err = WSAStartup( MAKEWORD(2,2), &wsaData ); if ( err != 0 ) { @@ -699,13 +697,13 @@ h5_show_hostname(void) #endif #ifdef H5_HAVE_GETHOSTNAME if (gethostname(hostname, (size_t)80) < 0) - printf(" gethostname failed\n"); + printf(" gethostname failed\n"); else - printf(" hostname=%s\n", hostname); + printf(" hostname=%s\n", hostname); #else printf(" gethostname not supported\n"); #endif -#ifdef H5_HAVE_WINSOCK_H +#ifdef H5_HAVE_WIN32_API WSACleanup(); #endif } @@ -728,8 +726,8 @@ h5_show_hostname(void) int h5_set_info_object(void) { - char *envp; /* environment pointer */ - int ret_value=0; + char *envp; /* environment pointer */ + int ret_value=0; /* handle any MPI INFO hints via $HDF5_MPI_INFO */ if ((envp = getenv("HDF5_MPI_INFO")) != NULL){ @@ -816,39 +814,39 @@ h5_set_info_object(void) void h5_dump_info_object(MPI_Info info) { - char key[MPI_MAX_INFO_KEY+1]; - char value[MPI_MAX_INFO_VAL+1]; - int flag; - int i, nkeys; + char key[MPI_MAX_INFO_KEY+1]; + char value[MPI_MAX_INFO_VAL+1]; + int flag; + int i, nkeys; printf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info, - MPI_MAX_INFO_VAL); + MPI_MAX_INFO_VAL); if (info==MPI_INFO_NULL){ - printf("object is MPI_INFO_NULL\n"); + printf("object is MPI_INFO_NULL\n"); } else { - MPI_Info_get_nkeys(info, &nkeys); - printf("object has %d items\n", nkeys); - for (i=0; i<nkeys; i++){ - MPI_Info_get_nthkey(info, i, key); - MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag); - printf("%s=%s\n", key, value); - } + MPI_Info_get_nkeys(info, &nkeys); + printf("object has %d items\n", nkeys); + for (i=0; i<nkeys; i++){ + MPI_Info_get_nthkey(info, i, key); + MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag); + printf("%s=%s\n", key, value); + } } } -#endif /* H5_HAVE_PARALLEL */ +#endif /* H5_HAVE_PARALLEL */ /*------------------------------------------------------------------------- - * Function: h5_get_file_size + * Function: h5_get_file_size * - * Purpose: Get the current size of a file (in bytes) + * Purpose: Get the current size of a file (in bytes) * - * Return: Success: Size of file in bytes - * Failure: -1 + * Return: Success: Size of file in bytes + * Failure: -1 * - * Programmer: Quincey Koziol + * Programmer: Quincey Koziol * Saturday, March 22, 2003 * *------------------------------------------------------------------------- @@ -857,8 +855,8 @@ h5_stat_size_t h5_get_file_size(const char *filename, hid_t fapl) { char temp[2048]; /* Temporary buffer for file names */ - h5_stat_t sb; /* Structure for querying file info */ - int j = 0; + h5_stat_t sb; /* Structure for querying file info */ + int j = 0; if(fapl == H5P_DEFAULT) { /* Get the file's statistics */ @@ -866,7 +864,7 @@ h5_get_file_size(const char *filename, hid_t fapl) return((h5_stat_size_t)sb.st_size); } /* end if */ else { - hid_t driver; /* VFD used for file */ + hid_t driver; /* VFD used for file */ /* Get the driver used when creating the file */ if((driver = H5Pget_driver(fapl)) < 0) @@ -950,26 +948,26 @@ h5_get_file_size(const char *filename, hid_t fapl) int print_func(const char *format, ...) { - va_list arglist; - int ret_value; + va_list arglist; + int ret_value; - va_start(arglist, format); - ret_value = vprintf(format, arglist); - va_end(arglist); - return ret_value; + va_start(arglist, format); + ret_value = vprintf(format, arglist); + va_end(arglist); + return ret_value; } #ifdef H5_HAVE_FILTER_SZIP /*------------------------------------------------------------------------- - * Function: h5_szip_can_encode + * Function: h5_szip_can_encode * - * Purpose: Retrieve the filter config flags for szip, tell if + * Purpose: Retrieve the filter config flags for szip, tell if * encoder is available. * - * Return: 1: decode+encode is enabled - * 0: only decode is enabled + * Return: 1: decode+encode is enabled + * 0: only decode is enabled * -1: other * * Programmer: @@ -1008,28 +1006,28 @@ int h5_szip_can_encode(void ) #ifdef H5_HAVE_PARALLEL /*------------------------------------------------------------------------- - * Function: getenv_all + * Function: getenv_all * - * Purpose: Used to get the environment that the root MPI task has. - * name specifies which environment variable to look for - * val is the string to which the value of that environment - * variable will be copied. + * Purpose: Used to get the environment that the root MPI task has. + * name specifies which environment variable to look for + * val is the string to which the value of that environment + * variable will be copied. * - * NOTE: The pointer returned by this function is only - * valid until the next call to getenv_all and the data - * stored there must be copied somewhere else before any - * further calls to getenv_all take place. + * NOTE: The pointer returned by this function is only + * valid until the next call to getenv_all and the data + * stored there must be copied somewhere else before any + * further calls to getenv_all take place. * - * Return: pointer to a string containing the value of the environment variable - * NULL if the varialbe doesn't exist in task 'root's environment. + * Return: pointer to a string containing the value of the environment variable + * NULL if the varialbe doesn't exist in task 'root's environment. * - * Programmer: Leon Arber + * Programmer: Leon Arber * 4/4/05 * * Modifications: - * Use original getenv if MPI is not initialized. This happens - * one uses the PHDF5 library to build a serial nature code. - * Albert 2006/04/07 + * Use original getenv if MPI is not initialized. This happens + * one uses the PHDF5 library to build a serial nature code. + * Albert 2006/04/07 * *------------------------------------------------------------------------- */ @@ -1044,48 +1042,48 @@ getenv_all(MPI_Comm comm, int root, const char* name) MPI_Initialized(&mpi_initialized); if(!mpi_initialized) { - /* use original getenv */ - if(env) - HDfree(env); - env = HDgetenv(name); + /* use original getenv */ + if(env) + HDfree(env); + env = HDgetenv(name); } /* end if */ else { - MPI_Comm_rank(comm, &mpi_rank); - MPI_Comm_size(comm, &mpi_size); - assert(root < mpi_size); - - /* The root task does the getenv call - * and sends the result to the other tasks */ - if(mpi_rank == root) { - env = HDgetenv(name); - if(env) { - len = HDstrlen(env); - MPI_Bcast(&len, 1, MPI_INT, root, comm); - MPI_Bcast(env, len, MPI_CHAR, root, comm); - } - else { - /* len -1 indicates that the variable was not in the environment */ - len = -1; - MPI_Bcast(&len, 1, MPI_INT, root, comm); - } - } - else { - MPI_Bcast(&len, 1, MPI_INT, root, comm); - if(len >= 0) { - if(env == NULL) - env = (char*) HDmalloc(len+1); - else if(strlen(env) < len) - env = (char*) HDrealloc(env, len+1); - - MPI_Bcast(env, len, MPI_CHAR, root, comm); - env[len] = '\0'; - } - else { - if(env) - HDfree(env); - env = NULL; - } - } + MPI_Comm_rank(comm, &mpi_rank); + MPI_Comm_size(comm, &mpi_size); + assert(root < mpi_size); + + /* The root task does the getenv call + * and sends the result to the other tasks */ + if(mpi_rank == root) { + env = HDgetenv(name); + if(env) { + len = HDstrlen(env); + MPI_Bcast(&len, 1, MPI_INT, root, comm); + MPI_Bcast(env, len, MPI_CHAR, root, comm); + } + else { + /* len -1 indicates that the variable was not in the environment */ + len = -1; + MPI_Bcast(&len, 1, MPI_INT, root, comm); + } + } + else { + MPI_Bcast(&len, 1, MPI_INT, root, comm); + if(len >= 0) { + if(env == NULL) + env = (char*) HDmalloc(len+1); + else if(strlen(env) < len) + env = (char*) HDrealloc(env, len+1); + + MPI_Bcast(env, len, MPI_CHAR, root, comm); + env[len] = '\0'; + } + else { + if(env) + HDfree(env); + env = NULL; + } + } } #ifndef NDEBUG @@ -1118,7 +1116,7 @@ getenv_all(MPI_Comm comm, int root, const char* name) *------------------------------------------------------------------------- */ hid_t -h5_make_local_copy(char *origfilename, char *local_copy_name) +h5_make_local_copy(const char *origfilename, const char *local_copy_name) { int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ ssize_t nread; /* Number of bytes read in */ @@ -1175,7 +1173,7 @@ h5_verify_cached_stabs_cb(hid_t oid, const char UNUSED *name, const H5O_info_t *oinfo, void UNUSED *udata) { if(oinfo->type == H5O_TYPE_GROUP) - return(H5G_verify_cached_stabs_test(oid)); + return(H5G__verify_cached_stabs_test(oid)); else return(0); } /* end h5_verify_cached_stabs_cb() */ diff --git a/test/h5test.h b/test/h5test.h index 5d3fb17..dd38546 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -61,18 +61,18 @@ /* Should be used internally by the libtest.a only. */ #define HDGetTestVerbosity() (TestVerbosity) -#define VERBOSE_NONE (HDGetTestVerbosity()==VERBO_NONE) -#define VERBOSE_DEF (HDGetTestVerbosity()>=VERBO_DEF) -#define VERBOSE_LO (HDGetTestVerbosity()>=VERBO_LO) -#define VERBOSE_MED (HDGetTestVerbosity()>=VERBO_MED) -#define VERBOSE_HI (HDGetTestVerbosity()>=VERBO_HI) +#define VERBOSE_NONE (HDGetTestVerbosity()==VERBO_NONE) +#define VERBOSE_DEF (HDGetTestVerbosity()>=VERBO_DEF) +#define VERBOSE_LO (HDGetTestVerbosity()>=VERBO_LO) +#define VERBOSE_MED (HDGetTestVerbosity()>=VERBO_MED) +#define VERBOSE_HI (HDGetTestVerbosity()>=VERBO_HI) /* * Test controls definitions. */ -#define SKIPTEST 1 /* Skip this test */ -#define ONLYTEST 2 /* Do only this test */ -#define BEGINTEST 3 /* Skip all tests before this test */ +#define SKIPTEST 1 /* Skip this test */ +#define ONLYTEST 2 /* Do only this test */ +#define BEGINTEST 3 /* Skip all tests before this test */ /* * This contains the filename prefix specificied as command line option for @@ -80,14 +80,14 @@ */ H5TEST_DLLVAR char *paraprefix; #ifdef H5_HAVE_PARALLEL -extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ +H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #endif /* * Print the current location on the standard output stream. */ -#define AT() printf (" at %s:%d in %s()...\n", \ - __FILE__, __LINE__, __FUNCTION__); +#define AT() printf (" at %s:%d in %s()...\n", \ + __FILE__, __LINE__, FUNC); /* * The name of the test is printed by saying TESTING("something") which will @@ -98,12 +98,12 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ * spaces. If the h5_errors() is used for automatic error handling then * the H5_FAILED() macro is invoked automatically when an API function fails. */ -#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);} -#define TESTING_2(WHAT) {printf(" Testing %-62s",WHAT); fflush(stdout);} -#define PASSED() {puts(" PASSED");fflush(stdout);} -#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} -#define H5_WARNING() {puts("*WARNING*");fflush(stdout);} -#define SKIPPED() {puts(" -SKIP-");fflush(stdout);} +#define TESTING(WHAT) {printf("Testing %-62s",WHAT); fflush(stdout);} +#define TESTING_2(WHAT) {printf(" Testing %-62s",WHAT); fflush(stdout);} +#define PASSED() {puts(" PASSED");fflush(stdout);} +#define H5_FAILED() {puts("*FAILED*");fflush(stdout);} +#define H5_WARNING() {puts("*WARNING*");fflush(stdout);} +#define SKIPPED() {puts(" -SKIP-");fflush(stdout);} #define TEST_ERROR {H5_FAILED(); AT(); goto error;} #define STACK_ERROR {H5Eprint2(H5E_DEFAULT, stdout); goto error;} #define FAIL_STACK_ERROR {H5_FAILED(); AT(); H5Eprint2(H5E_DEFAULT, stdout); \ @@ -113,9 +113,9 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ /* * Alarm definitions to wait up (terminate) a test that runs too long. */ -#define H5_ALARM_SEC 1200 /* default is 20 minutes */ -#define ALARM_ON TestAlarmOn() -#define ALARM_OFF HDalarm(0) +#define H5_ALARM_SEC 1200 /* default is 20 minutes */ +#define ALARM_ON TestAlarmOn() +#define ALARM_OFF HDalarm(0) /* * The methods to compare the equality of floating-point values: @@ -127,9 +127,9 @@ extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ * It's the test's responsibility not to pass in the value 0, which * may cause the equation to fail. */ -#define FLT_ABS_EQUAL(X,Y) ((float)fabs(X-Y)<FLT_EPSILON) -#define DBL_ABS_EQUAL(X,Y) (fabs(X-Y)<DBL_EPSILON) -#define LDBL_ABS_EQUAL(X,Y) (fabsl(X-Y)<LDBL_EPSILON) +#define FLT_ABS_EQUAL(X,Y) ((float)fabs(X-Y)<FLT_EPSILON) +#define DBL_ABS_EQUAL(X,Y) (fabs(X-Y)<DBL_EPSILON) +#define LDBL_ABS_EQUAL(X,Y) (fabsl(X-Y)<LDBL_EPSILON) #define FLT_REL_EQUAL(X,Y,M) (fabsf((Y-X)/X<M) #define DBL_REL_EQUAL(X,Y,M) (fabs((Y-X)/X)<M) @@ -142,7 +142,7 @@ extern "C" { /* Generally useful testing routines */ H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, - size_t size); + size_t size); H5TEST_DLL hid_t h5_fileaccess(void); H5TEST_DLL void h5_no_hwconv(void); H5TEST_DLL const char *h5_rmprefix(const char *filename); @@ -150,14 +150,14 @@ H5TEST_DLL void h5_reset(void); H5TEST_DLL void h5_show_hostname(void); H5TEST_DLL h5_stat_size_t h5_get_file_size(const char *filename, hid_t fapl); H5TEST_DLL int print_func(const char *format, ...); -H5TEST_DLL int h5_make_local_copy(char *origfilename, char *local_copy_name); +H5TEST_DLL int h5_make_local_copy(const char *origfilename, const char *local_copy_name); H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl); /* Routines for operating on the list of tests (for the "all in one" tests) */ H5TEST_DLL void TestUsage(void); H5TEST_DLL void AddTest(const char *TheName, void (*TheCall) (void), - void (*Cleanup) (void), const char *TheDescr, - const void *Parameters); + void (*Cleanup) (void), const char *TheDescr, + const void *Parameters); H5TEST_DLL void TestInfo(const char *ProgName); H5TEST_DLL void TestParseCmdLine(int argc, char *argv[]); H5TEST_DLL void PerformTests(void); diff --git a/test/le_data.h5 b/test/le_data.h5 Binary files differindex 1225d21..e79ab47 100644 --- a/test/le_data.h5 +++ b/test/le_data.h5 diff --git a/test/links.c b/test/links.c index cba49f4..ee635ff 100644 --- a/test/links.c +++ b/test/links.c @@ -5521,7 +5521,7 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check on root group's status */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Query the group creation properties */ if((gcpl = H5Gget_create_plist(gid)) < 0) TEST_ERROR @@ -5532,10 +5532,10 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) if(H5Lcreate_external(filename2, "/dst", gid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Check on root group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR if(nmsgs != 1) TEST_ERROR - if(H5G_has_stab_test(gid) == TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR /* Create enough objects in the root group to change it into a "dense" group */ for(u = 0; u < max_compact; u++) { @@ -5545,9 +5545,9 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) } /* end for */ /* Check on root group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Close group creation property list */ if(H5Pclose(gcpl) < 0) TEST_ERROR @@ -5587,11 +5587,11 @@ external_link_unlink_dense(hid_t fapl, hbool_t new_format) } /* end for */ /* Check on root group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR if(nmsgs != (min_dense - 1)) TEST_ERROR - if(H5G_is_new_dense_test(gid) == TRUE) TEST_ERROR - if(H5G_has_stab_test(gid) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) == TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR /* Close root group */ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR @@ -5859,7 +5859,7 @@ external_link_ride(hid_t fapl, hbool_t new_format) if((gid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check on root group's status */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Query the group creation properties */ if((gcpl = H5Gget_create_plist(gid)) < 0) TEST_ERROR @@ -5873,13 +5873,13 @@ external_link_ride(hid_t fapl, hbool_t new_format) } /* end for */ /* Check on root group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR if(new_format) { - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR } /* end if */ else { - if(H5G_has_stab_test(gid) != TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR } /* end else */ /* Create external link */ @@ -5887,9 +5887,9 @@ external_link_ride(hid_t fapl, hbool_t new_format) if(H5Lcreate_external(filename2, "/dst", gid, "src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Check on root group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Close group creation property list */ if(H5Pclose(gcpl) < 0) TEST_ERROR @@ -5941,11 +5941,11 @@ external_link_ride(hid_t fapl, hbool_t new_format) } /* end for */ /* Check on root group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR if(nmsgs != (min_dense - 1)) TEST_ERROR - if(H5G_has_stab_test(gid) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) == TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) == TRUE) TEST_ERROR /* Close root group */ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR @@ -7031,9 +7031,9 @@ external_file_cache(hid_t fapl, hbool_t new_format) if(H5F_sfile_assert_num(0) < 0) TEST_ERROR - +#ifndef H5_CANNOT_OPEN_TWICE /* - * Test 3: 3 file cycle + * Test 5: 3 file cycle */ /* Create files */ if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) @@ -7084,7 +7084,7 @@ external_file_cache(hid_t fapl, hbool_t new_format) /* - * Test 3: 3 file cycle, release parent's EFC + * Test 6: 3 file cycle, release parent's EFC */ /* Create files */ if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) @@ -7140,7 +7140,10 @@ external_file_cache(hid_t fapl, hbool_t new_format) /* Verify that all files are now closed */ if(H5F_sfile_assert_num(0) < 0) TEST_ERROR +#endif /* H5_CANNOT_OPEN_TWICE */ + /* Close fapl */ + H5Pclose(my_fapl); PASSED(); return 0; @@ -7160,6 +7163,246 @@ error: /*------------------------------------------------------------------------- + * Function: external_open_twice + * + * Purpose: Test opening the same object twice, both times through an + * external links. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Neil Fortner + * Saturday, April 30, 2011 + * + *------------------------------------------------------------------------- + */ +static int +external_open_twice(hid_t fapl, hbool_t new_format) +{ + hid_t fid1 = (-1); /* File ID */ + hid_t fid2 = (-1); /* File ID */ + hid_t oid1 = (-1); /* Object ID */ + hid_t oid2 = (-1); /* Object ID */ + hid_t type = (-1); /* Datatype ID */ + hid_t space = (-1); /* Dataspace ID */ + char filename1[NAME_BUF_SIZE]; + char filename2[NAME_BUF_SIZE]; + + if(new_format) + TESTING("opening object twice through elink (w/new group format)") + else + TESTING("opening object twice through elink") + + /* Set up filenames */ + h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); + h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2); + + + /* + * Test 1: Open root group twice + */ + /* Create files */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create link */ + if(H5Lcreate_external(filename2, "/", fid1, "link_to_2", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + + /* Close file 2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Open the target of the external link twice */ + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Close both objects, in the reverse opening order (necessary to duplicate + * bug */ + if(H5Oclose(oid2) < 0) + TEST_ERROR + if(H5Oclose(oid1) < 0) + TEST_ERROR + + /* Close file 1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Verify that both files are now closed */ + if(H5F_sfile_assert_num(0) < 0) + TEST_ERROR + + + /* + * Test 2: Open group twice + */ + /* Create files */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create target group */ + if((oid1 = H5Gcreate2(fid2, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) + < 0) + TEST_ERROR + if(H5Gclose(oid1) < 0) + TEST_ERROR + + /* Create link */ + if(H5Lcreate_external(filename2, "/group", fid1, "link_to_2", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + + /* Close file 2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Open the target of the external link twice */ + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Close both objects, in the reverse opening order (necessary to duplicate + * bug */ + if(H5Oclose(oid2) < 0) + TEST_ERROR + if(H5Oclose(oid1) < 0) + TEST_ERROR + + /* Close file 1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Verify that both files are now closed */ + if(H5F_sfile_assert_num(0) < 0) + TEST_ERROR + + + /* + * Test 3: Open dataset twice + */ + /* Create files */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create target dataset */ + if((space = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR + if((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + if(H5Dclose(oid1) < 0) + TEST_ERROR + if(H5Sclose(space) < 0) + TEST_ERROR + + /* Create link */ + if(H5Lcreate_external(filename2, "/dset", fid1, "link_to_2", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + + /* Close file 2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Open the target of the external link twice */ + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Close both objects, in the reverse opening order (necessary to duplicate + * bug */ + if(H5Oclose(oid2) < 0) + TEST_ERROR + if(H5Oclose(oid1) < 0) + TEST_ERROR + + /* Close file 1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Verify that both files are now closed */ + if(H5F_sfile_assert_num(0) < 0) + TEST_ERROR + + + /* + * Test 4: Open datatype twice + */ + /* Create files */ + if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create target datatype */ + if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) + TEST_ERROR + if(H5Tcommit2(fid2, "dtype", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) + < 0) + TEST_ERROR + if(H5Tclose(type) < 0) + TEST_ERROR + + /* Create link */ + if(H5Lcreate_external(filename2, "/dtype", fid1, "link_to_2", H5P_DEFAULT, + H5P_DEFAULT) < 0) + TEST_ERROR + + /* Close file 2 */ + if(H5Fclose(fid2) < 0) + TEST_ERROR + + /* Open the target of the external link twice */ + if((oid1 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + if((oid2 = H5Oopen(fid1, "link_to_2", H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Close both objects, in the reverse opening order (necessary to duplicate + * bug */ + if(H5Oclose(oid2) < 0) + TEST_ERROR + if(H5Oclose(oid1) < 0) + TEST_ERROR + + /* Close file 1 */ + if(H5Fclose(fid1) < 0) + TEST_ERROR + + /* Verify that both files are now closed */ + if(H5F_sfile_assert_num(0) < 0) + TEST_ERROR + + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Oclose(oid1); + H5Oclose(oid2); + H5Tclose(type); + H5Fclose(fid1); + H5Fclose(fid2); + H5Sclose(space); + } H5E_END_TRY + + return -1; +} /* end efc_open_twice */ + + +/*------------------------------------------------------------------------- * Function: ud_hard_links * * Purpose: Check that the functionality of hard links can be duplicated @@ -10015,7 +10258,7 @@ corder_create_empty(hid_t fapl) if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on group's status */ - if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -10034,7 +10277,7 @@ corder_create_empty(hid_t fapl) if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check on group's status */ - if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR /* Retrieve group creation property list for group */ if((gcpl_id = H5Gget_create_plist(group_id)) < 0) TEST_ERROR @@ -10108,9 +10351,9 @@ corder_create_compact(hid_t fapl) if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on group's initial status */ - if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR /* Query the group creation properties */ if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR @@ -10122,10 +10365,10 @@ corder_create_compact(hid_t fapl) if(H5Gclose(group_id2) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR if(nlinks != (u + 1)) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR } /* end for */ /* Close the group */ @@ -10145,10 +10388,10 @@ corder_create_compact(hid_t fapl) if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR if(nlinks != max_compact) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR /* Loop through links, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ @@ -10228,9 +10471,9 @@ corder_create_dense(hid_t fapl) if((group_id = H5Gcreate2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on group's initial status */ - if(H5G_is_empty_test(group_id) != TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_empty_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR /* Query the group creation properties */ if(H5Pget_link_phase_change(gcpl_id, &max_compact, &min_dense) < 0) TEST_ERROR @@ -10242,10 +10485,10 @@ corder_create_dense(hid_t fapl) if(H5Gclose(group_id2) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR if(nlinks != (u + 1)) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR } /* end for */ /* Create another link, to push group into dense form */ @@ -10254,12 +10497,12 @@ corder_create_dense(hid_t fapl) if(H5Gclose(group_id2) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR /* Close the group */ @@ -10279,9 +10522,9 @@ corder_create_dense(hid_t fapl) if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Loop through links, checking their creation order values */ /* (the name index is used, but the creation order value is in the same order) */ @@ -10402,12 +10645,12 @@ corder_transition(hid_t fapl) if(H5Gclose(group_id2) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR /* Delete several links from group, until it resumes compact form */ @@ -10416,12 +10659,12 @@ corder_transition(hid_t fapl) if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR } /* end for */ @@ -10430,10 +10673,10 @@ corder_transition(hid_t fapl) if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR if(nlinks != (min_dense - 1)) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR /* Re-add links to get back into dense form */ for(u = (min_dense - 1); u < (max_compact + 1); u++) { @@ -10443,12 +10686,12 @@ corder_transition(hid_t fapl) } /* end for */ /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR /* Close the group */ @@ -10465,12 +10708,12 @@ corder_transition(hid_t fapl) if((group_id = H5Gopen2(file_id, CORDER_GROUP_NAME, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR /* Delete several links from group, until it resumes compact form */ @@ -10479,12 +10722,12 @@ corder_transition(hid_t fapl) if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR } /* end for */ @@ -10493,10 +10736,10 @@ corder_transition(hid_t fapl) if(H5Ldelete(group_id, objname, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, &nlinks) != TRUE) TEST_ERROR if(nlinks != (min_dense - 1)) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR /* Re-add links to get back into dense form */ for(u = (min_dense - 1); u < (max_compact + 1); u++) { @@ -10506,12 +10749,12 @@ corder_transition(hid_t fapl) } /* end for */ /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR /* Delete all the links */ @@ -10623,12 +10866,12 @@ corder_delete(hid_t fapl) } /* end for */ /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(group_id) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Retrieve & verify # of records in the name & creation order indices */ - if(H5G_new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR + if(H5G__new_dense_info_test(group_id, &name_count, &corder_count) < 0) TEST_ERROR if(name_count != corder_count) TEST_ERROR /* Close the group */ @@ -10932,7 +11175,7 @@ link_info_by_idx(hid_t fapl) } /* end for */ /* Verify state of group */ - if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR /* Check for out of bound offset queries */ H5E_BEGIN_TRY { @@ -10970,7 +11213,7 @@ link_info_by_idx(hid_t fapl) } /* end else */ /* Verify state of group */ - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Verify link information for new link */ if(link_info_by_idx_check(group_id, objname, (hsize_t)u, hard_link, use_index) < 0) TEST_ERROR @@ -11159,7 +11402,7 @@ link_info_by_idx_old(hid_t fapl) if(ret >= 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -11291,7 +11534,7 @@ delete_by_idx(hid_t fapl) } /* end for */ /* Verify state of group (compact) */ - if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR /* Check for out of bound deletion */ H5E_BEGIN_TRY { @@ -11328,7 +11571,7 @@ delete_by_idx(hid_t fapl) if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group (empty) */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR /* Create more links, to push group into dense form */ for(u = 0; u < (max_compact * 2); u++) { @@ -11343,7 +11586,7 @@ delete_by_idx(hid_t fapl) /* Verify state of group (dense) */ if(u >= max_compact) - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Verify link information for new link */ if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR @@ -11384,8 +11627,8 @@ delete_by_idx(hid_t fapl) if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group (empty) */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR /* Check for deletion on empty group again */ H5E_BEGIN_TRY { @@ -11410,7 +11653,7 @@ delete_by_idx(hid_t fapl) /* Verify state of group (dense) */ if(u >= max_compact) - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Verify link information for new link */ if(link_info_by_idx_check(group_id, objname, (hsize_t)u, TRUE, use_index) < 0) TEST_ERROR @@ -11470,8 +11713,8 @@ delete_by_idx(hid_t fapl) if(H5Ldelete_by_idx(group_id, ".", idx_type, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group (empty) */ - if(H5G_has_links_test(group_id, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(group_id) == TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) == TRUE) TEST_ERROR @@ -11621,7 +11864,7 @@ delete_by_idx_old(hid_t fapl) if(ret >= 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Delete links in middle */ @@ -11703,7 +11946,7 @@ delete_by_idx_old(hid_t fapl) if(H5Ldelete_by_idx(group_id, ".", H5_INDEX_NAME, order, (hsize_t)0, H5P_DEFAULT) < 0) TEST_ERROR /* Verify state of group */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Close the group */ if(H5Gclose(group_id) < 0) TEST_ERROR @@ -12130,7 +12373,7 @@ link_iterate(hid_t fapl) } /* end for */ /* Verify state of group (compact) */ - if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR /* Check for out of bound iteration on compact group */ skip = (hsize_t)u; @@ -12156,7 +12399,7 @@ link_iterate(hid_t fapl) } /* end for */ /* Verify state of group (dense) */ - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound iteration on dense group */ skip = (hsize_t)u; @@ -12543,7 +12786,7 @@ link_iterate_old(hid_t fapl) } /* end for */ /* Verify state of group (symbol table) */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound iteration on old-style group */ skip = (hsize_t)u; @@ -12834,7 +13077,7 @@ open_by_idx(hid_t fapl) } /* end for */ /* Verify state of group (compact) */ - if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR /* Check for out of bound open by index on compact group */ H5E_BEGIN_TRY { @@ -12869,7 +13112,7 @@ open_by_idx(hid_t fapl) } /* end for */ /* Verify state of group (dense) */ - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound open by index on compact group */ H5E_BEGIN_TRY { @@ -13011,7 +13254,7 @@ open_by_idx_old(hid_t fapl) } /* end for */ /* Verify state of group (symbol table) */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound open by index */ H5E_BEGIN_TRY { @@ -13282,7 +13525,7 @@ object_info(hid_t fapl) } /* end for */ /* Verify state of group (compact) */ - if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR /* Check for out of bound query by index */ H5E_BEGIN_TRY { @@ -13330,7 +13573,7 @@ object_info(hid_t fapl) } /* end for */ /* Verify state of group (dense) */ - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound query by index */ H5E_BEGIN_TRY { @@ -13479,7 +13722,7 @@ object_info_old(hid_t fapl) } /* end for */ /* Verify state of group (symbol table) */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound query by index */ H5E_BEGIN_TRY { @@ -13767,7 +14010,7 @@ group_info(hid_t fapl) } /* end for */ /* Verify state of group (compact) */ - if(H5G_has_links_test(group_id, NULL) != TRUE) TEST_ERROR + if(H5G__has_links_test(group_id, NULL) != TRUE) TEST_ERROR /* Check for out of bound query by index */ H5E_BEGIN_TRY { @@ -13908,7 +14151,7 @@ group_info(hid_t fapl) } /* end for */ /* Verify state of group (dense) */ - if(H5G_is_new_dense_test(group_id) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound query by index */ H5E_BEGIN_TRY { @@ -14138,7 +14381,7 @@ group_info_old(hid_t fapl) } /* end for */ /* Verify state of group (old-style) */ - if(H5G_has_stab_test(group_id) != TRUE) TEST_ERROR + if(H5G__has_stab_test(group_id) != TRUE) TEST_ERROR /* Check for out of bound query by index */ H5E_BEGIN_TRY { @@ -14478,6 +14721,9 @@ main(void) nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; +#ifndef H5_CANNOT_OPEN_TWICE + nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; +#endif /* H5_CANNOT_OPEN_TWICE */ } /* end for */ /* These tests assume that external links are a form of UD links, diff --git a/test/mount.c b/test/mount.c index f63404d..b7180fa 100644 --- a/test/mount.c +++ b/test/mount.c @@ -983,10 +983,13 @@ error: static int test_interlink(hid_t fapl) { - hid_t file1 = -1, file2 = -1, type = -1, space = -1, dset = -1; + hid_t file1 = -1, file2 = -1; +#ifdef NOT_NOW + hid_t type = -1, space = -1, dset = -1; + hsize_t cur_dims[1] = {2}; +#endif /* NOT_NOW */ char filename1[1024], filename2[1024]; herr_t status; - hsize_t cur_dims[1] = {2}; TESTING("interfile hard links"); h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1); @@ -1018,6 +1021,11 @@ test_interlink(hid_t fapl) TEST_ERROR } /* end if */ +/* Commented this code out until Jira issue #7638 is resolved. Once that + * issue is resolved (hopefully by refactored the file code to use shared + * file pointers for all operations), this should be uncommented. -QAK + */ +#ifdef NOT_NOW /* Try an interfile hard link by sharing a data type */ if((type = H5Tcopy(H5T_NATIVE_INT)) < 0) FAIL_STACK_ERROR if(H5Tcommit2(file1, "/type1", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -1031,9 +1039,15 @@ test_interlink(hid_t fapl) TEST_ERROR } /* end if */ - /* Shut down */ + /* Close IDs */ if(H5Sclose(space) < 0) FAIL_STACK_ERROR if(H5Tclose(type) < 0) FAIL_STACK_ERROR +#else /* NOT_NOW */ + SKIPPED(); + HDputs(" Test skipped due file pointer sharing issue (Jira 7638)."); +#endif /* NOT_NOW */ + + /* Shut down */ if(H5Funmount(file1, "/mnt1") < 0) FAIL_STACK_ERROR if(H5Fclose(file1) < 0) FAIL_STACK_ERROR if(H5Fclose(file2) < 0) FAIL_STACK_ERROR @@ -1043,9 +1057,11 @@ test_interlink(hid_t fapl) error: H5E_BEGIN_TRY { +#ifdef NOT_NOW H5Dclose(dset); H5Sclose(space); H5Tclose(type); +#endif /* NOT_NOW */ H5Fclose(file1); H5Fclose(file2); } H5E_END_TRY; diff --git a/test/multi_file_v16-r.h5 b/test/multi_file_v16-r.h5 Binary files differnew file mode 100644 index 0000000..36a4c88 --- /dev/null +++ b/test/multi_file_v16-r.h5 diff --git a/test/multi_file_v16-s.h5 b/test/multi_file_v16-s.h5 Binary files differnew file mode 100644 index 0000000..e990e95 --- /dev/null +++ b/test/multi_file_v16-s.h5 diff --git a/test/ntypes.c b/test/ntypes.c index 3310a82..165d21b 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -331,7 +331,7 @@ test_compound_dtype2(hid_t file) temp_point->st.c2 = (short)(i + j); temp_point->st.l2 = (i * 5 + j * 50) * n; temp_point->st.ll2 = (i * 10 + j * 100) * n; - temp_point->l = (unsigned long long)((i * 100 + j * 1000) * n); + temp_point->l = (unsigned long long)((i * 40 + j * 400) * n); } /* end for */ } /* end for */ @@ -2187,7 +2187,7 @@ test_refer_dtype(hid_t file) TEST_ERROR; /* Open datatype object */ - if((tid1 = H5Rdereference(dataset, H5R_OBJECT, rbuf)) < 0) + if((tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, rbuf)) < 0) TEST_ERROR; /* Verify correct datatype */ @@ -2372,7 +2372,7 @@ test_refer_dtype2(hid_t file) TEST_ERROR; /* Try to open objects */ - if((dset2 = H5Rdereference(dset1, H5R_DATASET_REGION, &rbuf)) < 0) + if((dset2 = H5Rdereference2(dset1, H5P_DEFAULT, H5R_DATASET_REGION, &rbuf)) < 0) TEST_ERROR; /* Check what H5Rget_obj_type2 function returns */ diff --git a/test/objcopy.c b/test/objcopy.c index 95b2db3..8fb8bbe 100755 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -61,9 +61,10 @@ const char *FILENAME[] = { */ #define CONFIG_SHARE_SRC 1 #define CONFIG_SHARE_DST 2 -#define CONFIG_NEW_FORMAT 4 -#define CONFIG_DENSE 8 -#define MAX_CONFIGURATION 15 +#define CONFIG_SRC_NEW_FORMAT 4 +#define CONFIG_DST_NEW_FORMAT 8 +#define CONFIG_DENSE 16 +#define MAX_CONFIGURATION 31 #define FILE_EXT "objcopy_ext.dat" /* The fill_old.h5 is generated from gen_old_fill.c in HDF5 'test' directory @@ -985,8 +986,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if(obj1_type != obj2_type) TEST_ERROR /* Open referenced objects */ - if((obj1_id = H5Rdereference(parent1, H5R_OBJECT, ref_buf1)) < 0) TEST_ERROR - if((obj2_id = H5Rdereference(parent2, H5R_OBJECT, ref_buf2)) < 0) TEST_ERROR + if((obj1_id = H5Rdereference2(parent1, H5P_DEFAULT, H5R_OBJECT, ref_buf1)) < 0) TEST_ERROR + if((obj2_id = H5Rdereference2(parent2, H5P_DEFAULT, H5R_OBJECT, ref_buf2)) < 0) TEST_ERROR /* break the infinite loop when the ref_object points to itself */ if(obj_owner > 0) { @@ -1043,8 +1044,8 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if(obj1_type != obj2_type) TEST_ERROR /* Open referenced objects */ - if((obj1_id = H5Rdereference(parent1, H5R_DATASET_REGION, ref_buf1)) < 0) TEST_ERROR - if((obj2_id = H5Rdereference(parent2, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR + if((obj1_id = H5Rdereference2(parent1, H5P_DEFAULT, H5R_DATASET_REGION, ref_buf1)) < 0) TEST_ERROR + if((obj2_id = H5Rdereference2(parent2, H5P_DEFAULT, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR /* break the infinite loop when the ref_object points to itself */ if(obj_owner > 0) { @@ -1249,7 +1250,8 @@ compare_datasets(hid_t did, hid_t did2, hid_t pid, const void *wbuf) * data in each dataset will (probably) be different and the storage * size will thus vary) */ - if(!(nfilters > 0 && H5Tdetect_class(tid, H5T_VLEN))) { + if(!(nfilters > 0 && (H5Tdetect_class(tid, H5T_VLEN) || + (H5Tdetect_class(tid, H5T_REFERENCE) && H5Tequal(tid, H5T_STD_REF_DSETREG))))) { hsize_t storage_size = H5Dget_storage_size(did); /* Dataset's raw data storage size */ hsize_t storage_size2 = H5Dget_storage_size(did2); /* 2nd Dataset's raw data storage size */ @@ -1535,7 +1537,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_named_datatype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_named_datatype(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2 = -1; /* Datatype IDs */ @@ -1545,14 +1547,14 @@ test_copy_named_datatype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): named datatype"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create datatype */ if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR @@ -1568,10 +1570,10 @@ test_copy_named_datatype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -1628,7 +1630,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_named_datatype_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_named_datatype_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2 = -1; /* Datatype IDs */ @@ -1638,14 +1640,14 @@ test_copy_named_datatype_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): named vlen datatype"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create datatype */ if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR @@ -1661,10 +1663,10 @@ test_copy_named_datatype_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -1721,7 +1723,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_named_datatype_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_named_datatype_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2 = -1; /* Datatype IDs */ @@ -1731,14 +1733,14 @@ test_copy_named_datatype_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): named nested vlen datatype"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create first vlen datatype */ if((tid = H5Tvlen_create(H5T_NATIVE_INT)) < 0) TEST_ERROR @@ -1760,10 +1762,10 @@ test_copy_named_datatype_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -1803,7 +1805,150 @@ error: H5Fclose(fid_src); } H5E_END_TRY; return 1; -} /* end test_copy_named_datatype_vl */ +} /* end test_copy_named_datatype_vl_vl */ + + +/*------------------------------------------------------------------------- + * Function: test_copy_named_datatype_attr_self + * + * Purpose: Create name datatype in SRC file, with an attribute that + * uses that named datatype as its datatype, and copy it to + * DST file + * + * Return: Success: 0 + * Failure: number of errors + * + * Programmer: Neil + * Friday, March 11, 2011 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static int +test_copy_named_datatype_attr_self(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) +{ + hid_t fid_src = -1, fid_dst = -1; /* File IDs */ + hid_t tid = -1, tid2 = -1; /* Datatype IDs */ + hid_t aid = -1; /* Attribute ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t dims[2] = {3, 4}; /* Dataspace dimensions */ + H5O_info_t oinfo, oinfo2; /* Object info */ + H5G_info_t ginfo; /* Group info */ + char src_filename[NAME_BUF_SIZE]; + char dst_filename[NAME_BUF_SIZE]; + + TESTING("H5Ocopy(): named datatype with self-referential attribute"); + + /* Initialize the filenames */ + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); + + /* Reset file address checking info */ + addr_reset(); + + /* create source file */ + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR + + /* create datatype */ + if((tid = H5Tcopy(H5T_NATIVE_INT)) < 0) TEST_ERROR + + /* create named datatype */ + if((H5Tcommit2(fid_src, NAME_DATATYPE_SIMPLE, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* create dataspace */ + if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR + + /* create attribute */ + if((aid = H5Acreate2(tid, "attr_self", tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* attach other attributes to the dataset */ + if(test_copy_attach_attributes(tid, tid) < 0) TEST_ERROR + + /* close the attribute */ + if(H5Aclose(aid) < 0) TEST_ERROR + + /* close the datatype */ + if(H5Tclose(tid) < 0) TEST_ERROR + + /* close the dataspace */ + if(H5Sclose(sid) < 0) TEST_ERROR + + /* close the SRC file */ + if(H5Fclose(fid_src) < 0) TEST_ERROR + + + /* open the source file with read-only */ + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + + /* create destination file */ + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR + + /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ + if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + + /* copy the datatype from SRC to DST */ + if(H5Ocopy(fid_src, NAME_DATATYPE_SIMPLE, fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + + /* open the source datatype */ + if((tid = H5Topen2(fid_src, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* open the copied datatype */ + if((tid2 = H5Topen2(fid_dst, NAME_DATATYPE_SIMPLE, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Compare the datatypes */ + if(H5Tequal(tid, tid2) != TRUE) TEST_ERROR + + /* close the source datatype */ + if(H5Tclose(tid) < 0) TEST_ERROR + + /* open the destination attribute */ + if((aid = H5Aopen(tid2, "attr_self", H5P_DEFAULT)) < 0) TEST_ERROR + + /* open the destination attribute's datatype */ + if((tid = H5Aget_type(aid)) < 0) TEST_ERROR + + /* verify that the attribute's datatype is committed */ + if(H5Tcommitted(tid) != TRUE) TEST_ERROR + + /* verify that the addresses of the datatypes are the same */ + if(H5Oget_info(tid, &oinfo) < 0) TEST_ERROR + if(H5Oget_info(tid2, &oinfo2) < 0) TEST_ERROR + if(oinfo.fileno != oinfo2.fileno || oinfo.addr != oinfo2.addr) + FAIL_PUTS_ERROR("destination attribute does not use the same committed datatype") + + /* Verify that there are only 2 links int he destination root group */ + if(H5Gget_info(fid_dst, &ginfo) < 0) + if(ginfo.nlinks != 2) + FAIL_PUTS_ERROR("unexpected number of links in destination root group") + + /* close the attribute */ + if(H5Aclose(aid) < 0) TEST_ERROR + + /* close the datatypes */ + if(H5Tclose(tid2) < 0) TEST_ERROR + if(H5Tclose(tid) < 0) TEST_ERROR + + /* close the SRC file */ + if(H5Fclose(fid_src) < 0) TEST_ERROR + + /* close the DST file */ + if(H5Fclose(fid_dst) < 0) TEST_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Tclose(tid2); + H5Tclose(tid); + H5Sclose(sid); + H5Aclose(aid); + H5Fclose(fid_dst); + H5Fclose(fid_src); + } H5E_END_TRY; + return 1; +} /* end test_copy_named_datatype_attr_self */ /*------------------------------------------------------------------------- @@ -1822,7 +1967,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_simple(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_simple(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -1841,14 +1986,14 @@ test_copy_dataset_simple(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; @@ -1877,10 +2022,10 @@ test_copy_dataset_simple(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2045,7 +2190,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -2057,14 +2202,14 @@ test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): empty contiguous dataset"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; @@ -2090,10 +2235,10 @@ test_copy_dataset_simple_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2153,7 +2298,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -2180,14 +2325,14 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0] = DIM_SIZE_1; @@ -2223,10 +2368,10 @@ test_copy_dataset_compound(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2287,7 +2432,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -2314,14 +2459,14 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set 1-D dataspace dimensions */ dim1d[0] = DIM_SIZE_1; @@ -2404,10 +2549,10 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2424,7 +2569,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2444,7 +2589,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2464,7 +2609,7 @@ test_copy_dataset_chunked(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2514,7 +2659,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -2531,14 +2676,14 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): empty chunked dataset"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set 1-D dataspace dimensions */ dim1d[0] = DIM_SIZE_1; @@ -2611,10 +2756,10 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2631,7 +2776,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2651,7 +2796,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2671,7 +2816,7 @@ test_copy_dataset_chunked_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2721,7 +2866,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -2751,14 +2896,14 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set 1-D dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -2907,10 +3052,10 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -2928,7 +3073,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_EARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2948,7 +3093,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_BT2, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_BT2, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2968,7 +3113,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED3, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -2988,7 +3133,7 @@ test_copy_dataset_chunked_sparse(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED4, H5P_DEFAULT)) < 0) TEST_ERROR /* Check if the array index type is correct */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3037,7 +3182,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { #ifdef H5_HAVE_FILTER_DEFLATE hid_t fid_src = -1, fid_dst = -1; /* File IDs */ @@ -3064,14 +3209,14 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = (float)(100.0); /* Something easy to compress */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; @@ -3125,10 +3270,10 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3143,7 +3288,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3162,7 +3307,7 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED2, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3216,7 +3361,8 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, + hid_t dst_fapl) { #ifdef H5_HAVE_FILTER_DEFLATE hid_t fid_src = -1, fid_dst = -1; /* File IDs */ @@ -3243,14 +3389,14 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = (float)(100.0); /* Something easy to compress */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0]=DIM_SIZE_1; @@ -3288,10 +3434,10 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3306,7 +3452,7 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if((did2 = H5Dopen2(fid_dst, NAME_DATASET_CHUNKED, H5P_DEFAULT)) < 0) TEST_ERROR /* H5Pset_chunk_opts() will set layout version to 4 which will use latest indexing available */ - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_FARRAY) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_FARRAY) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -3357,7 +3503,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -3377,14 +3523,14 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = (float)(i+j/100.0); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0]=DIM_SIZE_1; @@ -3420,10 +3566,10 @@ test_copy_dataset_compact(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3484,7 +3630,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_external(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_external(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -3507,14 +3653,14 @@ test_copy_dataset_external(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) HDfclose(HDfopen (FILE_EXT, "w")); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -3547,10 +3693,10 @@ test_copy_dataset_external(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3610,7 +3756,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -3629,14 +3775,14 @@ test_copy_dataset_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i] = i; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -3668,10 +3814,10 @@ test_copy_dataset_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3731,7 +3877,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_named_dtype_hier(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_named_dtype_hier(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -3751,14 +3897,14 @@ test_copy_dataset_named_dtype_hier(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i] = i; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create group to place all objects in */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3805,10 +3951,10 @@ test_copy_dataset_named_dtype_hier(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3870,7 +4016,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_named_dtype_hier_outside(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_named_dtype_hier_outside(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -3890,14 +4036,14 @@ test_copy_dataset_named_dtype_hier_outside(hid_t fcpl_src, hid_t fcpl_dst, hid_t buf[i] = i; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create group to place all objects in */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -3944,10 +4090,10 @@ test_copy_dataset_named_dtype_hier_outside(hid_t fcpl_src, hid_t fcpl_dst, hid_t /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4009,7 +4155,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -4028,14 +4174,14 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i] = i; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create group to place all objects in */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4078,10 +4224,10 @@ test_copy_dataset_multi_ohdr_chunks(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4142,7 +4288,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_attr_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_attr_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -4162,14 +4308,14 @@ test_copy_dataset_attr_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i] = i; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create group to place all objects in */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4219,10 +4365,10 @@ test_copy_dataset_attr_named_dtype(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4284,7 +4430,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -4307,14 +4453,14 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -4339,10 +4485,10 @@ test_copy_dataset_contig_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4413,7 +4559,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -4438,14 +4584,14 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -4491,10 +4637,10 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4509,7 +4655,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -4528,7 +4674,7 @@ test_copy_dataset_chunked_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL2, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -4589,7 +4735,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -4613,14 +4759,14 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -4652,10 +4798,10 @@ test_copy_dataset_compact_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4726,7 +4872,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_attribute_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_attribute_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -4739,14 +4885,14 @@ test_copy_attribute_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): variable length attribute"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; @@ -4772,10 +4918,10 @@ test_copy_attribute_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4841,7 +4987,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { #ifdef H5_HAVE_FILTER_DEFLATE hid_t fid_src = -1, fid_dst = -1; /* File IDs */ @@ -4874,14 +5020,14 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0]=DIM_SIZE_1; @@ -4915,10 +5061,10 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -4993,7 +5139,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_group_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_group_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t gid = -1, gid2 = -1; /* Group IDs */ @@ -5003,14 +5149,14 @@ test_copy_group_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): empty group"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_EMPTY, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5026,10 +5172,10 @@ test_copy_group_empty(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5073,22 +5219,22 @@ error: /*------------------------------------------------------------------------- - * Function: test_copy_group + * Function: test_copy_root_group * - * Purpose: Create a group in SRC file and copy it to DST file + * Purpose: Create a root group in SRC file and copy it to DST file * * Return: Success: 0 * Failure: number of errors * * Programmer: Peter Cao - * Friday, September 30, 2005 + * August 8, 2006 * * Modifications: * *------------------------------------------------------------------------- */ static int -test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -5101,7 +5247,7 @@ test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) char src_filename[NAME_BUF_SIZE]; char dst_filename[NAME_BUF_SIZE]; - TESTING("H5Ocopy(): simple nested groups"); + TESTING("H5Ocopy(): root group"); /* set initial data values */ for (i=0; i<DIM_SIZE_1; i++) @@ -5109,14 +5255,14 @@ test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5125,8 +5271,8 @@ test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR /* Set dataspace dimensions */ - dim2d[0]=DIM_SIZE_1; - dim2d[1]=DIM_SIZE_2; + dim2d[0] = DIM_SIZE_1; + dim2d[1] = DIM_SIZE_2; /* create dataspace */ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR @@ -5143,11 +5289,11 @@ test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create a sub-group */ if((gid_sub = H5Gcreate2(fid_src, NAME_GROUP_SUB, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if( H5Gclose(gid_sub) < 0) TEST_ERROR + if(H5Gclose(gid_sub) < 0) TEST_ERROR /* create another sub-group */ if((gid_sub = H5Gcreate2(fid_src, NAME_GROUP_SUB_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if( H5Gclose(gid_sub) < 0) TEST_ERROR + if(H5Gclose(gid_sub) < 0) TEST_ERROR /* close the group */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -5155,24 +5301,23 @@ test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR - /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* copy the group from SRC to DST */ - if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, "/", fid_dst, "/root_from_src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((gid = H5Gopen2(fid_src, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((gid2 = H5Gopen2(fid_dst, "/root_from_src", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check if the groups are equal */ if(compare_groups(gid, gid2, H5P_DEFAULT, -1, 0) != TRUE) TEST_ERROR @@ -5194,35 +5339,35 @@ test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) error: H5E_BEGIN_TRY { - H5Sclose(sid); - H5Dclose(did); - H5Gclose(gid_sub); - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid_dst); - H5Fclose(fid_src); + H5Sclose(sid); + H5Dclose(did); + H5Gclose(gid_sub); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid_dst); + H5Fclose(fid_src); } H5E_END_TRY; return 1; -} /* end test_copy_group */ +} /* end test_copy_root_group */ /*------------------------------------------------------------------------- - * Function: test_copy_root_group + * Function: test_copy_group * - * Purpose: Create a root group in SRC file and copy it to DST file + * Purpose: Create a group in SRC file and copy it to DST file * * Return: Success: 0 * Failure: number of errors * * Programmer: Peter Cao - * August 8, 2006 + * Friday, September 30, 2005 * * Modifications: * *------------------------------------------------------------------------- */ static int -test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -5235,7 +5380,7 @@ test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) char src_filename[NAME_BUF_SIZE]; char dst_filename[NAME_BUF_SIZE]; - TESTING("H5Ocopy(): root group"); + TESTING("H5Ocopy(): simple nested groups"); /* set initial data values */ for (i=0; i<DIM_SIZE_1; i++) @@ -5243,14 +5388,14 @@ test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5259,8 +5404,8 @@ test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(test_copy_attach_attributes(gid, H5T_NATIVE_INT) < 0) TEST_ERROR /* Set dataspace dimensions */ - dim2d[0] = DIM_SIZE_1; - dim2d[1] = DIM_SIZE_2; + dim2d[0]=DIM_SIZE_1; + dim2d[1]=DIM_SIZE_2; /* create dataspace */ if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR @@ -5277,11 +5422,11 @@ test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* create a sub-group */ if((gid_sub = H5Gcreate2(fid_src, NAME_GROUP_SUB, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid_sub) < 0) TEST_ERROR + if( H5Gclose(gid_sub) < 0) TEST_ERROR /* create another sub-group */ if((gid_sub = H5Gcreate2(fid_src, NAME_GROUP_SUB_2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Gclose(gid_sub) < 0) TEST_ERROR + if( H5Gclose(gid_sub) < 0) TEST_ERROR /* close the group */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -5289,23 +5434,24 @@ test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* close the SRC file */ if(H5Fclose(fid_src) < 0) TEST_ERROR + /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* copy the group from SRC to DST */ - if(H5Ocopy(fid_src, "/", fid_dst, "/root_from_src", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if(H5Ocopy(fid_src, NAME_GROUP_TOP, fid_dst, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* open the group for copy */ - if((gid = H5Gopen2(fid_src, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((gid = H5Gopen2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* open the destination group */ - if((gid2 = H5Gopen2(fid_dst, "/root_from_src", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((gid2 = H5Gopen2(fid_dst, NAME_GROUP_TOP, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Check if the groups are equal */ if(compare_groups(gid, gid2, H5P_DEFAULT, -1, 0) != TRUE) TEST_ERROR @@ -5327,16 +5473,16 @@ test_copy_root_group(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) error: H5E_BEGIN_TRY { - H5Sclose(sid); - H5Dclose(did); - H5Gclose(gid_sub); - H5Gclose(gid2); - H5Gclose(gid); - H5Fclose(fid_dst); - H5Fclose(fid_src); + H5Sclose(sid); + H5Dclose(did); + H5Gclose(gid_sub); + H5Gclose(gid2); + H5Gclose(gid); + H5Fclose(fid_dst); + H5Fclose(fid_src); } H5E_END_TRY; return 1; -} /* end test_copy_root_group */ +} /* end test_copy_group */ /*------------------------------------------------------------------------- @@ -5353,7 +5499,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -5375,14 +5521,14 @@ test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5432,10 +5578,10 @@ test_copy_group_deep(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5495,7 +5641,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_group_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_group_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t gid = -1, gid2 = -1; /* Group IDs */ @@ -5506,14 +5652,14 @@ test_copy_group_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): nested groups with loop"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5543,10 +5689,10 @@ test_copy_group_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5610,7 +5756,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_group_wide_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_group_wide_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t gid = -1, gid2 = -1; /* Group IDs */ @@ -5623,14 +5769,14 @@ test_copy_group_wide_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) TESTING("H5Ocopy(): wide nested groups with loop"); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5672,10 +5818,10 @@ test_copy_group_wide_loop(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5740,7 +5886,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_group_links(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_group_links(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -5767,18 +5913,18 @@ test_copy_group_links(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); - h5_fixname(FILENAME[2], fapl, ext_filename, sizeof ext_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], src_fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[2], dst_fapl, ext_filename, sizeof ext_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create file to hold external dataset */ - if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create groups at the SRC file. Group 2 will hold dangling links. */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5861,10 +6007,10 @@ test_copy_group_links(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(H5Pset_copy_object(plid, copy_options) < 0) TEST_ERROR /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -5911,7 +6057,7 @@ test_copy_group_links(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) FAIL_PUTS_ERROR("External link was not expanded to a hard link") /* Compare datasets */ - if((fid_ext = H5Fopen(ext_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_ext = H5Fopen(ext_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR if((did = H5Dopen2(fid_ext, NAME_DATASET_SIMPLE, H5P_DEFAULT)) < 0) TEST_ERROR if((did2 = H5Dopen2(fid_dst, NAME_LINK_EXTERN, H5P_DEFAULT)) < 0) TEST_ERROR if(compare_datasets(did, did2, H5P_DEFAULT, NULL) != TRUE) TEST_ERROR @@ -5996,7 +6142,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -6016,14 +6162,14 @@ test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6059,10 +6205,10 @@ test_copy_soft_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6121,7 +6267,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_ext_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_ext_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -6142,15 +6288,15 @@ test_copy_ext_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); - h5_fixname(FILENAME[2], fapl, ext_filename, sizeof ext_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], src_fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[2], dst_fapl, ext_filename, sizeof ext_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6177,7 +6323,7 @@ test_copy_ext_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(H5Gclose(gid) < 0) TEST_ERROR /* create file to hold external links to the src file */ - if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, H5P_DEFAULT, src_fapl)) < 0) TEST_ERROR /* create group in the file that will hold the external link */ if((gid = H5Gcreate2(fid_ext, NAME_GROUP_LINK, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6190,10 +6336,10 @@ test_copy_ext_link(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(H5Fclose(fid_ext) < 0) TEST_ERROR /* open the "extern" file with read-only */ - if((fid_ext = H5Fopen(ext_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_ext = H5Fopen(ext_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6256,7 +6402,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_exist(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_exist(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -6276,14 +6422,14 @@ test_copy_exist(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; @@ -6312,10 +6458,10 @@ test_copy_exist(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6364,7 +6510,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_path(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_path(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -6385,14 +6531,14 @@ test_copy_path(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim2d[0] = DIM_SIZE_1; @@ -6421,10 +6567,10 @@ test_copy_path(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6649,7 +6795,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid_copy=-1; /* Datatype ID */ @@ -6673,14 +6819,14 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -6721,10 +6867,10 @@ test_copy_dataset_compact_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6797,7 +6943,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid_copy=-1; /* Datatype ID */ @@ -6820,14 +6966,14 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -6861,10 +7007,10 @@ test_copy_dataset_contig_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -6936,7 +7082,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid_copy=-1; /* Datatype ID */ @@ -6961,14 +7107,14 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7009,10 +7155,10 @@ test_copy_dataset_chunked_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7085,7 +7231,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid_copy=-1; /* Datatype ID */ @@ -7110,14 +7256,14 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7159,10 +7305,10 @@ test_copy_dataset_compressed_named_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7235,7 +7381,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid=-1, tid2=-1; /* Datatype ID */ @@ -7273,14 +7419,14 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7315,10 +7461,10 @@ test_copy_dataset_compact_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7390,7 +7536,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid=-1, tid2=-1; /* Datatype ID */ @@ -7428,14 +7574,14 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7469,10 +7615,10 @@ test_copy_dataset_contig_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7544,7 +7690,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2=-1; /* Datatype ID */ @@ -7582,14 +7728,14 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7638,10 +7784,10 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7655,7 +7801,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_FARRAY, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -7674,7 +7820,7 @@ test_copy_dataset_chunked_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the destination dataset */ if((did2 = H5Dopen2(fid_dst, NAME_DATASET_VL_VL2, H5P_DEFAULT)) < 0) TEST_ERROR - if(compare_idx_type(fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) + if(compare_idx_type(src_fapl, did2, H5D_CHUNK_IDX_NONE, H5D_CHUNK_IDX_BTREE) != TRUE) TEST_ERROR /* Check if the datasets are equal */ @@ -7738,7 +7884,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2=-1; /* Datatype ID */ @@ -7776,14 +7922,14 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7819,10 +7965,10 @@ test_copy_dataset_compressed_vl_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -7904,7 +8050,7 @@ typedef struct cmpd_vl_t { *------------------------------------------------------------------------- */ static int -test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1; /* Datatype ID */ @@ -7931,14 +8077,14 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -7967,10 +8113,10 @@ test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8043,7 +8189,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2 = -1; /* Datatype IDs */ @@ -8070,14 +8216,14 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -8113,10 +8259,10 @@ test_copy_dataset_chunked_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8189,7 +8335,7 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t tid = -1, tid2 = -1; /* Datatype IDs */ @@ -8215,14 +8361,14 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) } /* end for */ /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Set dataspace dimensions */ dim1d[0]=DIM_SIZE_1; @@ -8258,10 +8404,10 @@ test_copy_dataset_compact_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) /* open the source file with read-only */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ if(H5Gclose(H5Gcreate2(fid_dst, NAME_GROUP_UNCOPIED, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8333,12 +8479,12 @@ error: * Failure: number of errors * * Programmer: Neil Fortner - * Wednesday, March 31, 2005 + * Wednesday, March 31, 2010 * *------------------------------------------------------------------------- */ static int -test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) +test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl) { hid_t fid1 = -1, fid2 = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -8358,15 +8504,15 @@ test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) HDmemset(zeros, 0, sizeof(zeros)); /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, mid_filename, sizeof mid_filename); - h5_fixname(FILENAME[2], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], src_fapl, mid_filename, sizeof mid_filename); + h5_fixname(FILENAME[2], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* Create source file */ - if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) + if((fid1 = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Create dataspace */ @@ -8399,7 +8545,7 @@ test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(H5Dclose(did2) < 0) TEST_ERROR /* Create middle file */ - if((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) + if((fid2 = H5Fcreate(mid_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* Copy the source file to the middle file. Note the expand references @@ -8428,7 +8574,7 @@ test_copy_null_ref(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl) if(H5Dclose(did2) < 0) TEST_ERROR /* Create destination file */ - if((fid1 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) + if((fid1 = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create object copy property list */ @@ -8497,7 +8643,8 @@ error: *------------------------------------------------------------------------- */ static int -test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl, unsigned flag, hbool_t crt_intermediate_grp, const char* test_desciption) +test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid_t dst_fapl, + unsigned flag, hbool_t crt_intermediate_grp, const char* test_desciption) { hid_t fid_src = -1, fid_dst = -1, fid_ext = -1; /* File IDs */ hid_t sid = -1; /* Dataspace ID */ @@ -8521,14 +8668,14 @@ test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl, unsigned flag, hboo buf[i][j] = 10000 + 100*i+j; /* Initialize the filenames */ - h5_fixname(FILENAME[0], fapl, src_filename, sizeof src_filename); - h5_fixname(FILENAME[1], fapl, dst_filename, sizeof dst_filename); + h5_fixname(FILENAME[0], src_fapl, src_filename, sizeof src_filename); + h5_fixname(FILENAME[1], dst_fapl, dst_filename, sizeof dst_filename); /* Reset file address checking info */ addr_reset(); /* create source file */ - if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fcreate(src_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR /* create group at the SRC file */ if((gid = H5Gcreate2(fid_src, NAME_GROUP_TOP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR @@ -8593,10 +8740,10 @@ test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl, unsigned flag, hboo if((flag & H5O_COPY_EXPAND_EXT_LINK_FLAG) > 0) { char ext_filename[NAME_BUF_SIZE]; - h5_fixname(FILENAME[2], fapl, ext_filename, sizeof ext_filename); + h5_fixname(FILENAME[2], src_fapl, ext_filename, sizeof ext_filename); /* Create the external file and dataset */ - if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, fapl)) < 0) TEST_ERROR + if((fid_ext = H5Fcreate(ext_filename, H5F_ACC_TRUNC, fcpl_src, src_fapl)) < 0) TEST_ERROR if((sid = H5Screate_simple(2, dim2d, NULL)) < 0) TEST_ERROR if((did = H5Dcreate2(fid_ext, NAME_DATASET_SIMPLE, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR @@ -8651,13 +8798,13 @@ test_copy_option(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl, unsigned flag, hboo /* open the source file with read-only */ /* (except when expanding soft links */ if((flag & H5O_COPY_EXPAND_SOFT_LINK_FLAG) > 0) { - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDWR, src_fapl)) < 0) TEST_ERROR } /* end if */ else - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR /* create destination file */ - if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR + if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, dst_fapl)) < 0) TEST_ERROR /* Create an uncopied object in destination file so that addresses in source and destination files aren't the same */ @@ -8825,12 +8972,13 @@ main(void) /* Test in all configurations */ for(configuration = 0; configuration <= MAX_CONFIGURATION; configuration++) { - hid_t my_fapl; + hid_t src_fapl; + hid_t dst_fapl; hid_t fcpl_src; hid_t fcpl_dst; /* No need to test dense attributes with old format */ - if(!(configuration & CONFIG_NEW_FORMAT) && (configuration & CONFIG_DENSE)) + if(!(configuration & CONFIG_SRC_NEW_FORMAT) && (configuration & CONFIG_DENSE)) continue; /* Test with and without shared messages */ @@ -8851,111 +8999,131 @@ main(void) fcpl_dst = H5P_DEFAULT; } - /* Set the FAPL for the type of format */ - if(configuration & CONFIG_NEW_FORMAT) { - puts("Testing with new group format:"); - my_fapl = fapl2; + /* Set the FAPL for the source file's type of format */ + if(configuration & CONFIG_SRC_NEW_FORMAT) { + puts("Testing with latest format for source file:"); + src_fapl = fapl2; - /* Test with and without dense attributes */ + /* Test with and without dense attributes */ if(configuration & CONFIG_DENSE) { puts("Testing with dense attributes:"); num_attributes_g = max_compact + 1; } else { puts("Testing without dense attributes:"); - num_attributes_g = MAX(min_dense, 2) - 1; + num_attributes_g = MAX(min_dense, 2) - 2; } } /* end if */ else { - puts("Testing with old group format:"); - my_fapl = fapl; + puts("Testing with oldest file format for source file:"); + src_fapl = fapl; num_attributes_g = 4; } /* end else */ + /* Set the FAPL for the destination file's type of format */ + if(configuration & CONFIG_DST_NEW_FORMAT) { + puts("Testing with latest format for destination file:"); + dst_fapl = fapl2; + } /* end if */ + else { + puts("Testing with oldest file format for destination file:"); + dst_fapl = fapl; + } /* end else */ + /* The tests... */ - nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_simple_samefile(fcpl_src, my_fapl); - nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compound(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked_empty(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked_sparse(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compressed(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_no_edge_filt(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_attr_named_dtype(fcpl_src, fcpl_dst, my_fapl); - - nerrors += test_copy_group_empty(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_root_group(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_group(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_group_deep(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_group_loop(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_group_wide_loop(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_group_links(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, my_fapl); + nerrors += test_copy_dataset_simple(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_simple_samefile(fcpl_src, src_fapl); + nerrors += test_copy_dataset_simple_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compound(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked_sparse(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compressed(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_no_edge_filt(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compact(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_multi_ohdr_chunks(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_attr_named_dtype(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + + nerrors += test_copy_group_empty(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_root_group(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_group(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_group_deep(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_group_loop(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_group_wide_loop(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_group_links(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_soft_link(fcpl_src, fcpl_dst, src_fapl, dst_fapl); #ifndef H5_CANNOT_OPEN_TWICE - nerrors += test_copy_ext_link(fcpl_src, fcpl_dst, my_fapl); + nerrors += test_copy_ext_link(fcpl_src, fcpl_dst, src_fapl, dst_fapl); #endif /* H5_CANNOT_OPEN_TWICE */ - nerrors += test_copy_exist(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_path(fcpl_src, fcpl_dst, my_fapl); - - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG, - FALSE, "H5Ocopy(): without attributes"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, 0, TRUE, - "H5Ocopy(): with missing groups"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_SOFT_LINK_FLAG, - FALSE, "H5Ocopy(): expand soft link"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_EXT_LINK_FLAG, + nerrors += test_copy_exist(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_path(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + + nerrors += test_copy_named_datatype_attr_self(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_WITHOUT_ATTR_FLAG, + FALSE, "H5Ocopy(): without attributes"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + 0, + TRUE, "H5Ocopy(): with missing groups"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_EXPAND_SOFT_LINK_FLAG, + FALSE, "H5Ocopy(): expand soft link"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_EXPAND_EXT_LINK_FLAG, FALSE, "H5Ocopy: expand external link"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, H5O_COPY_EXPAND_SOFT_LINK_FLAG | H5O_COPY_EXPAND_EXT_LINK_FLAG, FALSE, "H5Ocopy: expand soft and external links"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_SHALLOW_HIERARCHY_FLAG, - FALSE, "H5Ocopy(): shallow group copy"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_EXPAND_REFERENCE_FLAG, - FALSE, "H5Ocopy(): expand object reference"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_PRESERVE_NULL_FLAG, - FALSE, "H5Ocopy(): preserve NULL messages"); - nerrors += test_copy_option(fcpl_src, fcpl_dst, my_fapl, H5O_COPY_WITHOUT_ATTR_FLAG | - H5O_COPY_PRESERVE_NULL_FLAG, TRUE, "H5Ocopy(): preserve NULL messages"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_SHALLOW_HIERARCHY_FLAG, + FALSE, "H5Ocopy(): shallow group copy"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_EXPAND_REFERENCE_FLAG, + FALSE, "H5Ocopy(): expand object reference"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_PRESERVE_NULL_FLAG, + FALSE, "H5Ocopy(): preserve NULL messages"); + nerrors += test_copy_option(fcpl_src, fcpl_dst, src_fapl, dst_fapl, + H5O_COPY_WITHOUT_ATTR_FLAG | H5O_COPY_PRESERVE_NULL_FLAG, + TRUE, "H5Ocopy(): preserve NULL messages"); /* Tests that do not use attributes and do not need to be tested * multiple times for different attribute configurations */ if(configuration < CONFIG_DENSE) { - nerrors += test_copy_named_datatype(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_named_datatype_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_named_datatype_vl_vl(fcpl_src, fcpl_dst, my_fapl); - - nerrors += test_copy_dataset_external(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_named_dtype(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_named_dtype_hier(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_named_dtype_hier_outside(fcpl_src, fcpl_dst, my_fapl); - - nerrors += test_copy_dataset_contig_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compact_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compressed_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_attribute_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compact_named_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_contig_named_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compressed_named_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compact_vl_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked_vl_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_contig_cmpd_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_chunked_cmpd_vl(fcpl_src, fcpl_dst, my_fapl); - nerrors += test_copy_dataset_compact_cmpd_vl(fcpl_src, fcpl_dst, my_fapl); - - nerrors += test_copy_same_file_named_datatype(fcpl_src, my_fapl); - nerrors += test_copy_old_layout(fcpl_dst, my_fapl); - nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, my_fapl); + nerrors += test_copy_named_datatype(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_named_datatype_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_named_datatype_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + + nerrors += test_copy_dataset_external(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_named_dtype(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_named_dtype_hier(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_named_dtype_hier_outside(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + + nerrors += test_copy_dataset_contig_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compact_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compressed_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_attribute_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compact_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_contig_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compressed_named_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compact_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_contig_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compressed_vl_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_contig_cmpd_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_chunked_cmpd_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + nerrors += test_copy_dataset_compact_cmpd_vl(fcpl_src, fcpl_dst, src_fapl, dst_fapl); + + nerrors += test_copy_same_file_named_datatype(fcpl_src, src_fapl); + nerrors += test_copy_old_layout(fcpl_dst, dst_fapl); + nerrors += test_copy_null_ref(fcpl_src, fcpl_dst, src_fapl, dst_fapl); } /* TODO: not implemented - nerrors += test_copy_mount(my_fapl); + nerrors += test_copy_mount(src_fapl); */ } /* end for */ diff --git a/test/stab.c b/test/stab.c index b460d90..a42ee5e 100644 --- a/test/stab.c +++ b/test/stab.c @@ -277,14 +277,14 @@ test_large(hid_t fapl, hbool_t new_format) */ if((cwg = H5Gcreate2(fid, "/big", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(new_format) - if(H5G_has_stab_test(cwg) != FALSE) TEST_ERROR + if(H5G__has_stab_test(cwg) != FALSE) TEST_ERROR for(i = 0; i < LARGE_NOBJS; i++) { sprintf(name, "%05d%05d", (HDrandom() % 100000), i); if((dir = H5Gcreate2(cwg, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Gclose(dir) < 0) TEST_ERROR } if(new_format) - if(H5G_is_new_dense_test(cwg) != TRUE) TEST_ERROR + if(H5G__is_new_dense_test(cwg) != TRUE) TEST_ERROR if(H5Gclose(cwg) < 0) TEST_ERROR /* Close file */ @@ -386,21 +386,21 @@ lifecycle(hid_t fapl2) if(est_name_len != LIFECYCLE_EST_NAME_LEN) TEST_ERROR /* Use internal testing routine to check that the group has no links or symbol table */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Create first "bottom" group */ sprintf(objname, LIFECYCLE_BOTTOM_GROUP, (unsigned)0); if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR /* Check on top group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR if(nmsgs != 1) TEST_ERROR /* Create several more bottom groups, to push the top group almost to a symbol table */ @@ -410,17 +410,17 @@ lifecycle(hid_t fapl2) if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR } /* end for */ /* Check on top group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR if(nmsgs != LIFECYCLE_MAX_COMPACT) TEST_ERROR - if(H5G_is_new_dense_test(gid) != FALSE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != FALSE) TEST_ERROR /* Check that the object header is only one chunk and the space has been allocated correctly */ if(H5Oget_info(gid, &oinfo) < 0) TEST_ERROR @@ -434,15 +434,15 @@ lifecycle(hid_t fapl2) if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR /* Check on top group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Check that the object header is still one chunk and the space has been allocated correctly */ if(H5Oget_info(gid, &oinfo) < 0) TEST_ERROR @@ -461,9 +461,9 @@ lifecycle(hid_t fapl2) } /* end while */ /* Check on top group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Unlink one more object from the group, which should transform back to using links */ sprintf(objname, LIFECYCLE_BOTTOM_GROUP, u); @@ -471,8 +471,8 @@ lifecycle(hid_t fapl2) u--; /* Check on top group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, &nmsgs) != TRUE) TEST_ERROR if(nmsgs != (LIFECYCLE_MIN_DENSE - 1)) TEST_ERROR /* Unlink last two objects from top group */ @@ -483,7 +483,7 @@ lifecycle(hid_t fapl2) if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check on top group's status */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Close top group */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -568,47 +568,47 @@ long_compact(hid_t fapl2) if((gid = H5Gcreate2(fid, "top", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Use internal testing routine to check that the group has no links or dense storage */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Create first group with "long" name */ if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR /* Check on top group's status */ /* (Should have dense storage to hold links, since name is too long for object header message) */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Create second group with "long" name */ objname[0] = 'b'; if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR /* Check on top group's status */ /* (Should have dense storage to hold links, since name is too long for object header message) */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Unlink second object from top group */ if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check on top group's status */ /* (Should still be dense storage to hold links, since name is too long for object header message) */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Unlink first object from top group */ objname[0] = 'a'; @@ -616,7 +616,7 @@ long_compact(hid_t fapl2) /* Check on top group's status */ /* (Should have deleted the dense storage now) */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Free object name */ HDfree(objname); @@ -684,9 +684,9 @@ read_old(void) if((gid = H5Gopen2(fid, "old", H5P_DEFAULT)) < 0) TEST_ERROR /* Check on old group's status */ - if(H5G_is_empty_test(gid) == FALSE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == FALSE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR /* Create a bunch of objects in the group */ for(u = 0; u < READ_OLD_NGROUPS; u++) { @@ -694,7 +694,7 @@ read_old(void) if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR @@ -702,9 +702,9 @@ read_old(void) /* Check on old group's status */ /* (Should stay in old "symbol table" form) */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR /* Delete new objects from old group */ for(u = 0; u < READ_OLD_NGROUPS; u++) { @@ -714,9 +714,9 @@ read_old(void) /* Check on old group's status */ /* (Should stay in old "symbol table" form, but have no links) */ - if(H5G_is_empty_test(gid) == FALSE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_has_stab_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == FALSE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) != TRUE) TEST_ERROR /* Close old group */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -798,29 +798,29 @@ no_compact(hid_t fapl2) if(H5Pclose(gcpl) < 0) TEST_ERROR /* Use internal testing routine to check that the group has no links or dense storage */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Create first "bottom" group */ sprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); if((gid2 = H5Gcreate2(gid, objname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Check on bottom group's status */ - if(H5G_is_empty_test(gid2) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid2) != TRUE) TEST_ERROR /* Close bottom group */ if(H5Gclose(gid2) < 0) TEST_ERROR /* Check on top group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Unlink object from top group */ sprintf(objname, NO_COMPACT_BOTTOM_GROUP, (unsigned)0); if(H5Ldelete(gid, objname, H5P_DEFAULT) < 0) FAIL_STACK_ERROR /* Check on top group's status */ - if(H5G_is_empty_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) != TRUE) TEST_ERROR /* Close top group */ if(H5Gclose(gid) < 0) TEST_ERROR diff --git a/test/tattr.c b/test/tattr.c index 60d4ddb..1285f0e 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -128,6 +128,8 @@ float attr_data5=(float)-5.123; /* Test data for 5th attribute */ #define ATTR7_NAME "attr 1 - 000000" #define ATTR8_NAME "attr 2" +#define LINK1_NAME "Link1" + #define NATTR_MANY_OLD 350 #define NATTR_MANY_NEW 35000 @@ -10216,7 +10218,339 @@ test_attr_bug6(hid_t fcpl, hid_t fapl) ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); -} +} /* test_attr_bug6() */ + +/**************************************************************** +** +** test_attr_bug7(): Test basic H5A (attribute) code. +** (Really tests object header allocation code). +** Tests creating and deleting attributes in such a way as +** to change the size of the "chunk #0 size" field. +** Includes testing "skipping" a possible size of the +** field, i.e. going from 1 to 4 bytes or 4 to 1 byte. +** +****************************************************************/ +static void +test_attr_bug7(hid_t fcpl, hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t tid; /* Datatype ID */ + hsize_t dims_s = 140; /* Small attribute dimensions */ + hsize_t dims_l = 65480; /* Large attribute dimensions */ + H5A_info_t ainfo; /* Attribute info */ + herr_t ret; /* Generic return status */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing adding and deleting large attributes\n")); + + + /* Create committed datatype to operate on. Use a committed datatype so that + * there is nothing after the object header and the first chunk can expand and + * contract as necessary. */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + tid = H5Tcopy(H5T_STD_I32LE); + CHECK(tid, FAIL, "H5Tcopy"); + ret = H5Tcommit2(fid, TYPE1_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Tcommit2"); + + /* + * Create small attribute + */ + sid = H5Screate_simple(1, &dims_s, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + aid = H5Acreate2(tid, ATTR1_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Close file */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check attribute */ + tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT); + CHECK(tid, FAIL, "H5Topen2"); + ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + + /* + * Create another small attribute. Should cause chunk size field to expand by + * 1 byte (1->2). + */ + aid = H5Acreate2(tid, ATTR2_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Close file */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check attributes */ + tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT); + CHECK(tid, FAIL, "H5Topen2"); + ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + + /* + * Create large attribute. Should cause chunk size field to expand by 2 bytes + * (2->4). + */ + ret = H5Sset_extent_simple(sid, 1, &dims_l, NULL); + CHECK(ret, FAIL, "H5Sset_extent_simple"); + aid = H5Acreate2(tid, ATTR3_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Close file */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check attributes */ + tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT); + CHECK(tid, FAIL, "H5Topen2"); + ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + ret = H5Aget_info_by_name(tid, ".", ATTR3_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_l) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_l); + + /* + * Delete last two attributes - should merge into a null message that is too + * large, causing the chunk size field to shrink by 3 bytes (4->1). + */ + ret = H5Sset_extent_simple(sid, 1, &dims_l, NULL); + CHECK(ret, FAIL, "H5Sset_extent_simple"); + ret = H5Adelete(tid, ATTR2_NAME); + CHECK(ret, FAIL, "H5Adelete"); + ret = H5Adelete(tid, ATTR3_NAME); + CHECK(ret, FAIL, "H5Adelete"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check attribute */ + tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT); + CHECK(tid, FAIL, "H5Topen2"); + ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + + /* + * Create large attribute. Should cause chunk size field to expand by 3 bytes + * (1->4). + */ + aid = H5Acreate2(tid, ATTR2_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Close file */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check attributes */ + tid = H5Topen2(fid, TYPE1_NAME, H5P_DEFAULT); + CHECK(tid, FAIL, "H5Topen2"); + ret = H5Aget_info_by_name(tid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_s) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_s); + ret = H5Aget_info_by_name(tid, ".", ATTR2_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims_l) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims_l); + + /* Close IDs */ + ret = H5Tclose(tid); + CHECK(ret, FAIL, "H5Tclose"); + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); +} /* test_attr_bug7() */ + +/**************************************************************** +** +** test_attr_bug8(): Test basic H5A (attribute) code. +** (Really tests object header code). +** Tests adding a link and attribute to a group in such a +** way as to cause the "chunk #0 size" field to expand +** when some object header messages are not loaded into +** cache. Before the bug was fixed, this would prevent +** these messages from being shifted to the correct +** position as the expansion algorithm marked them dirty, +** invalidating the raw form, when there was no native +** form to encode. +** +****************************************************************/ +static void +test_attr_bug8(hid_t fcpl, hid_t fapl) +{ + hid_t fid; /* File ID */ + hid_t aid; /* Attribute ID */ + hid_t sid; /* Dataspace ID */ + hid_t gid; /* Group ID */ + hid_t oid; /* Object ID */ + hsize_t dims = 256; /* Attribute dimensions */ + H5O_info_t oinfo; /* Object info */ + H5A_info_t ainfo; /* Attribute info */ + haddr_t root_addr; /* Root group address */ + herr_t ret; /* Generic return status */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing attribute expanding object header with undecoded messages\n")); + + + /* Create committed datatype to operate on. Use a committed datatype so that + * there is nothing after the object header and the first chunk can expand and + * contract as necessary. */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + gid = H5Gcreate2(fid, GROUP1_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + /* Get root group address */ + ret = H5Oget_info(fid, &oinfo); + CHECK(ret, FAIL, "H5Oget_info"); + root_addr = oinfo.addr; + + /* + * Create link to root group + */ + ret = H5Lcreate_hard(fid, "/", gid, LINK1_NAME, H5P_DEFAULT, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Lcreate_hard"); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check link */ + gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); + oid = H5Oopen(gid, LINK1_NAME, H5P_DEFAULT); + CHECK(oid, FAIL, "H5Oopen"); + ret = H5Oget_info(oid, &oinfo); + CHECK(ret, FAIL, "H5Oget_info"); + if(oinfo.addr != root_addr) + TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n", (long long unsigned)oinfo.addr, (long long unsigned)root_addr); + + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Oclose(oid); + CHECK(ret, FAIL, "H5Oclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* + * Create attribute. Should cause chunk size field to expand by 1 byte + * (1->2). + */ + gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); + sid = H5Screate_simple(1, &dims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + aid = H5Acreate2(gid, ATTR1_NAME, H5T_STD_I8LE, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(aid, FAIL, "H5Acreate2"); + + /* Close file */ + ret = H5Aclose(aid); + CHECK(ret, FAIL, "H5Aclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + + /* Open file */ + fid = H5Fopen(FILENAME, H5F_ACC_RDONLY, fapl); + CHECK(fid, FAIL, "H5Fopen"); + + /* Check link and attribute */ + gid = H5Gopen2(fid, GROUP1_NAME, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gopen2"); + oid = H5Oopen(gid, LINK1_NAME, H5P_DEFAULT); + CHECK(oid, FAIL, "H5Oopen"); + ret = H5Oget_info(oid, &oinfo); + CHECK(ret, FAIL, "H5Oget_info"); + if(oinfo.addr != root_addr) + TestErrPrintf("incorrect link target address: addr: %llu, expected: %llu\n", (long long unsigned)oinfo.addr, (long long unsigned)root_addr); + ret = H5Aget_info_by_name(gid, ".", ATTR1_NAME, &ainfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Aget_info_by_name"); + if(ainfo.data_size != dims) + TestErrPrintf("attribute data size different: data_size=%llu, should be %llu\n", (long long unsigned)ainfo.data_size, (long long unsigned)dims); + + /* Close IDs */ + ret = H5Oclose(oid); + CHECK(ret, FAIL, "H5Oclose"); + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); +} /* test_attr_bug8() */ /**************************************************************** ** @@ -10364,6 +10698,8 @@ test_attr(void) test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */ test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */ test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */ + test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */ + test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */ } /* end for */ } /* end if */ else { @@ -10388,6 +10724,10 @@ test_attr(void) test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */ test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */ test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */ + /* Skip test_attr_bug7 because it is specific to the new object + * header format and in fact fails if used with the old format, due + * to the attributes being larger than 64K */ + test_attr_bug8(fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */ } /* end else */ } /* end for */ diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1 index 308ca07..8d6e208 100644 --- a/test/testfiles/error_test_1 +++ b/test/testfiles/error_test_1 @@ -1,8 +1,6 @@ ############################# Expected output for error_test ############################# -Testing error API based on data I/O -All error API tests passed. This program tests the Error API. There're supposed to be some error messages ********* Print error stack in HDF5 default way ********* Second Test-DIAG: Error detected in Second Program (1.0) thread (IDs): @@ -23,6 +21,8 @@ Error Test-DIAG: Error detected in Error Program (1.0) thread (IDs): class: Second Test major: Error in test minor: Error in error stack + +Testing error API based on data I/O HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Dwrite(): not a dataset major: Invalid arguments to routine @@ -38,3 +38,23 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #002: (file name) line (number) in H5Dwrite(): not a dataset major: Invalid arguments to routine minor: Inappropriate type + +Testing error message during data reading when filter isn't registered +HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): + #000: (file name) line (number) in H5Dread(): can't read data + major: Dataset + minor: Read failed + #001: (file name) line (number) in H5D_read(): can't read data + major: Dataset + minor: Read failed + #002: (file name) line (number) in H5D_chunk_read(): unable to read raw data chunk + major: Low-level I/O + minor: Read failed + #003: (file name) line (number) in H5D_chunk_lock(): data pipeline read failed + major: Data filters + minor: Filter operation failed + #004: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered + major: Data filters + minor: Read failed + +All error API tests passed. diff --git a/test/testlinks_env.sh.in b/test/testlinks_env.sh.in index e71dfc8..5a7e045 100644 --- a/test/testlinks_env.sh.in +++ b/test/testlinks_env.sh.in @@ -35,7 +35,7 @@ TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary ENVCMD="env HDF5_EXT_PREFIX=.:tmp" # The environment variable & value # # Run the test -$ENVCMD $TEST_BIN +$ENVCMD $RUNSERIAL $TEST_BIN exitcode=$? if [ $exitcode -eq 0 ]; then echo "Test for HDF5_EXT_PREFIX PASSED" diff --git a/test/tfile.c b/test/tfile.c index 6c3746c..7d26c63 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1263,6 +1263,79 @@ test_file_perm(void) /**************************************************************** ** +** test_file_perm2(): low-level file test routine. +** This test verifies that no object can be created in a +** file that is opened for read-only. +** +*****************************************************************/ +static void +test_file_perm2(void) +{ + hid_t file; /* File opened with read-write permission */ + hid_t filero; /* Same file opened with read-only permission */ + hid_t dspace; /* Dataspace ID */ + hid_t group; /* Group ID */ + hid_t dset; /* Dataset ID */ + hid_t type; /* Datatype ID */ + hid_t attr; /* Attribute ID */ + herr_t ret; + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Low-Level File Permissions again\n")); + + dspace = H5Screate(H5S_SCALAR); + CHECK(dspace, FAIL, "H5Screate"); + + /* Create the file (with read-write permission) */ + file = H5Fcreate(FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file, FAIL, "H5Fcreate"); + + ret = H5Fclose(file); + CHECK(ret, FAIL, "H5Fclose"); + + /* Open the file (with read-only permission) */ + filero = H5Fopen(FILE2, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(filero, FAIL, "H5Fopen"); + + /* Create a group with the read-only file handle (should fail) */ + H5E_BEGIN_TRY { + group = H5Gcreate2(filero, "MY_GROUP", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(group, FAIL, "H5Gcreate2"); + + /* Create a dataset with the read-only file handle (should fail) */ + H5E_BEGIN_TRY { + dset = H5Dcreate2(filero, F2_DSET, H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(dset, FAIL, "H5Dcreate2"); + + /* Create an attribute with the read-only file handle (should fail) */ + H5E_BEGIN_TRY { + attr = H5Acreate2(filero, "MY_ATTR", H5T_NATIVE_INT, dspace, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(attr, FAIL, "H5Acreate2"); + + type = H5Tcopy(H5T_NATIVE_SHORT); + CHECK(type, FAIL, "H5Tcopy"); + + /* Commit a datatype with the read-only file handle (should fail) */ + H5E_BEGIN_TRY { + ret = H5Tcommit2(filero, "MY_DTYPE", type, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Tcommit2"); + + ret = H5Tclose(type); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Fclose(filero); + CHECK(ret, FAIL, "H5Fclose"); + + ret = H5Sclose(dspace); + CHECK(ret, FAIL, "H5Sclose"); +} /* end test_file_perm2() */ + +/**************************************************************** +** ** test_file_freespace(): low-level file test routine. ** This test checks the free space available in a file in various ** situations. @@ -3057,63 +3130,113 @@ 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) +** test_libver_bounds_real(): +** Verify that a file created and modified with the +** specified libver bounds has the specified object header +** versions for the right objects. ** ****************************************************************/ static void -test_libver_bounds(void) +test_libver_bounds_real(H5F_libver_t libver_create, unsigned oh_vers_create, + H5F_libver_t libver_mod, unsigned oh_vers_mod) { 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")); + H5O_info_t oinfo; /* Object info */ + herr_t ret; /* Return value */ /* - * Create a new file using the default properties. + * Create a new file using the creation properties. */ fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(fapl, FAIL, "H5Pcreate"); - ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); + ret = H5Pset_libver_bounds(fapl, libver_create, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); file = H5Fcreate("tfile5.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); + /* + * Make sure the root group has the correct object header version + */ + ret = H5Oget_info_by_name(file, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(oinfo.hdr.version, oh_vers_create, "H5Oget_info_by_name"); + + /* + * Reopen the file and make sure the root group still has the correct version + */ ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); - ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); + ret = H5Pset_libver_bounds(fapl, libver_mod, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); file = H5Fopen("tfile5.h5", H5F_ACC_RDWR, fapl); CHECK(file, FAIL, "H5Fopen"); + ret = H5Oget_info_by_name(file, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(oinfo.hdr.version, oh_vers_create, "H5Oget_info_by_name"); + /* - * Create a group named "G1" in the file. + * Create a group named "G1" in the file, and make sure it has the correct + * object header version */ group = H5Gcreate2(file, "/G1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group, FAIL, "H5Gcreate"); + ret = H5Oget_info(group, &oinfo); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(oinfo.hdr.version, oh_vers_mod, "H5Oget_info_by_name"); + ret = H5Gclose(group); CHECK(ret, FAIL, "H5Gclose"); /* - * Create a group named "/G1/G3" in the file. + * Create a group named "/G1/G3" in the file, and make sure it has the + * correct object header version */ group = H5Gcreate2(file, "/G1/G3", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group, FAIL, "H5Gcreate"); + ret = H5Oget_info(group, &oinfo); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(oinfo.hdr.version, oh_vers_mod, "H5Oget_info_by_name"); + ret = H5Gclose(group); CHECK(ret, FAIL, "H5Gclose"); + /* + * Make sure the root group still has the correct object header version + */ + ret = H5Oget_info_by_name(file, "/", &oinfo, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Oget_info_by_name"); + VERIFY(oinfo.hdr.version, oh_vers_create, "H5Oget_info_by_name"); + ret = H5Fclose(file); CHECK(ret, FAIL, "H5Fclose"); -} /* test_libver_bounds() */ +} /* end test_libver_bounds_real() */ + +/**************************************************************** +** +** test_libver_bounds(): +** Verify that a file created and modified with various +** libver bounds is handled correctly. (Further testing +** welcome) +** +****************************************************************/ +static void +test_libver_bounds(void) +{ + /* Output message about test being performed */ + MESSAGE(5, ("Testing setting library version bounds\n")); + + /* Run the tests */ + test_libver_bounds_real(H5F_LIBVER_EARLIEST, 1, H5F_LIBVER_LATEST, 2); + test_libver_bounds_real(H5F_LIBVER_LATEST, 2, H5F_LIBVER_EARLIEST, 1); +} /* end test_libver_bounds() */ /**************************************************************** ** @@ -3581,6 +3704,7 @@ test_file(void) #endif /* H5_NO_SHARED_WRITING */ test_get_file_id(); /* Test H5Iget_file_id */ test_file_perm(); /* Test file access permissions */ + test_file_perm2(); /* Test file access permission again */ test_file_freespace(); /* Test file free space information */ test_file_ishdf5(); /* Test detecting HDF5 files correctly */ test_file_open_dot(); /* Test opening objects with "." for a name */ diff --git a/test/th5o.c b/test/th5o.c index 70f8067..c46751e 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -1351,7 +1351,9 @@ test_h5o(void) test_h5o_link(); /* Test object link routine */ test_h5o_comment(); /* Test routines for comment */ test_h5o_comment_by_name(); /* Test routines for comment by name */ +#ifndef H5_CANNOT_OPEN_TWICE /* OpenVMS can't open a file twice */ test_h5o_getinfo_same_file(); /* Test info for objects in the same file */ +#endif /* H5_CANNOT_OPEN_TWICE */ } /* test_h5o() */ diff --git a/test/th5s.c b/test/th5s.c index d0d176a..87aa0f1 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -544,70 +544,13 @@ test_h5s_zero_dim(void) hssize_t nelem; /* Number of elements */ H5S_sel_type sel_type; /* Type of selection currently */ H5S_class_t stype; /* dataspace type */ + H5D_alloc_time_t alloc_time; /* Space allocation time */ herr_t ret; /* Generic return value */ unsigned int i, j, k; /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace with zero dimension size\n")); - /* Make sure we can create the space with the dimension size 0 (starting from v1.8.7). - * The dimension doesn't need to be unlimited. */ - sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - CHECK(sid1, FAIL, "H5Screate_simple"); - - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); - - sid1 = H5Screate(H5S_SIMPLE); - CHECK(sid1, FAIL, "H5Screate"); - - /* SID1 has the 1st dimension size as zero. The maximal dimension will be - * the same as the dimension because of the NULL passed in. */ - ret = H5Sset_extent_simple(sid1,SPACE1_RANK,dims1,NULL); - CHECK(ret, FAIL, "H5Sset_extent_simple"); - - /* Check that the dataspace actually has 0 elements */ - nelem = H5Sget_simple_extent_npoints(sid1); - VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); - - /* Check that the dataspace was created with an "all" selection */ - sel_type = H5Sget_select_type(sid1); - VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type"); - - /* Check that the dataspace has 0 elements selected */ - nelem = H5Sget_select_npoints(sid1); - VERIFY(nelem, 0, "H5Sget_select_npoints"); - - /* Change to "none" selection */ - ret = H5Sselect_none(sid1); - CHECK(ret, FAIL, "H5Sselect_none"); - - /* Check that the dataspace has 0 elements selected */ - nelem = H5Sget_select_npoints(sid1); - VERIFY(nelem, 0, "H5Sget_select_npoints"); - - /* Try to select all dataspace */ - ret = H5Sselect_all(sid1); - CHECK(ret, FAIL, "H5Sselect_all"); - - /* Check that the dataspace has 0 elements selected */ - nelem = H5Sget_select_npoints(sid1); - VERIFY(nelem, 0, "H5Sget_select_npoints"); - - /* Create the dataspace for chunked dataset with the first dimension size as zero. - * The maximal dimensions are bigger than the dimensions for later expansion. */ - sid_chunk = H5Screate_simple(SPACE1_RANK, dims1, max_dims); - CHECK(sid_chunk, FAIL, "H5Screate_simple"); - - /*============================================ - * Make sure we can use 0-dimension to create - * contiguous, chunked, compact, and external - * datasets, and also attribute. - *============================================ - */ - fid1 = H5Fcreate(ZEROFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - CHECK(fid1, FAIL, "H5Fcreate"); - /* Initialize the data */ for(i=0; i<SPACE1_DIM2; i++) for(j=0; j<SPACE1_DIM3; j++) { @@ -622,505 +565,588 @@ test_h5s_zero_dim(void) for(k=0; k<SPACE1_DIM3; k++) wdata_real[i][j][k] = i + j + k; - - /*===================== Contiguous dataset =======================*/ - dset1 = H5Dcreate2(fid1, BASICDATASET, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset1, FAIL, "H5Dcreate2"); - - /* Write "nothing" to the dataset */ - ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata); - CHECK(ret, FAIL, "H5Dwrite"); - - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); - - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); - - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); + /* Test with different space allocation times */ + for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) { + + /* Make sure we can create the space with the dimension size 0 (starting from v1.8.7). + * The dimension doesn't need to be unlimited. */ + dims1[0] = 0; + dims1[1] = SPACE1_DIM2; + dims1[2] = SPACE1_DIM3; + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + sid1 = H5Screate(H5S_SIMPLE); + CHECK(sid1, FAIL, "H5Screate"); + + /* SID1 has the 1st dimension size as zero. The maximal dimension will be + * the same as the dimension because of the NULL passed in. */ + ret = H5Sset_extent_simple(sid1,SPACE1_RANK,dims1,NULL); + CHECK(ret, FAIL, "H5Sset_extent_simple"); + + /* Check that the dataspace actually has 0 elements */ + nelem = H5Sget_simple_extent_npoints(sid1); + VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); + + /* Check that the dataspace was created with an "all" selection */ + sel_type = H5Sget_select_type(sid1); + VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type"); + + /* Check that the dataspace has 0 elements selected */ + nelem = H5Sget_select_npoints(sid1); + VERIFY(nelem, 0, "H5Sget_select_npoints"); + + /* Change to "none" selection */ + ret = H5Sselect_none(sid1); + CHECK(ret, FAIL, "H5Sselect_none"); + + /* Check that the dataspace has 0 elements selected */ + nelem = H5Sget_select_npoints(sid1); + VERIFY(nelem, 0, "H5Sget_select_npoints"); + + /* Try to select all dataspace */ + ret = H5Sselect_all(sid1); + CHECK(ret, FAIL, "H5Sselect_all"); + + /* Check that the dataspace has 0 elements selected */ + nelem = H5Sget_select_npoints(sid1); + VERIFY(nelem, 0, "H5Sget_select_npoints"); + + /* Create the dataspace for chunked dataset with the first dimension size as zero. + * The maximal dimensions are bigger than the dimensions for later expansion. */ + sid_chunk = H5Screate_simple(SPACE1_RANK, dims1, max_dims); + CHECK(sid_chunk, FAIL, "H5Screate_simple"); + + /*============================================ + * Make sure we can use 0-dimension to create + * contiguous, chunked, compact, and external + * datasets, and also attribute. + *============================================ + */ + fid1 = H5Fcreate(ZEROFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fcreate"); + + /*===================== Contiguous dataset =======================*/ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + CHECK(plist_id, FAIL, "H5Pcreate"); + + ret = H5Pset_alloc_time(plist_id, alloc_time); + CHECK(ret, FAIL, "H5Pset_alloc_time"); + + dset1 = H5Dcreate2(fid1, BASICDATASET, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT); + CHECK(dset1, FAIL, "H5Dcreate2"); + + ret = H5Pclose(plist_id); + CHECK(ret, FAIL, "H5Pclose"); + + /* Write "nothing" to the dataset */ + ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); + + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); + } } } - } - /* Write "nothing" to the dataset (with type conversion :-) */ - ret = H5Dwrite(dset1, H5T_NATIVE_SHORT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_short); - CHECK(ret, FAIL, "H5Dwrite"); + /* Write "nothing" to the dataset (with type conversion :-) */ + ret = H5Dwrite(dset1, H5T_NATIVE_SHORT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_short); + CHECK(ret, FAIL, "H5Dwrite"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata_short); - CHECK(ret, FAIL, "H5Dread"); + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata_short); + CHECK(ret, FAIL, "H5Dread"); - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata_short[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata_short[i][j]); + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata_short[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata_short[i][j]); + } } } - } - /* Select a hyperslab beyond its current dimension sizes, then try to write - * the data. It should fail. */ - ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + /* Select a hyperslab beyond its current dimension sizes, then try to write + * the data. It should fail. */ + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, wdata); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Dwrite"); + H5E_BEGIN_TRY { + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, wdata); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dwrite"); - /* Change to "none" selection */ - ret = H5Sselect_none(sid1); - CHECK(ret, FAIL, "H5Sselect_none"); + /* Change to "none" selection */ + ret = H5Sselect_none(sid1); + CHECK(ret, FAIL, "H5Sselect_none"); - /* Select a point beyond the dimension size, then try to write the data. - * It should fail. */ - coord[0][0]=2; coord[0][1]=5; coord[0][2]=3; - ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord); - CHECK(ret, FAIL, "H5Sselect_elements"); + /* Select a point beyond the dimension size, then try to write the data. + * It should fail. */ + coord[0][0]=2; coord[0][1]=5; coord[0][2]=3; + ret = H5Sselect_elements(sid1, H5S_SELECT_SET, (size_t)1, (const hsize_t *)coord); + CHECK(ret, FAIL, "H5Sselect_elements"); - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &val); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Dwrite"); - - /* Restore the selection to all */ - ret = H5Sselect_all(sid1); - CHECK(ret, FAIL, "H5Sselect_all"); - - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); - - /*=================== Chunked dataset ====================*/ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - CHECK(plist_id, FAIL, "H5Pcreate"); + H5E_BEGIN_TRY { + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, sid1, H5P_DEFAULT, &val); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dwrite"); - ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims); - CHECK(ret, FAIL, "H5Pset_chunk"); + /* Restore the selection to all */ + ret = H5Sselect_all(sid1); + CHECK(ret, FAIL, "H5Sselect_all"); - dset1 = H5Dcreate2(fid1, BASICDATASET1, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT); - CHECK(dset1, FAIL, "H5Dcreate2"); - - /* Write "nothing" to the dataset */ - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - CHECK(ret, FAIL, "H5Dwrite"); + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + /*=================== Chunked dataset ====================*/ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + CHECK(plist_id, FAIL, "H5Pcreate"); - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); + ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims); + CHECK(ret, FAIL, "H5Pset_chunk"); - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); - } - } + // ret = H5Pset_alloc_time(plist_id, alloc_time); + // CHECK(ret, FAIL, "H5Pset_alloc_time"); - /* Now extend the dataset to SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3 and make sure - * we can write data to it */ - ret = H5Dset_extent(dset1, extend_dims); - CHECK(ret, FAIL, "H5Dset_extent"); + dset1 = H5Dcreate2(fid1, BASICDATASET1, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT); + CHECK(dset1, FAIL, "H5Dcreate2"); - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real); - CHECK(ret, FAIL, "H5Dwrite"); + /* Write "nothing" to the dataset */ + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real); - CHECK(ret, FAIL, "H5Dread"); + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); - /* Check results */ - for(i=0; i<SPACE1_DIM1; i++) { - for(j=0; j<SPACE1_DIM2; j++) { - for(k=0; k<SPACE1_DIM3; k++) { - if(rdata_real[i][j][k] != wdata_real[i][j][k]) { + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { H5_FAILED(); - printf("element [%d][%d][%d] is %d but should have been %d\n", - i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); } - } } - } - - /* Now shrink the first dimension size of the dataset to 0 and make sure no data is in it */ - extend_dims[0] = 0; - ret = H5Dset_extent(dset1, extend_dims); - CHECK(ret, FAIL, "H5Dset_extent"); - - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); - - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); + /* Now extend the dataset to SPACE1_DIM1*SPACE1_DIM2*SPACE1_DIM3 and make sure + * we can write data to it */ + extend_dims[0] = SPACE1_DIM1; + ret = H5Dset_extent(dset1, extend_dims); + CHECK(ret, FAIL, "H5Dset_extent"); + + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); + + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real); + CHECK(ret, FAIL, "H5Dread"); + + /* Check results */ + for(i=0; i<SPACE1_DIM1; i++) { + for(j=0; j<SPACE1_DIM2; j++) { + for(k=0; k<SPACE1_DIM3; k++) { + if(rdata_real[i][j][k] != wdata_real[i][j][k]) { + H5_FAILED(); + printf("element [%d][%d][%d] is %d but should have been %d\n", + i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]); + } + } } - } + } - /* Now extend the first dimension size of the dataset to SPACE1_DIM1*3 past the maximal size. - * It is supposed to fail. */ - extend_dims[0] = SPACE1_DIM1*3; - H5E_BEGIN_TRY { + /* Now shrink the first dimension size of the dataset to 0 and make sure no data is in it */ + extend_dims[0] = 0; ret = H5Dset_extent(dset1, extend_dims); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Dset_extent"); - - ret = H5Pclose(plist_id); - CHECK(ret, FAIL, "H5Pclose"); - - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); - - /*=================== Compact dataset =====================*/ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - CHECK(plist_id, FAIL, "H5Pcreate"); - - ret = H5Pset_layout(plist_id, H5D_COMPACT); - CHECK(ret, FAIL, "H5Pset_layout"); - - ret = H5Pset_alloc_time(plist_id, H5D_ALLOC_TIME_EARLY); - CHECK(ret, FAIL, "H5Pset_alloc_time"); + CHECK(ret, FAIL, "H5Dset_extent"); - dset1 = H5Dcreate2(fid1, BASICDATASET2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT); - CHECK(dset1, FAIL, "H5Dcreate2"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - /* Write "nothing" to the dataset */ - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); - CHECK(ret, FAIL, "H5Dwrite"); + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); + } + } - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); + /* Now extend the first dimension size of the dataset to SPACE1_DIM1*3 past the maximal size. + * It is supposed to fail. */ + extend_dims[0] = SPACE1_DIM1*3; + H5E_BEGIN_TRY { + ret = H5Dset_extent(dset1, extend_dims); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dset_extent"); - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); - } - } + ret = H5Pclose(plist_id); + CHECK(ret, FAIL, "H5Pclose"); - ret = H5Pclose(plist_id); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /*=================== Compact dataset =====================*/ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + CHECK(plist_id, FAIL, "H5Pcreate"); - /*=========== Contiguous dataset with external storage ============*/ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - CHECK(plist_id, FAIL, "H5Pcreate"); + ret = H5Pset_layout(plist_id, H5D_COMPACT); + CHECK(ret, FAIL, "H5Pset_layout"); - ret = H5Pset_layout(plist_id, H5D_CONTIGUOUS); - CHECK(ret, FAIL, "H5Pset_layout"); + /* Don't set the allocation time for compact storage datasets (must be early) */ - /* Change the DCPL for contiguous layout with external storage. The size of the reserved - * space in the external file is the size of the dataset (zero because one dimension size is zero). - * There's no need to clean up the external file since the library doesn't create it - * until the data is written to it. */ - ret = H5Pset_external(plist_id, EXTFILE_NAME, (off_t)0, (hsize_t)0); - CHECK(ret, FAIL, "H5Pset_external"); + dset1 = H5Dcreate2(fid1, BASICDATASET2, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT); + CHECK(dset1, FAIL, "H5Dcreate2"); - dset1 = H5Dcreate2(fid1, BASICDATASET3, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT); - CHECK(dset1, FAIL, "H5Dcreate2"); + /* Write "nothing" to the dataset */ + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); - /* Write "nothing" to the dataset */ - ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata); - CHECK(ret, FAIL, "H5Dwrite"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); - - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); - } + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); + } } - } - ret = H5Pclose(plist_id); - CHECK(ret, FAIL, "H5Pclose"); + ret = H5Pclose(plist_id); + CHECK(ret, FAIL, "H5Pclose"); - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); - - /*=============== Create an attribute for the file ================*/ - attr = H5Acreate2(fid1, NULLATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Acreate2"); + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* Write "nothing" to the attribute */ - ret = H5Awrite(attr, H5T_NATIVE_INT, wdata); - CHECK(ret, FAIL, "H5Awrite"); + /*=========== Contiguous dataset with external storage ============*/ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + CHECK(plist_id, FAIL, "H5Pcreate"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + /* Change the DCPL for contiguous layout with external storage. The size of the reserved + * space in the external file is the size of the dataset (zero because one dimension size is zero). + * There's no need to clean up the external file since the library doesn't create it + * until the data is written to it. */ + ret = H5Pset_external(plist_id, EXTFILE_NAME, (off_t)0, (hsize_t)0); + CHECK(ret, FAIL, "H5Pset_external"); - /* Try reading from the attribute (make certain our buffer is unmodified) */ - ret = H5Aread(attr, H5T_NATIVE_INT, rdata); - CHECK(ret, FAIL, "H5Aread"); + ret = H5Pset_alloc_time(plist_id, alloc_time); + CHECK(ret, FAIL, "H5Pset_alloc_time"); - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); - } - } - } + dset1 = H5Dcreate2(fid1, BASICDATASET3, H5T_NATIVE_INT, sid1, H5P_DEFAULT, plist_id, H5P_DEFAULT); + CHECK(dset1, FAIL, "H5Dcreate2"); - /* Write "nothing" to the attribute (with type conversion :-) */ - ret = H5Awrite(attr, H5T_NATIVE_SHORT, wdata_short); - CHECK(ret, FAIL, "H5Awrite"); + /* Write "nothing" to the dataset */ + ret = H5Dwrite(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - /* Try reading from the attribute (with type conversion :-) (make certain our buffer is unmodified) */ - ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short); - CHECK(ret, FAIL, "H5Aread"); + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, sid1, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata_short[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata_short[i][j]); + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); + } } } - } - /*=============================================================== - * Extend the dimension to make it a normal dataspace (3x15x13). - * Verify that data can be written to and read from the chunked - * dataset now. - *=============================================================== - */ - dims1[0]=SPACE1_DIM1; - ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,max_dims); - CHECK(ret, FAIL, "H5Sset_extent_simple"); + ret = H5Pclose(plist_id); + CHECK(ret, FAIL, "H5Pclose"); - nelem = H5Sget_simple_extent_npoints(sid_chunk); - CHECK(nelem, FAIL, "H5Sget_simple_extent_npoints"); - VERIFY(nelem, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, - "H5Sget_simple_extent_npoints"); + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - rank = H5Sget_simple_extent_ndims(sid_chunk); - CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); - VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); - - rank = H5Sget_simple_extent_dims(sid_chunk, tdims, NULL); - CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, - "H5Sget_simple_extent_dims"); - - /* Set it to chunked dataset */ - plist_id = H5Pcreate(H5P_DATASET_CREATE); - CHECK(plist_id, FAIL, "H5Pcreate"); - - ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims); - CHECK(ret, FAIL, "H5Pset_chunk"); - - dset1 = H5Dcreate2(fid1, BASICDATASET4, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT); - CHECK(dset1, FAIL, "H5Dcreate2"); + /*=============== Create an attribute for the file ================*/ + attr = H5Acreate2(fid1, NULLATTR, H5T_NATIVE_INT, sid1, H5P_DEFAULT, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate2"); - ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real); - CHECK(ret, FAIL, "H5Dwrite"); + /* Write "nothing" to the attribute */ + ret = H5Awrite(attr, H5T_NATIVE_INT, wdata); + CHECK(ret, FAIL, "H5Awrite"); - ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); - CHECK(ret, FAIL, "H5Fflush"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real); - CHECK(ret, FAIL, "H5Dread"); + /* Try reading from the attribute (make certain our buffer is unmodified) */ + ret = H5Aread(attr, H5T_NATIVE_INT, rdata); + CHECK(ret, FAIL, "H5Aread"); - /* Check results */ - for(i=0; i<SPACE1_DIM1; i++) { - for(j=0; j<SPACE1_DIM2; j++) { - for(k=0; k<SPACE1_DIM3; k++) { - if(rdata_real[i][j][k] != wdata_real[i][j][k]) { + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { H5_FAILED(); - printf("element [%d][%d][%d] is %d but should have been %d\n", - i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); } } } - } - - ret = H5Pclose(plist_id); - CHECK(ret, FAIL, "H5Pclose"); - - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); - - /* Change the dimensions to make them zero size again (0x0x0). Verify that - * no element is in the dataspace. */ - dims1[0]=dims1[1]=dims1[2]=0; - ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,NULL); - CHECK(ret, FAIL, "H5Sset_extent_simple"); - - /* Check that the dataspace actually has 0 elements */ - nelem = H5Sget_simple_extent_npoints(sid_chunk); - VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); - - /* Check that the dataspace was created with an "all" selection */ - sel_type = H5Sget_select_type(sid_chunk); - VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type"); - - /* Check that the dataspace has 0 elements selected */ - nelem = H5Sget_select_npoints(sid_chunk); - VERIFY(nelem, 0, "H5Sget_select_npoints"); - - /* Change to "none" selection */ - ret = H5Sselect_none(sid_chunk); - CHECK(ret, FAIL, "H5Sselect_none"); - /* Check that the dataspace has 0 elements selected */ - nelem = H5Sget_select_npoints(sid_chunk); - VERIFY(nelem, 0, "H5Sget_select_npoints"); - - ret = H5Sclose(sid_chunk); - CHECK(ret, FAIL, "H5Sclose"); - - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); - - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); - - /*============================================ - * Reopen the file to check the data space - *============================================ - */ - fid1 = H5Fopen(ZEROFILE, H5F_ACC_RDONLY, H5P_DEFAULT); - CHECK(fid1, FAIL, "H5Fopen"); - - /* Reopen the chunked dataset */ - dset1 = H5Dopen2(fid1, BASICDATASET1, H5P_DEFAULT); - CHECK(dset1, FAIL, "H5Dopen2"); + /* Write "nothing" to the attribute (with type conversion :-) */ + ret = H5Awrite(attr, H5T_NATIVE_SHORT, wdata_short); + CHECK(ret, FAIL, "H5Awrite"); - /* Get the space of the dataset and querry it */ - sid1 = H5Dget_space(dset1); - CHECK(sid1, FAIL, "H5Dget_space"); - - /* Verify the class type of dataspace */ - stype = H5Sget_simple_extent_type(sid1); - VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type"); + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); - /* Verify there is zero element in the dataspace */ - nelem = H5Sget_simple_extent_npoints(sid1); - VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); + /* Try reading from the attribute (with type conversion :-) (make certain our buffer is unmodified) */ + ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short); + CHECK(ret, FAIL, "H5Aread"); - /* Verify the dimension sizes are correct */ - rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); - CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); - VERIFY(tdims[0], 0, "H5Sget_simple_extent_dims"); - VERIFY(tdims[1], SPACE1_DIM2, "H5Sget_simple_extent_dims"); - VERIFY(tdims[2], SPACE1_DIM3, "H5Sget_simple_extent_dims"); + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata_short[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata_short[i][j]); + } + } + } - /* Try reading from the dataset (make certain our buffer is unmodified) */ - ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); - CHECK(ret, FAIL, "H5Dread"); + /* Close attribute */ + ret = H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); + + /*=============================================================== + * Extend the dimension to make it a normal dataspace (3x15x13). + * Verify that data can be written to and read from the chunked + * dataset now. + *=============================================================== + */ + dims1[0]=SPACE1_DIM1; + ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,max_dims); + CHECK(ret, FAIL, "H5Sset_extent_simple"); + + nelem = H5Sget_simple_extent_npoints(sid_chunk); + CHECK(nelem, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(nelem, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, + "H5Sget_simple_extent_npoints"); + + rank = H5Sget_simple_extent_ndims(sid_chunk); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + + rank = H5Sget_simple_extent_dims(sid_chunk, tdims, NULL); + CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, + "H5Sget_simple_extent_dims"); + + /* Set it to chunked dataset */ + plist_id = H5Pcreate(H5P_DATASET_CREATE); + CHECK(plist_id, FAIL, "H5Pcreate"); + + ret = H5Pset_chunk(plist_id, SPACE1_RANK, chunk_dims); + CHECK(ret, FAIL, "H5Pset_chunk"); + + ret = H5Pset_alloc_time(plist_id, alloc_time); + CHECK(ret, FAIL, "H5Pset_alloc_time"); + + dset1 = H5Dcreate2(fid1, BASICDATASET4, H5T_NATIVE_INT, sid_chunk, H5P_DEFAULT, plist_id, H5P_DEFAULT); + CHECK(dset1, FAIL, "H5Dcreate2"); + + ret = H5Dwrite(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata_real); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Fflush(fid1, H5F_SCOPE_GLOBAL); + CHECK(ret, FAIL, "H5Fflush"); + + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_real); + CHECK(ret, FAIL, "H5Dread"); + + /* Check results */ + for(i=0; i<SPACE1_DIM1; i++) { + for(j=0; j<SPACE1_DIM2; j++) { + for(k=0; k<SPACE1_DIM3; k++) { + if(rdata_real[i][j][k] != wdata_real[i][j][k]) { + H5_FAILED(); + printf("element [%d][%d][%d] is %d but should have been %d\n", + i, j, k, rdata_real[i][j][k], wdata_real[i][j][k]); + } + } + } + } - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata[i][j]); + ret = H5Pclose(plist_id); + CHECK(ret, FAIL, "H5Pclose"); + + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); + + /* Change the dimensions to make them zero size again (0x0x0). Verify that + * no element is in the dataspace. */ + dims1[0]=dims1[1]=dims1[2]=0; + ret = H5Sset_extent_simple(sid_chunk,SPACE1_RANK,dims1,NULL); + CHECK(ret, FAIL, "H5Sset_extent_simple"); + + /* Check that the dataspace actually has 0 elements */ + nelem = H5Sget_simple_extent_npoints(sid_chunk); + VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); + + /* Check that the dataspace was created with an "all" selection */ + sel_type = H5Sget_select_type(sid_chunk); + VERIFY(sel_type, H5S_SEL_ALL, "H5Sget_select_type"); + + /* Check that the dataspace has 0 elements selected */ + nelem = H5Sget_select_npoints(sid_chunk); + VERIFY(nelem, 0, "H5Sget_select_npoints"); + + /* Change to "none" selection */ + ret = H5Sselect_none(sid_chunk); + CHECK(ret, FAIL, "H5Sselect_none"); + + /* Check that the dataspace has 0 elements selected */ + nelem = H5Sget_select_npoints(sid_chunk); + VERIFY(nelem, 0, "H5Sget_select_npoints"); + + ret = H5Sclose(sid_chunk); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /*============================================ + * Reopen the file to check the data space + *============================================ + */ + fid1 = H5Fopen(ZEROFILE, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid1, FAIL, "H5Fopen"); + + /* Reopen the chunked dataset */ + dset1 = H5Dopen2(fid1, BASICDATASET1, H5P_DEFAULT); + CHECK(dset1, FAIL, "H5Dopen2"); + + /* Get the space of the dataset and querry it */ + sid1 = H5Dget_space(dset1); + CHECK(sid1, FAIL, "H5Dget_space"); + + /* Verify the class type of dataspace */ + stype = H5Sget_simple_extent_type(sid1); + VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type"); + + /* Verify there is zero element in the dataspace */ + nelem = H5Sget_simple_extent_npoints(sid1); + VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); + + /* Verify the dimension sizes are correct */ + rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); + CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); + VERIFY(tdims[0], 0, "H5Sget_simple_extent_dims"); + VERIFY(tdims[1], SPACE1_DIM2, "H5Sget_simple_extent_dims"); + VERIFY(tdims[2], SPACE1_DIM3, "H5Sget_simple_extent_dims"); + + /* Try reading from the dataset (make certain our buffer is unmodified) */ + ret = H5Dread(dset1, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); + CHECK(ret, FAIL, "H5Dread"); + + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata[i][j]); + } } } - } - /* Close the dataset and its dataspace */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Close the dataset and its dataspace */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Open the attribute for the file */ - attr = H5Aopen(fid1, NULLATTR, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Aopen"); + /* Open the attribute for the file */ + attr = H5Aopen(fid1, NULLATTR, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Aopen"); - /* Get the space of the dataset */ - attr_sid = H5Aget_space(attr); - CHECK(attr_sid, FAIL, "H5Aget_space"); + /* Get the space of the dataset */ + attr_sid = H5Aget_space(attr); + CHECK(attr_sid, FAIL, "H5Aget_space"); - /* Verify the class type of dataspace */ - stype = H5Sget_simple_extent_type(attr_sid); - VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type"); + /* Verify the class type of dataspace */ + stype = H5Sget_simple_extent_type(attr_sid); + VERIFY(stype, H5S_SIMPLE, "H5Sget_simple_extent_type"); - /* Verify there is zero element in the dataspace */ - nelem = H5Sget_simple_extent_npoints(attr_sid); - VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); + /* Verify there is zero element in the dataspace */ + nelem = H5Sget_simple_extent_npoints(attr_sid); + VERIFY(nelem, 0, "H5Sget_simple_extent_npoints"); - /* Try reading from the attribute (make certain our buffer is unmodified) */ - ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short); - CHECK(ret, FAIL, "H5Aread"); + /* Try reading from the attribute (make certain our buffer is unmodified) */ + ret = H5Aread(attr, H5T_NATIVE_SHORT, rdata_short); + CHECK(ret, FAIL, "H5Aread"); - /* Check results */ - for(i=0; i<SPACE1_DIM2; i++) { - for(j=0; j<SPACE1_DIM3; j++) { - if(rdata_short[i][j] != 7) { - H5_FAILED(); - printf("element [%d][%d] is %d but should have been 7\n", - i, j, rdata_short[i][j]); + /* Check results */ + for(i=0; i<SPACE1_DIM2; i++) { + for(j=0; j<SPACE1_DIM3; j++) { + if(rdata_short[i][j] != 7) { + H5_FAILED(); + printf("element [%d][%d] is %d but should have been 7\n", + i, j, rdata_short[i][j]); + } } } - } - /* Close attribute */ - ret=H5Aclose(attr); - CHECK(ret, FAIL, "H5Aclose"); + /* Close attribute */ + ret=H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); - /* Close the dataspace */ - ret = H5Sclose(attr_sid); - CHECK(ret, FAIL, "H5Sclose"); + /* Close the dataspace */ + ret = H5Sclose(attr_sid); + CHECK(ret, FAIL, "H5Sclose"); - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_zero_dim() */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + } /* end for */ +} /* test_h5s_zero_dim() */ /**************************************************************** diff --git a/test/tmisc.c b/test/tmisc.c index b7ed202..5539cee 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -15,7 +15,7 @@ /*********************************************************** * -* Test program: tmisc +* Test program: tmisc * * Test miscellaneous features not tested elsewhere. Generally * regression tests for bugs that are reported and don't @@ -23,7 +23,7 @@ * *************************************************************/ -#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ /* Define this macro to indicate that the testing APIs should be available */ #define H5D_TESTING @@ -31,10 +31,10 @@ #include "hdf5.h" #include "testhdf5.h" #include "H5srcdir.h" -#include "H5Dpkg.h" /* Datasets */ +#include "H5Dpkg.h" /* Datasets */ /* Definitions for misc. test #1 */ -#define MISC1_FILE "tmisc1.h5" +#define MISC1_FILE "tmisc1.h5" #define MISC1_VAL (13417386) /* 0xccbbaa */ #define MISC1_VAL2 (15654348) /* 0xeeddcc */ #define MISC1_DSET_NAME "/scalar_set" @@ -166,8 +166,8 @@ typedef struct /* Definitions for misc. test #12 */ #define MISC12_FILE "tmisc12.h5" #define MISC12_DSET_NAME "Dataset" -#define MISC12_SPACE1_RANK 1 -#define MISC12_SPACE1_DIM1 4 +#define MISC12_SPACE1_RANK 1 +#define MISC12_SPACE1_DIM1 4 #define MISC12_CHUNK_SIZE 2 #define MISC12_APPEND_SIZE 5 @@ -239,6 +239,7 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC20_SPACE2_DIM0 8 #define MISC20_SPACE2_DIM1 4 +#ifdef H5_HAVE_FILTER_SZIP /* Definitions for misc. test #21 */ #define MISC21_FILE "tmisc21.h5" #define MISC21_DSET_NAME "Dataset" @@ -256,6 +257,7 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC22_CHUNK_DIM1 512 #define MISC22_SPACE_DIM0 639 #define MISC22_SPACE_DIM1 1308 +#endif /* H5_HAVE_FILTER_SZIP */ /* Definitions for misc. test #23 */ #define MISC23_FILE "tmisc23.h5" @@ -311,6 +313,9 @@ unsigned m13_rdata[MISC13_DIM1][MISC13_DIM2]; /* Data read from dataset #define MISC29_COPY_FILE "tmisc29.h5" #define MISC29_DSETNAME "dset2" +/* Definitions for misc. test #30 */ +#define MISC30_FILE "tmisc30.h5" + /**************************************************************** ** ** test_misc1(): test unlinking a dataset from a group and immediately @@ -448,7 +453,7 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att1, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - free(data_check.string); + HDfree(data_check.string); ret = H5Aclose(att1); CHECK(ret, FAIL, "HAclose"); @@ -459,8 +464,6 @@ static void test_misc2_write_attribute(void) ret = H5Fclose(file1); CHECK(ret, FAIL, "H5Fclose"); - - root2 = H5Gopen2(file2, "/", H5P_DEFAULT); CHECK(root2, FAIL, "H5Gopen2"); @@ -475,7 +478,7 @@ static void test_misc2_write_attribute(void) ret = H5Aread(att2, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - free(data_check.string); + HDfree(data_check.string); ret = H5Aclose(att2); CHECK(ret, FAIL, "HAclose"); @@ -492,8 +495,8 @@ static void test_misc2_write_attribute(void) ret = H5Fclose(file2); CHECK(ret, FAIL, "H5Fclose"); - free(string_att1); - free(string_att2); + HDfree(string_att1); + HDfree(string_att2); return; } @@ -519,7 +522,7 @@ static void test_misc2_read_attribute(const char *filename, const char *att_name ret = H5Aread(att, type, &data_check); CHECK(ret, FAIL, "H5Aread"); - free(data_check.string); + HDfree(data_check.string); ret = H5Aclose(att); CHECK(ret, FAIL, "H5Aclose"); @@ -727,7 +730,7 @@ delete_struct3(misc5_struct3_hndl *str3hndl) ret=H5Tclose(str3hndl->st3h_base); CHECK(ret,FAIL,"H5Tclose"); - free(str3hndl); + HDfree(str3hndl); } static void @@ -778,7 +781,7 @@ delete_struct2(misc5_struct2_hndl *str2hndl) H5Tclose(str2hndl->st2h_base); CHECK(ret,FAIL,"H5Tclose"); - free(str2hndl); + HDfree(str2hndl); } static void @@ -789,7 +792,7 @@ set_struct2(misc5_struct2 *buf) buf->st2_el1=MISC5_DBGELVAL2; buf->st2_el2.len=MISC5_DBGNELM3; - buf->st2_el2.p=malloc((buf->st2_el2.len)*sizeof(misc5_struct3)); + buf->st2_el2.p=HDmalloc((buf->st2_el2.len)*sizeof(misc5_struct3)); CHECK(buf->st2_el2.p,NULL,"malloc"); for(i=0; i<(buf->st2_el2.len); i++) @@ -799,7 +802,7 @@ set_struct2(misc5_struct2 *buf) static void clear_struct2(misc5_struct2 *buf) { - free(buf->st2_el2.p); + HDfree(buf->st2_el2.p); } /*********************** struct1 ***********************/ @@ -844,7 +847,7 @@ delete_struct1(misc5_struct1_hndl *str1hndl) ret=H5Tclose(str1hndl->st1h_base); CHECK(ret,FAIL,"H5Tclose"); - free(str1hndl); + HDfree(str1hndl); } static void @@ -855,7 +858,7 @@ set_struct1(misc5_struct1 *buf) buf->st1_el1=MISC5_DBGELVAL1; buf->st1_el2.len=MISC5_DBGNELM2; - buf->st1_el2.p=malloc((buf->st1_el2.len)*sizeof(misc5_struct2)); + buf->st1_el2.p=HDmalloc((buf->st1_el2.len)*sizeof(misc5_struct2)); CHECK(buf->st1_el2.p,NULL,"malloc"); for(i=0; i<(buf->st1_el2.len); i++) @@ -869,7 +872,7 @@ clear_struct1(misc5_struct1 *buf) for(i=0;i<buf->st1_el2.len;i++) clear_struct2(&((( misc5_struct2 *)(buf->st1_el2.p))[i])); - free(buf->st1_el2.p); + HDfree(buf->st1_el2.p); } static void @@ -905,7 +908,7 @@ test_misc5(void) /* Create the variable-length buffer */ buf.len = MISC5_DBGNELM1; - buf.p = malloc((buf.len) * sizeof(misc5_struct1)); + buf.p = HDmalloc((buf.len) * sizeof(misc5_struct1)); CHECK(buf.p, NULL, "malloc"); /* Create the top-level VL information */ @@ -921,7 +924,7 @@ test_misc5(void) clear_struct1(&(((misc5_struct1 *)(buf.p))[j])); /* Free the variable-length buffer */ - free(buf.p); + HDfree(buf.p); /* Close dataset */ ret = H5Dclose(dataset_id); @@ -1231,10 +1234,10 @@ test_misc8(void) MESSAGE(5, ("Testing dataset storage sizes\n")); /* Allocate space for the data to write & read */ - wdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); + wdata=HDmalloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); CHECK(wdata,NULL,"malloc"); #ifdef VERIFY_DATA - rdata=malloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); + rdata=HDmalloc(sizeof(int)*MISC8_DIM0*MISC8_DIM1); CHECK(rdata,NULL,"malloc"); #endif /* VERIFY_DATA */ @@ -1672,7 +1675,7 @@ test_misc8(void) CHECK(ret, FAIL, "H5Fclose"); /* Free the read & write buffers */ - free(wdata); + HDfree(wdata); #ifdef VERIFY_DATA free(rdata); #endif /* VERIFY_DATA */ @@ -1795,10 +1798,10 @@ test_misc11(void) unsigned sym_ik; /* Symbol table B-tree initial 'K' value */ unsigned istore_ik; /* Indexed storage B-tree initial 'K' value */ unsigned sym_lk; /* Symbol table B-tree leaf 'K' value */ - unsigned nindexes; /* Shared message number of indexes */ - H5F_info2_t finfo; /* global information about file */ - H5F_file_space_type_t strategy; /* File/free space strategy */ - hsize_t threshold; /* Free-space section threshold */ + unsigned nindexes; /* Shared message number of indexes */ + H5F_info2_t finfo; /* global information about file */ + H5F_file_space_type_t strategy; /* File/free space strategy */ + hsize_t threshold; /* Free-space section threshold */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -1953,10 +1956,10 @@ test_misc12(void) hsize_t dimsn[] = {MISC12_APPEND_SIZE}; hsize_t maxdims1[1] = {H5S_UNLIMITED}; hsize_t chkdims1[1] = {MISC12_CHUNK_SIZE}; - hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE}; - hsize_t offset[1] = {MISC12_SPACE1_DIM1}; - hsize_t count[1] = {MISC12_APPEND_SIZE}; - int i; /* counting variable */ + hsize_t newsize[1] = {MISC12_SPACE1_DIM1+MISC12_APPEND_SIZE}; + hsize_t offset[1] = {MISC12_SPACE1_DIM1}; + hsize_t count[1] = {MISC12_APPEND_SIZE}; + int i; /* counting variable */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -2210,7 +2213,7 @@ create_hdf_file(const char *name) /* Close the file */ ret = H5Fclose(fid); - assert(ret >= 0); + HDassert(ret >= 0); CHECK(ret, FAIL, "H5Fclose"); } @@ -2240,7 +2243,7 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz VERIFY(written, size, "HDfwrite"); /* Open the old file */ - old_fp=fopen(old_name,"rb"); + old_fp=HDfopen(old_name,"rb"); CHECK(old_fp, NULL, "HDfopen"); /* Allocate space for the copy buffer */ @@ -2263,10 +2266,10 @@ insert_user_block(const char *old_name, const char *new_name,const char *str,siz VERIFY(ret, 0, "HDfclose"); /* Free the copy buffer */ - free(copy_buf); + HDfree(copy_buf); /* Free the user block */ - free(user_block); + HDfree(user_block); } static void @@ -3529,7 +3532,7 @@ test_misc20(void) and encoder is available. EIP 2004/8/04 */ -#if defined H5_HAVE_FILTER_SZIP +#ifdef H5_HAVE_FILTER_SZIP /**************************************************************** ** @@ -4447,7 +4450,6 @@ test_misc25a(void) CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -4491,7 +4493,6 @@ test_misc25a(void) CHECK(ret, FAIL, "H5Fclose"); - /* Re-open file */ fid = H5Fopen(MISC25A_FILE, H5F_ACC_RDWR, H5P_DEFAULT); CHECK(fid, FAIL, "H5Fopen"); @@ -5113,6 +5114,87 @@ test_misc29(void) CHECK(ret, FAIL, "H5Fclose"); } /* end test_misc29() */ + +static int +test_misc30_get_info_cb(hid_t loc_id, const char *name, const H5L_info_t UNUSED *info, + void UNUSED *op_data) +{ + H5O_info_t object_info; + + return H5Oget_info_by_name(loc_id, name, &object_info, H5P_DEFAULT); +} + +static int +test_misc30_get_info(hid_t loc_id) +{ + return H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, test_misc30_get_info_cb, NULL); +} + + +/**************************************************************** +** +** test_misc30(): Exercise local heap code that loads prefix +** separately from data block, causing the free +** block information to get lost. +** +****************************************************************/ +static void +test_misc30(void) +{ + hsize_t file_size[] = {0, 0}; /* Sizes of file created */ + hbool_t get_info; /* Whether to perform the get info call */ + + /* Output message about test being performed */ + MESSAGE(5, ("Local heap dropping free block info\n")); + + for(get_info = FALSE; get_info <= TRUE; get_info++) { + hid_t fid; /* File ID */ + hid_t gid; /* Group ID */ + int i; /* Local index counter */ + herr_t ret; /* Generic return value */ + + fid = H5Fcreate(MISC30_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fcreate"); + gid = H5Gcreate2(fid, "/g0", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + + for(i = 0; i < 20; i++) { + char gname[32]; + + fid = H5Fopen(MISC30_FILE, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + + if(get_info) { + ret = test_misc30_get_info(fid); + CHECK(ret, FAIL, "test_misc30_get_info"); + } + + sprintf(gname, "/g0/group%d", i); + gid = H5Gcreate2(fid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK(gid, FAIL, "H5Gcreate2"); + + ret = H5Gclose(gid); + CHECK(ret, FAIL, "H5Gclose"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + + fid = H5Fopen(MISC30_FILE, H5F_ACC_RDONLY, H5P_DEFAULT); + CHECK(fid, FAIL, "H5Fopen"); + ret = H5Fget_filesize(fid, &file_size[get_info]); + CHECK(fid, FAIL, "H5Fget_filesize"); + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); + } + + VERIFY(file_size[0], file_size[1], "test_misc30"); +} /* end test_misc30() */ + /**************************************************************** ** ** test_misc(): Main misc. test routine. @@ -5144,7 +5226,7 @@ test_misc(void) test_misc18(); /* Test new object header information in H5O_info_t struct */ test_misc19(); /* Test incrementing & decrementing ref count on IDs */ test_misc20(); /* Test problems with truncated dimensions in version 2 of storage layout message */ -#if defined H5_HAVE_FILTER_SZIP +#ifdef H5_HAVE_FILTER_SZIP test_misc21(); /* Test that "late" allocation time is treated the same as "incremental", for chunked datasets w/a filters */ test_misc22(); /* check szip bits per pixel */ #endif /* H5_HAVE_FILTER_SZIP */ @@ -5157,6 +5239,7 @@ test_misc(void) test_misc27(); /* Test opening file with object that has bad # of object header messages */ test_misc28(); /* Test that chunks are cached appropriately */ test_misc29(); /* Test that speculative metadata reads are handled correctly */ + test_misc30(); /* Exercise local heap loading bug where free lists were getting dropped */ } /* test_misc() */ @@ -5201,7 +5284,7 @@ cleanup_misc(void) HDremove(MISC18_FILE); HDremove(MISC19_FILE); HDremove(MISC20_FILE); -#if defined H5_HAVE_FILTER_SZIP +#ifdef H5_HAVE_FILTER_SZIP HDremove(MISC21_FILE); HDremove(MISC22_FILE); #endif /* H5_HAVE_FILTER_SZIP */ @@ -5212,5 +5295,6 @@ cleanup_misc(void) HDremove(MISC26_FILE); HDremove(MISC28_FILE); HDremove(MISC29_COPY_FILE); + HDremove(MISC30_FILE); } diff --git a/test/trefer.c b/test/trefer.c index 4ab3fba..53f7b92 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -75,6 +75,7 @@ test_reference_params(void) hid_t group; /* Group ID */ hid_t sid1; /* Dataspace ID */ hid_t tid1; /* Datatype ID */ + hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}; hobj_ref_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ @@ -101,6 +102,10 @@ test_reference_params(void) sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Create dataset access property list */ + dapl_id = H5Pcreate(H5P_DATASET_ACCESS); + CHECK(dapl_id, FAIL, "H5Pcreate"); + /* Create a group */ group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group, FAIL, "H5Gcreate2"); @@ -179,12 +184,14 @@ test_reference_params(void) VERIFY(ret, FAIL, "H5Rcreate space"); /* Test parameters to H5Rdereference */ - dset2 = H5Rdereference(-1, H5R_OBJECT, &rbuf[0]); - VERIFY(dset2, FAIL, "H5Rdereference loc_id"); - dset2 = H5Rdereference(dataset, H5R_OBJECT, NULL); - VERIFY(dset2, FAIL, "H5Rdereference ref"); - dset2 = H5Rdereference(dataset, H5R_MAXTYPE, &rbuf[0]); - VERIFY(dset2, FAIL, "H5Rdereference type"); + dset2 = H5Rdereference2(-1, H5P_DEFAULT, H5R_OBJECT, &rbuf[0]); + VERIFY(dset2, FAIL, "H5Rdereference2 loc_id"); + dset2 = H5Rdereference2(dataset, -1, H5R_OBJECT, &rbuf[0]); + VERIFY(dset2, FAIL, "H5Rdereference2 oapl_id"); + dset2 = H5Rdereference2(dataset, dapl_id, H5R_OBJECT, NULL); + VERIFY(dset2, FAIL, "H5Rdereference2 ref"); + dset2 = H5Rdereference2(dataset, dapl_id, H5R_MAXTYPE, &rbuf[0]); + VERIFY(dset2, FAIL, "H5Rdereference2 type"); /* Test parameters to H5Rget_obj_type2 */ ret = H5Rget_obj_type2(-1, H5R_OBJECT, &rbuf[0], NULL); @@ -214,6 +221,10 @@ test_reference_params(void) ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -237,23 +248,24 @@ test_reference_params(void) static void test_reference_obj(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset, /* Dataset ID */ - dset2; /* Dereferenced dataset ID */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset, /* Dataset ID */ + dset2; /* Dereferenced dataset ID */ hid_t group; /* Group ID */ hid_t sid1; /* Dataspace ID */ hid_t tid1; /* Datatype ID */ hsize_t dims1[] = {SPACE1_DIM1}; - hobj_ref_t *wbuf, /* buffer to write to disk */ - *rbuf, /* buffer read from disk */ - *tbuf; /* temp. buffer read from disk */ + hid_t dapl_id; /* Dataset access property list */ + hobj_ref_t *wbuf, /* buffer to write to disk */ + *rbuf, /* buffer read from disk */ + *tbuf; /* temp. buffer read from disk */ hobj_ref_t nvrbuf[3]={0,101,1000000000}; /* buffer with non-valid refs */ - unsigned *tu32; /* Temporary pointer to uint32 data */ - int i, j; /* counting variables */ + unsigned *tu32; /* Temporary pointer to uint32 data */ + int i, j; /* counting variables */ const char *write_comment="Foo!"; /* Comments for group */ char read_comment[10]; - H5O_type_t obj_type; /* Object type */ - herr_t ret; /* Generic return value */ + H5O_type_t obj_type; /* Object type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Functions\n")); @@ -271,6 +283,10 @@ test_reference_obj(void) sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Create dataset access property list */ + dapl_id = H5Pcreate(H5P_DATASET_ACCESS); + CHECK(dapl_id, FAIL, "H5Pcreate"); + /* Create a group */ group = H5Gcreate2(fid1, "Group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group, FAIL, "H5Gcreate2"); @@ -389,8 +405,8 @@ test_reference_obj(void) CHECK(ret, FAIL, "H5Dread"); /* Open dataset object */ - dset2 = H5Rdereference(dataset, H5R_OBJECT, &rbuf[0]); - CHECK(dset2, FAIL, "H5Rdereference"); + dset2 = H5Rdereference2(dataset, dapl_id, H5R_OBJECT, &rbuf[0]); + CHECK(dset2, FAIL, "H5Rdereference2"); /* Check information in referenced dataset */ sid1 = H5Dget_space(dset2); @@ -410,9 +426,9 @@ test_reference_obj(void) ret = H5Dclose(dset2); CHECK(ret, FAIL, "H5Dclose"); - /* Open group object */ - group = H5Rdereference(dataset, H5R_OBJECT, &rbuf[2]); - CHECK(group, FAIL, "H5Rdereference"); + /* Open group object. GAPL isn't supported yet. But it's harmless to pass in */ + group = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &rbuf[2]); + CHECK(group, FAIL, "H5Rdereference2"); /* Get group's comment */ ret = H5Oget_comment(group, read_comment, (size_t)10); @@ -426,9 +442,9 @@ test_reference_obj(void) ret = H5Gclose(group); CHECK(ret, FAIL, "H5Gclose"); - /* Open datatype object */ - tid1 = H5Rdereference(dataset, H5R_OBJECT, &rbuf[3]); - CHECK(tid1, FAIL, "H5Rdereference"); + /* Open datatype object. TAPL isn't supported yet. But it's harmless to pass in */ + tid1 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &rbuf[3]); + CHECK(tid1, FAIL, "H5Rdereference2"); /* Verify correct datatype */ { @@ -457,6 +473,10 @@ test_reference_obj(void) ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); @@ -481,6 +501,7 @@ test_reference_region(void) dset2; /* Dereferenced dataset ID */ hid_t sid1, /* Dataspace ID #1 */ sid2; /* Dataspace ID #2 */ + hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ @@ -518,6 +539,10 @@ test_reference_region(void) sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); CHECK(sid2, FAIL, "H5Screate_simple"); + /* Create dataset access property list */ + dapl_id = H5Pcreate(H5P_DATASET_ACCESS); + CHECK(dapl_id, FAIL, "H5Pcreate"); + /* Create a dataset */ dset2 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8LE, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset2, FAIL, "H5Dcreate2"); @@ -615,8 +640,8 @@ test_reference_region(void) CHECK(ret, FAIL, "H5Dread"); /* Try to open objects */ - dset2 = H5Rdereference(dset1, H5R_DATASET_REGION, &rbuf[0]); - CHECK(dset2, FAIL, "H5Rdereference"); + dset2 = H5Rdereference2(dset1, dapl_id, H5R_DATASET_REGION, &rbuf[0]); + CHECK(dset2, FAIL, "H5Rdereference2"); /* Check what H5Rget_obj_type2 function returns */ ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &rbuf[0], &obj_type); @@ -729,6 +754,10 @@ test_reference_region(void) ret = H5Dclose(dset1); CHECK(ret, FAIL, "H5Dclose"); + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); @@ -754,6 +783,7 @@ test_reference_region_1D(void) dset3; /* Dereferenced dataset ID */ hid_t sid1, /* Dataspace ID #1 */ sid3; /* Dataspace ID #3 */ + hid_t dapl_id; /* Dataset access property list */ hsize_t dims1[] = {SPACE1_DIM1}, dims3[] = {SPACE3_DIM1}; hsize_t start[SPACE3_RANK]; /* Starting location of hyperslab */ @@ -790,6 +820,10 @@ test_reference_region_1D(void) sid3 = H5Screate_simple(SPACE3_RANK, dims3, NULL); CHECK(sid3, FAIL, "H5Screate_simple"); + /* Create dataset access property list */ + dapl_id = H5Pcreate(H5P_DATASET_ACCESS); + CHECK(dapl_id, FAIL, "H5Pcreate"); + /* Create a dataset */ dset3 = H5Dcreate2(fid1, "Dataset2", H5T_STD_U8LE, sid3, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dset3, FAIL, "H5Dcreate2"); @@ -887,8 +921,8 @@ test_reference_region_1D(void) CHECK(ret, FAIL, "H5Dread"); /* Try to open objects */ - dset3 = H5Rdereference(dset1, H5R_DATASET_REGION, &rbuf[0]); - CHECK(dset3, FAIL, "H5Rdereference"); + dset3 = H5Rdereference2(dset1, dapl_id, H5R_DATASET_REGION, &rbuf[0]); + CHECK(dset3, FAIL, "H5Rdereference2"); /* Check what H5Rget_obj_type2 function returns */ ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &rbuf[0], &obj_type); @@ -1005,6 +1039,10 @@ test_reference_region_1D(void) ret = H5Dclose(dset1); CHECK(ret, FAIL, "H5Dclose"); + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); @@ -1094,13 +1132,13 @@ test_reference_obj_deleted(void) CHECK(ret, FAIL, "H5Dread"); /* Open deleted dataset object */ - dset2 = H5Rdereference(dataset, H5R_OBJECT, &oref); - VERIFY(dset2, FAIL, "H5Rdereference"); + dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &oref); + VERIFY(dset2, FAIL, "H5Rdereference2"); /* Open nonsense reference */ HDmemset(&oref, 0, sizeof(hobj_ref_t)); - dset2 = H5Rdereference(dataset, H5R_OBJECT, &oref); - VERIFY(dset2, FAIL, "H5Rdereference"); + dset2 = H5Rdereference2(dataset, H5P_DEFAULT, H5R_OBJECT, &oref); + VERIFY(dset2, FAIL, "H5Rdereference2"); /* Close Dataset */ ret = H5Dclose(dataset); @@ -1238,8 +1276,8 @@ test_reference_group(void) CHECK(ret, FAIL, "H5Dread"); /* Dereference to get the group */ - gid = H5Rdereference(did, H5R_OBJECT, &rref); - CHECK(gid, FAIL, "H5Rdereference"); + gid = H5Rdereference2(did, H5P_DEFAULT, H5R_OBJECT, &rref); + CHECK(gid, FAIL, "H5Rdereference2"); /* Iterate through objects in dereferenced group */ ret = H5Literate(gid, H5_INDEX_NAME, H5_ITER_INC, NULL, test_deref_iter_op, &count); @@ -1286,11 +1324,11 @@ static void test_reference_compat(void) { hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t group; /* Group ID */ + hid_t dataset, dset2; /* Dataset ID */ + hid_t group, group2; /* Group ID */ hid_t sid1, /* Dataspace IDs */ sid2; - hid_t tid1; /* Datatype ID */ + hid_t tid1, tid2; /* Datatype ID */ hsize_t dims1[] = {SPACE1_DIM1}, dims2[] = {SPACE2_DIM1, SPACE2_DIM2}; hsize_t start[SPACE2_RANK]; /* Starting location of hyperslab */ @@ -1485,6 +1523,32 @@ test_reference_compat(void) CHECK(obj_type, H5G_UNKNOWN, "H5Rget_obj_type1"); VERIFY(obj_type, H5G_TYPE, "H5Rget_obj_type1"); + + /* Make sure the referenced objects can be opened */ + dset2 = H5Rdereference1(dataset, H5R_OBJECT, &rbuf_obj[0]); + CHECK(dset2, FAIL, "H5Rdereference1"); + + ret = H5Dclose(dset2); + CHECK(ret, FAIL, "H5Dclose"); + + dset2 = H5Rdereference1(dataset, H5R_OBJECT, &rbuf_obj[1]); + CHECK(dset2, FAIL, "H5Rdereference1"); + + ret = H5Dclose(dset2); + CHECK(ret, FAIL, "H5Dclose"); + + group2 = H5Rdereference1(dataset, H5R_OBJECT, &rbuf_obj[2]); + CHECK(group2, FAIL, "H5Rdereference1"); + + ret = H5Gclose(group2); + CHECK(ret, FAIL, "H5Gclose"); + + tid2 = H5Rdereference1(dataset, H5R_OBJECT, &rbuf_obj[3]); + CHECK(tid2, FAIL, "H5Rdereference1"); + + ret = H5Tclose(tid2); + CHECK(ret, FAIL, "H5Tclose"); + /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); @@ -1513,11 +1577,23 @@ test_reference_compat(void) obj_type = H5Rget_obj_type1(dataset, H5R_DATASET_REGION, &rbuf_reg[3]); VERIFY(obj_type, H5G_UNKNOWN, "H5Rget_obj_type1"); + /* Make sure the referenced objects can be opened */ + dset2 = H5Rdereference1(dataset, H5R_DATASET_REGION, &rbuf_reg[0]); + CHECK(dset2, FAIL, "H5Rdereference1"); + + ret = H5Dclose(dset2); + CHECK(ret, FAIL, "H5Dclose"); + + dset2 = H5Rdereference1(dataset, H5R_DATASET_REGION, &rbuf_reg[1]); + CHECK(dset2, FAIL, "H5Rdereference1"); + + ret = H5Dclose(dset2); + CHECK(ret, FAIL, "H5Dclose"); + /* Close Dataset */ ret = H5Dclose(dataset); CHECK(ret, FAIL, "H5Dclose"); - /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); diff --git a/test/tskiplist.c b/test/tskiplist.c index 8510db2..8966e39 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -121,7 +121,7 @@ test_skiplist_create(void) MESSAGE(6, ("Testing Creating & Closing Skip Lists\n")); /* Try creating a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Try closing the skip list */ @@ -151,7 +151,7 @@ test_skiplist_insert(void) MESSAGE(7, ("Testing Insertion Into Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -160,7 +160,7 @@ test_skiplist_insert(void) /* Try searching for item in empty skip list */ key=37; - found_item=H5SL_search(slist,&key); + found_item=(int *)H5SL_search(slist,&key); VERIFY(found_item, NULL, "H5SL_search"); /* Insert an object into the skip list */ @@ -173,13 +173,13 @@ test_skiplist_insert(void) VERIFY(num, 1, "H5SL_count"); /* Search for the item just inserted */ - found_item=H5SL_search(slist,&key); + found_item=(int *)H5SL_search(slist,&key); CHECK(found_item, NULL, "H5SL_search"); VERIFY(*found_item,item,"H5SL_search"); /* Search for an item not in list */ search_key=37; - found_item=H5SL_search(slist,&search_key); + found_item=(int *)H5SL_search(slist,&search_key); VERIFY(found_item, NULL, "H5SL_search"); /* Attempt to insert duplicate key (should fail) */ @@ -212,7 +212,7 @@ test_skiplist_insert_many(void) MESSAGE(7, ("Testing Insertion of Many Items Into Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -231,7 +231,7 @@ test_skiplist_insert_many(void) /* Search for all objects in the skip list */ for(u=0; u<NUM_ELEMS; u++) { - found_item=H5SL_search(slist,&rand_num[u]); + found_item=(int *)H5SL_search(slist,&rand_num[u]); CHECK(found_item, NULL, "H5SL_search"); VERIFY(*found_item,rand_num[u],"H5SL_search"); } /* end for */ @@ -286,7 +286,7 @@ test_skiplist_remove(void) MESSAGE(7, ("Testing Removal From Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -295,7 +295,7 @@ test_skiplist_remove(void) /* Try removing an item in empty skip list */ search_key=37; - found_item=H5SL_remove(slist,&search_key); + found_item=(int *)H5SL_remove(slist,&search_key); VERIFY(found_item, NULL, "H5SL_remove"); /* Insert three objects into the skip list */ @@ -317,17 +317,17 @@ test_skiplist_remove(void) /* Try removing items from skip list */ search_key=key1; - found_item=H5SL_remove(slist,&search_key); + found_item=(int *)H5SL_remove(slist,&search_key); CHECK(found_item, NULL, "H5SL_remove"); VERIFY(found_item, &key1, "H5SL_remove"); search_key=key2; - found_item=H5SL_remove(slist,&search_key); + found_item=(int *)H5SL_remove(slist,&search_key); CHECK(found_item, NULL, "H5SL_remove"); VERIFY(found_item, &key2, "H5SL_remove"); search_key=key3; - found_item=H5SL_remove(slist,&search_key); + found_item=(int *)H5SL_remove(slist,&search_key); CHECK(found_item, NULL, "H5SL_remove"); VERIFY(found_item, &key3, "H5SL_remove"); @@ -337,7 +337,7 @@ test_skiplist_remove(void) /* Try removing items from empty skip list (after its been worked on) */ search_key=key1; - found_item=H5SL_remove(slist,&search_key); + found_item=(int *)H5SL_remove(slist,&search_key); VERIFY(found_item, NULL, "H5SL_remove"); /* Close the skip list */ @@ -365,7 +365,7 @@ test_skiplist_remove_many(void) MESSAGE(7, ("Testing Removal of Many Items From Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -384,7 +384,7 @@ test_skiplist_remove_many(void) /* Remove all objects from the skip list (in random order) */ for(u=0; u<NUM_ELEMS; u++) { - found_item=H5SL_remove(slist,&rand_num[u]); + found_item=(int *)H5SL_remove(slist,&rand_num[u]); CHECK(found_item, NULL, "H5SL_remove"); VERIFY(*found_item,rand_num[u],"H5SL_remove"); } /* end for */ @@ -407,7 +407,7 @@ test_skiplist_remove_many(void) /* Remove all objects from the skip list */ for(u=0; u<NUM_ELEMS; u++) { - found_item=H5SL_remove(slist,&sort_rand_num[u]); + found_item=(int *)H5SL_remove(slist,&sort_rand_num[u]); CHECK(found_item, NULL, "H5SL_remove"); VERIFY(*found_item,sort_rand_num[u],"H5SL_remove"); } /* end for */ @@ -430,7 +430,7 @@ test_skiplist_remove_many(void) /* Remove all objects from the skip list */ for(u=0; u<NUM_ELEMS; u++) { - found_item=H5SL_remove(slist,&rev_sort_rand_num[u]); + found_item=(int *)H5SL_remove(slist,&rev_sort_rand_num[u]); CHECK(found_item, NULL, "H5SL_remove"); VERIFY(*found_item,rev_sort_rand_num[u],"H5SL_remove"); } /* end for */ @@ -465,13 +465,13 @@ test_skiplist_firstnext(void) MESSAGE(7, ("Testing Iterating Over Skip List With First/Next\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ num=H5SL_count(slist); - VERIFY(num, 0, "H5SL_count"); + VERIFY(num, 0, "H5SL_count"); /* Check that the list appears empty */ node=H5SL_first(slist); VERIFY(node, NULL, "H5SL_first"); @@ -491,7 +491,7 @@ test_skiplist_firstnext(void) CHECK(node, NULL, "H5SL_first"); u=0; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(int *)H5SL_item(node); VERIFY(*found_item,sort_rand_num[u],"H5SL_next"); u++; node=H5SL_next(node); @@ -558,7 +558,7 @@ test_skiplist_string(void) MESSAGE(7, ("Testing Skip List With String Keys\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_STR); + slist = H5SL_create(H5SL_TYPE_STR, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -579,7 +579,7 @@ test_skiplist_string(void) node=H5SL_first(slist); u=0; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(string_node *)H5SL_item(node); VERIFY(found_item->i, hashed_data[u].i, "H5SL_next"); u++; node=H5SL_next(node); @@ -620,7 +620,7 @@ test_skiplist_iterate(void) MESSAGE(7, ("Testing Iterating Over Skip List\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -670,7 +670,7 @@ test_skiplist_hsize(void) MESSAGE(7, ("Testing Skip List With hsize_t Keys\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_HSIZE); + slist = H5SL_create(H5SL_TYPE_HSIZE, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -691,7 +691,7 @@ test_skiplist_hsize(void) node=H5SL_first(slist); u=0; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(hsize_t *)H5SL_item(node); VERIFY(*found_item,sorted_data[u],"H5SL_next"); u++; node=H5SL_next(node); @@ -725,7 +725,7 @@ test_skiplist_unsigned(void) MESSAGE(7, ("Testing Skip List With unsigned Keys\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -746,7 +746,7 @@ test_skiplist_unsigned(void) node=H5SL_first(slist); u=0; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(unsigned *)H5SL_item(node); VERIFY(*found_item,sorted_data[u],"H5SL_next"); u++; node=H5SL_next(node); @@ -760,6 +760,140 @@ test_skiplist_unsigned(void) /**************************************************************** ** +** test_skiplist_obj(): Test H5SL (skip list) code. +** Tests using H5_obj_t's for keys in skip lists. +** +****************************************************************/ +static void +test_skiplist_obj(void) +{ + H5SL_t *slist; /* Skip list created */ + H5SL_node_t *node; /* Skip list node */ + size_t num; /* Number of elements in skip list */ + size_t u; /* Local index variable */ + H5_obj_t data[10]={ {10, 12}, {20, 12}, {10, 32}, {10, 11}, {50, 1}, {8, 12}, {31, 12}, {20, 11}, {31, 11}, {8, 32} }; + H5_obj_t sorted_data[10]={ {8, 12}, {8, 32}, {10, 11}, {10, 12}, {10, 32}, {20, 11}, {20, 12}, {31, 11}, {31, 12}, {50, 1} }; + H5_obj_t *found_item; /* Item found in skip list */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(7, ("Testing Skip List With H5_obj_t Keys\n")); + + /* Create a skip list */ + slist = H5SL_create(H5SL_TYPE_OBJ, NULL); + CHECK(slist, NULL, "H5SL_create"); + + /* Check that the skip list has no elements */ + num=H5SL_count(slist); + VERIFY(num, 0, "H5SL_count"); + + /* Insert objects into the skip list */ + for(u=0; u<10; u++) { + ret=H5SL_insert(slist,&data[u],&data[u]); + CHECK(ret, FAIL, "H5SL_insert"); + } /* end for */ + + /* Check that the skip list has correct # of elements */ + num=H5SL_count(slist); + VERIFY(num, 10, "H5SL_count"); + + /* Iterate over all the nodes in the skip list */ + node=H5SL_first(slist); + u=0; + while(node!=NULL) { + found_item=(H5_obj_t *)H5SL_item(node); + VERIFY(found_item->fileno,sorted_data[u].fileno,"H5SL_next"); + VERIFY(found_item->addr,sorted_data[u].addr,"H5SL_next"); + u++; + node=H5SL_next(node); + } /* end while */ + + /* Close the skip list */ + ret=H5SL_close(slist); + CHECK(ret, FAIL, "H5SL_close"); + +} /* end test_skiplist_obj() */ + +/**************************************************************** +** +** test_skiplist_generic(): Test H5SL (skip list) code. +** Tests using generic keys in skip lists. Define +** structure for keys, and define comparison using +** key.a-key.b. +** +****************************************************************/ +typedef struct generic_t { + unsigned a; + unsigned b; +} generic_t; + +static int +test_skiplist_generic_cmp(const void *_key1, const void *_key2) +{ + const generic_t *key1 = (const generic_t *)_key1; + const generic_t *key2 = (const generic_t *)_key2; + long long result = (long long)(key1->a) - (long long)(key1->b) - (long long)(key2->a) + (long long)(key2->b); + + if(result < 0) + return -1; + else if(result > 0) + return 1; + else + return 0; +} /* end test_skiplist_generic_cmp */ + +static void +test_skiplist_generic(void) +{ + H5SL_t *slist; /* Skip list created */ + H5SL_node_t *node; /* Skip list node */ + size_t num; /* Number of elements in skip list */ + size_t u; /* Local index variable */ + generic_t data[10]={ {10, 1}, {20, 13}, {15, 32}, {5, 2}, {50, 37}, {30, 100}, {31, 38}, {32, 34}, {80, 32}, {90, 0} }; + generic_t sorted_data[10]={ {30, 100}, {15, 32}, {31, 38}, {32, 34}, {5, 2}, {20, 13}, {10, 1}, {50, 37}, {80, 32}, {90, 0} }; + generic_t *found_item; /* Item found in skip list */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(7, ("Testing Skip List With generic Keys\n")); + + /* Create a skip list */ + slist = H5SL_create(H5SL_TYPE_GENERIC, test_skiplist_generic_cmp); + CHECK(slist, NULL, "H5SL_create"); + + /* Check that the skip list has no elements */ + num=H5SL_count(slist); + VERIFY(num, 0, "H5SL_count"); + + /* Insert objects into the skip list */ + for(u=0; u<10; u++) { + ret=H5SL_insert(slist,&data[u],&data[u]); + CHECK(ret, FAIL, "H5SL_insert"); + } /* end for */ + + /* Check that the skip list has correct # of elements */ + num=H5SL_count(slist); + VERIFY(num, 10, "H5SL_count"); + + /* Iterate over all the nodes in the skip list */ + node=H5SL_first(slist); + u=0; + while(node!=NULL) { + found_item=(generic_t *)H5SL_item(node); + VERIFY(found_item->a,sorted_data[u].a,"H5SL_next"); + VERIFY(found_item->b,sorted_data[u].b,"H5SL_next"); + u++; + node=H5SL_next(node); + } /* end while */ + + /* Close the skip list */ + ret=H5SL_close(slist); + CHECK(ret, FAIL, "H5SL_close"); + +} /* end test_skiplist_generic() */ + +/**************************************************************** +** ** test_skiplist_lastprev(): Test H5SL (skip list) code. ** Tests iterating over nodes in skip list with last/prev calls. ** @@ -778,7 +912,7 @@ test_skiplist_lastprev(void) MESSAGE(7, ("Testing Iterating Over Skip List With Last/Prev\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Check that the skip list has no elements */ @@ -804,7 +938,7 @@ test_skiplist_lastprev(void) CHECK(node, NULL, "H5SL_last"); u=NUM_ELEMS-1; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(int *)H5SL_item(node); VERIFY(*found_item,sort_rand_num[u],"H5SL_prev"); u--; node=H5SL_prev(node); @@ -846,7 +980,7 @@ test_skiplist_find(void) MESSAGE(7, ("Testing Skip List 'Find' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -863,7 +997,7 @@ test_skiplist_find(void) /* Iterate over the rest of the nodes in the skip list */ u=4; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(unsigned *)H5SL_item(node); VERIFY(*found_item,sorted_data[u],"H5SL_next"); u++; node=H5SL_next(node); @@ -902,7 +1036,7 @@ test_skiplist_add(void) MESSAGE(7, ("Testing Skip List 'Add' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -923,7 +1057,7 @@ test_skiplist_add(void) /* Iterate over the rest of the nodes in the skip list */ u=2; while(node!=NULL) { - found_item=H5SL_item(node); + found_item=(unsigned *)H5SL_item(node); VERIFY(*found_item,sorted_data[u],"H5SL_item"); u++; node=H5SL_next(node); @@ -964,7 +1098,7 @@ test_skiplist_destroy(void) MESSAGE(7, ("Testing Skip List 'Destroy' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1000,7 +1134,7 @@ test_skiplist_free(void) MESSAGE(7, ("Testing Skip List 'Free' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1056,7 +1190,7 @@ test_skiplist_less(void) MESSAGE(7, ("Testing Skip List 'Less' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1067,30 +1201,30 @@ test_skiplist_less(void) /* Check for exact match of items in various positions */ find_item=20; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,find_item,"H5SL_less"); find_item=90; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,find_item,"H5SL_less"); find_item=5; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,find_item,"H5SL_less"); /* Find item less than a missing key, in various positions */ find_item=19; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,15,"H5SL_less"); find_item=89; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,80,"H5SL_less"); find_item=100; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,90,"H5SL_less"); find_item=9; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(*found_item,5,"H5SL_less"); find_item=4; - found_item=H5SL_less(slist,&find_item); + found_item=(unsigned *)H5SL_less(slist,&find_item); VERIFY(found_item,NULL,"H5SL_less"); /* Close the skip list */ @@ -1120,7 +1254,7 @@ test_skiplist_greater(void) MESSAGE(7, ("Testing Skip List 'Greater' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1131,30 +1265,30 @@ test_skiplist_greater(void) /* Check for exact match of items in various positions */ find_item = 20; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, find_item, "H5SL_greater"); find_item = 90; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, find_item, "H5SL_greater"); find_item = 5; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, find_item, "H5SL_greater"); /* Find item greater than a missing key, in various positions */ find_item = 19; - found_item = H5SL_greater(slist,&find_item); + found_item = (unsigned *)H5SL_greater(slist,&find_item); VERIFY(*found_item, 20, "H5SL_greater"); find_item = 89; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 90, "H5SL_greater"); find_item = 100; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(found_item, NULL, "H5SL_greater"); find_item = 6; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 10, "H5SL_greater"); find_item = 4; - found_item = H5SL_greater(slist, &find_item); + found_item = (unsigned *)H5SL_greater(slist, &find_item); VERIFY(*found_item, 5, "H5SL_greater"); /* Close the skip list */ @@ -1185,7 +1319,7 @@ test_skiplist_below(void) MESSAGE(7, ("Testing Skip List 'Below' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1198,42 +1332,42 @@ test_skiplist_below(void) find_item = 20; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); find_item = 90; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); find_item = 5; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_below"); /* Find item less than a missing key, in various positions */ find_item = 19; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 15, "H5SL_below"); find_item = 89; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 80, "H5SL_below"); find_item = 100; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 90, "H5SL_below"); find_item = 9; node = H5SL_below(slist, &find_item); CHECK(node, NULL, "H5SL_below"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 5, "H5SL_below"); find_item = 4; - node = H5SL_less(slist, &find_item); + node = (H5SL_node_t *)H5SL_less(slist, &find_item); VERIFY(node, NULL, "H5SL_below"); /* Close the skip list */ @@ -1264,7 +1398,7 @@ test_skiplist_above(void) MESSAGE(7, ("Testing Skip List 'Above' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1277,29 +1411,29 @@ test_skiplist_above(void) find_item = 20; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); find_item = 90; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); find_item = 5; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, find_item, "H5SL_above"); /* Find item greater than a missing key, in various positions */ find_item = 19; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 20, "H5SL_above"); find_item = 89; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 90, "H5SL_above"); find_item = 100; node = H5SL_above(slist, &find_item); @@ -1307,12 +1441,12 @@ test_skiplist_above(void) find_item = 6; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 10, "H5SL_above"); find_item = 4; node = H5SL_above(slist, &find_item); CHECK(node, NULL, "H5SL_above"); - found_item = H5SL_item(node); + found_item = (unsigned *)H5SL_item(node); VERIFY(*found_item, 5, "H5SL_above"); /* Close the skip list */ @@ -1341,7 +1475,7 @@ test_skiplist_remove_first(void) MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_UNSIGNED); + slist = H5SL_create(H5SL_TYPE_UNSIGNED, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1352,12 +1486,12 @@ test_skiplist_remove_first(void) /* Remove objects from the skip list */ for(u = 0; u < 10; u++) { - found_item = H5SL_remove_first(slist); + found_item = (unsigned *)H5SL_remove_first(slist); VERIFY(*found_item, sorted_data[u], "H5SL_remove_first"); } /* end for */ /* Check for removing object from empty list */ - found_item = H5SL_remove_first(slist); + found_item = (unsigned *)H5SL_remove_first(slist); VERIFY(found_item, NULL, "H5SL_remove_first"); /* Close the skip list */ @@ -1385,7 +1519,7 @@ test_skiplist_remove_first_many(void) MESSAGE(7, ("Testing Skip List 'Remove First' Operation\n")); /* Create a skip list */ - slist = H5SL_create(H5SL_TYPE_INT); + slist = H5SL_create(H5SL_TYPE_INT, NULL); CHECK(slist, NULL, "H5SL_create"); /* Insert objects into the skip list */ @@ -1436,6 +1570,8 @@ test_skiplist(void) test_skiplist_iterate(); /* Test iteration over skip list nodes with callback */ test_skiplist_hsize(); /* Test skip list hsize_t keys */ test_skiplist_unsigned(); /* Test skip list unsigned keys */ + test_skiplist_obj(); /* Test skip list H5_obj_t keys */ + test_skiplist_generic(); /* Test skip list generic keys */ test_skiplist_lastprev(); /* Test iteration over skip list nodes with last/prev */ test_skiplist_find(); /* Test 'find' operation */ test_skiplist_add(); /* Test 'add' operation */ diff --git a/test/tunicode.c b/test/tunicode.c index 892e563..3b949e9 100644 --- a/test/tunicode.c +++ b/test/tunicode.c @@ -464,8 +464,8 @@ void test_objnames(hid_t fid, const char* string) CHECK(ret, FAIL, "H5Dread"); /* Ensure that we can open named datatype using object reference */ - type_id = H5Rdereference(dset_id, H5R_OBJECT, &obj_ref); - CHECK(type_id, FAIL, "H5Rdereference"); + type_id = H5Rdereference2(dset_id, H5P_DEFAULT, H5R_OBJECT, &obj_ref); + CHECK(type_id, FAIL, "H5Rdereference2"); ret = H5Tcommitted(type_id); VERIFY(ret, 1, "H5Tcommitted"); diff --git a/test/unlink.c b/test/unlink.c index 604b014..993a7ec 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -2221,9 +2221,9 @@ test_full_group_compact(hid_t fapl) } /* end for */ /* Check on group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) != TRUE) TEST_ERROR - if(H5G_has_stab_test(gid) == TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) != TRUE) TEST_ERROR + if(H5G__has_stab_test(gid) == TRUE) TEST_ERROR /* Close group with objects to delete */ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR @@ -2367,9 +2367,9 @@ test_full_group_dense(hid_t fapl) } /* end for */ /* Check on group's status */ - if(H5G_is_empty_test(gid) == TRUE) TEST_ERROR - if(H5G_has_links_test(gid, NULL) == TRUE) TEST_ERROR - if(H5G_is_new_dense_test(gid) != TRUE) TEST_ERROR + if(H5G__is_empty_test(gid) == TRUE) TEST_ERROR + if(H5G__has_links_test(gid, NULL) == TRUE) TEST_ERROR + if(H5G__is_new_dense_test(gid) != TRUE) TEST_ERROR /* Close group with objects to delete */ if(H5Gclose(gid) < 0) FAIL_STACK_ERROR @@ -50,13 +50,14 @@ const char *FILENAME[] = { "log_file", /*6*/ "stdio_file", /*7*/ "windows_file", /*8*/ + "new_multi_file_v16",/*9*/ NULL }; #define LOG_FILENAME "log_vfd_out.log" #define COMPAT_BASENAME "family_v16_" - +#define MULTI_COMPAT_BASENAME "multi_file_v16" /*------------------------------------------------------------------------- @@ -75,9 +76,9 @@ const char *FILENAME[] = { static herr_t test_sec2(void) { - hid_t file = -1; - hid_t fapl = -1; - hid_t access_fapl = -1; + hid_t file = -1; + hid_t fapl = -1; + hid_t access_fapl = -1; char filename[1024]; int *fhandle = NULL; hsize_t file_size = 0; @@ -156,18 +157,18 @@ test_direct(void) { #ifdef H5_HAVE_DIRECT hid_t file=(-1), fapl, access_fapl = -1; - hid_t dset1=-1, dset2=-1, space1=-1, space2=-1; + hid_t dset1=-1, dset2=-1, space1=-1, space2=-1; char filename[1024]; int *fhandle=NULL; hsize_t file_size; - hsize_t dims1[2], dims2[1]; - size_t mbound; - size_t fbsize; - size_t cbsize; - int *points, *check, *p1, *p2; - int wdata2[DSET2_DIM] = {11,12,13,14}; - int rdata2[DSET2_DIM]; - int i, j, n; + hsize_t dims1[2], dims2[1]; + size_t mbound; + size_t fbsize; + size_t cbsize; + int *points, *check, *p1, *p2; + int wdata2[DSET2_DIM] = {11,12,13,14}; + int rdata2[DSET2_DIM]; + int i, j, n; #endif /*H5_HAVE_DIRECT*/ TESTING("DIRECT I/O file driver"); @@ -188,10 +189,10 @@ test_direct(void) if(H5Pget_fapl_direct(fapl, &mbound, &fbsize, &cbsize) < 0) TEST_ERROR; if(mbound != MBOUNDARY || fbsize != FBSIZE || cbsize != CBSIZE) - TEST_ERROR; + TEST_ERROR; if(H5Pset_alignment(fapl, (hsize_t)THRESHOLD, (hsize_t)FBSIZE) < 0) - TEST_ERROR; + TEST_ERROR; H5E_BEGIN_TRY { file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); @@ -199,7 +200,7 @@ test_direct(void) if(file<0) { H5Pclose (fapl); SKIPPED(); - printf(" Probably the file system doesn't support Direct I/O\n"); + printf(" Probably the file system doesn't support Direct I/O\n"); return 0; } @@ -243,8 +244,8 @@ test_direct(void) /* Initialize the dset1 */ p1 = points; for(i = n = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - *p1++ = n++; + for(j = 0; j < DSET1_DIM2; j++) + *p1++ = n++; /* Create the data space1 */ dims1[0] = DSET1_DIM1; @@ -274,13 +275,13 @@ test_direct(void) p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { - H5_FAILED(); - printf(" Read different values than written in data set 1.\n"); - printf(" At index %d,%d\n", i, j); - TEST_ERROR; - } /* end if */ + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ /* Create the data space2. For data set 2, memory address and data size are not aligned. */ dims2[0] = DSET2_DIM; @@ -307,12 +308,12 @@ test_direct(void) /* Check that the values read are the same as the values written */ for(i = 0; i < DSET2_DIM; i++) - if(wdata2[i] != rdata2[i]) { - H5_FAILED(); - printf(" Read different values than written in data set 2.\n"); - printf(" At index %d\n", i); + if(wdata2[i] != rdata2[i]) { + H5_FAILED(); + printf(" Read different values than written in data set 2.\n"); + printf(" At index %d\n", i); TEST_ERROR; - } /* end if */ + } /* end if */ if(H5Sclose(space1) < 0) TEST_ERROR; @@ -325,9 +326,9 @@ test_direct(void) if(H5Fclose(file) < 0) TEST_ERROR; if(points) - free(points); + free(points); if(check) - free(check); + free(check); h5_cleanup(FILENAME, fapl); PASSED(); @@ -367,10 +368,10 @@ test_core(void) char filename[1024]; void *fhandle=NULL; hsize_t file_size; - int *points, *check, *p1, *p2; - hid_t dset1=-1, space1=-1; - hsize_t dims1[2]; - int i, j, n; + int *points, *check, *p1, *p2; + hid_t dset1=-1, space1=-1; + hsize_t dims1[2]; + int i, j, n; TESTING("CORE file driver"); @@ -432,8 +433,8 @@ test_core(void) /* Initialize the dset1 */ p1 = points; for(i = n = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - *p1++ = n++; + for(j = 0; j < DSET1_DIM2; j++) + *p1++ = n++; /* Create the data space1 */ dims1[0] = DSET1_DIM1; @@ -463,13 +464,13 @@ test_core(void) p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { - H5_FAILED(); - printf(" Read different values than written in data set 1.\n"); - printf(" At index %d,%d\n", i, j); - TEST_ERROR; - } /* end if */ + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ if(H5Dclose(dset1) < 0) TEST_ERROR; @@ -501,7 +502,7 @@ test_core(void) /* Reallocate memory for reading buffer. */ if(check) - free(check); + free(check); check = (int*)malloc(DSET1_DIM1 * DSET1_DIM2 * sizeof(int)); @@ -513,13 +514,13 @@ test_core(void) p1 = points; p2 = check; for(i = 0; i < DSET1_DIM1; i++) - for(j = 0; j < DSET1_DIM2; j++) - if(*p1++ != *p2++) { - H5_FAILED(); - printf(" Read different values than written in data set 1.\n"); - printf(" At index %d,%d\n", i, j); - TEST_ERROR; - } /* end if */ + for(j = 0; j < DSET1_DIM2; j++) + if(*p1++ != *p2++) { + H5_FAILED(); + printf(" Read different values than written in data set 1.\n"); + printf(" At index %d,%d\n", i, j); + TEST_ERROR; + } /* end if */ /* Check file size API */ if(H5Fget_filesize(file, &file_size) < 0) @@ -537,9 +538,9 @@ test_core(void) if(H5Fclose(file) < 0) TEST_ERROR; if(points) - free(points); + free(points); if(check) - free(check); + free(check); h5_cleanup(FILENAME, fapl); @@ -1123,6 +1124,176 @@ error: /*------------------------------------------------------------------------- + * Function: test_multi_compat + * + * Purpose: Tests the backward compatibility for MULTI driver. + * See if we can open files created with v1.6 library. + * The source file was created by the test/file_handle.c + * of the v1.6 library. This test verifies the fix for + * Issue 2598. In v1.6 library, there was EOA for the whole + * MULTI file saved in the super block. We took it out in + * v1.8 library because it's meaningless for the MULTI file. + * v1.8 library saves the EOA for the metadata file, instead. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Raymond Lu + * 21 June 2011 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_multi_compat(void) +{ + hid_t file=(-1), fapl, fapl2=(-1), dset=(-1), space=(-1); + hid_t access_fapl = -1; + char filename[1024], newname[1024], tmp[1024]; + char filename_s[1024], newname_s[1024]; + char filename_r[1024], newname_r[1024]; + int *fhandle2=NULL, *fhandle=NULL; + hsize_t file_size; + H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; + hid_t memb_fapl[H5FD_MEM_NTYPES]; + haddr_t memb_addr[H5FD_MEM_NTYPES]; + const char *memb_name[H5FD_MEM_NTYPES]; + char sv[H5FD_MEM_NTYPES][32]; + hsize_t dims[2]={MULTI_SIZE, MULTI_SIZE}; + char dname[]="dataset2"; + int i, j; + int buf[MULTI_SIZE][MULTI_SIZE]; + + TESTING("MULTI file driver backward compatibility"); + + /* Set file access property list for MULTI driver */ + fapl = h5_fileaccess(); + + HDmemset(memb_map, 0, sizeof memb_map); + HDmemset(memb_fapl, 0, sizeof memb_fapl); + HDmemset(memb_name, 0, sizeof memb_name); + HDmemset(memb_addr, 0, sizeof memb_addr); + HDmemset(sv, 0, sizeof sv); + + for(mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) + memb_map[mt] = H5FD_MEM_SUPER; + memb_map[H5FD_MEM_DRAW] = H5FD_MEM_DRAW; + + memb_fapl[H5FD_MEM_SUPER] = H5P_DEFAULT; + sprintf(sv[H5FD_MEM_SUPER], "%%s-%c.h5", 's'); + memb_name[H5FD_MEM_SUPER] = sv[H5FD_MEM_SUPER]; + memb_addr[H5FD_MEM_SUPER] = 0; + + memb_fapl[H5FD_MEM_DRAW] = H5P_DEFAULT; + sprintf(sv[H5FD_MEM_DRAW], "%%s-%c.h5", 'r'); + memb_name[H5FD_MEM_DRAW] = sv[H5FD_MEM_DRAW]; + memb_addr[H5FD_MEM_DRAW] = HADDR_MAX/2; + + if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, TRUE)<0) + TEST_ERROR; + + h5_fixname(FILENAME[9], fapl, newname, sizeof newname); + + /* Make copy for the data file in the build directory, to protect the + * original file in the source directory */ + sprintf(filename_s, "%s-%c.h5", MULTI_COMPAT_BASENAME, 's'); + sprintf(newname_s, "%s-%c.h5", FILENAME[9], 's'); + h5_make_local_copy(filename_s, newname_s); + + sprintf(filename_r, "%s-%c.h5", MULTI_COMPAT_BASENAME, 'r'); + sprintf(newname_r, "%s-%c.h5", FILENAME[9], 'r'); + h5_make_local_copy(filename_r, newname_r); + + /* Reopen the file for read only. Verify 1.8 library can open file + * created with 1.6 library. */ + if((file=H5Fopen(newname, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR; + + if((dset = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) + TEST_ERROR; + + if(H5Fclose(file) < 0) + TEST_ERROR; + + /* Make sure we can reopen the file for read and write */ + if((file=H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR; + + if((dset = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) + TEST_ERROR; + + if(H5Fclose(file) < 0) + TEST_ERROR; + + /* Reopen the file for adding another dataset. The new EOA for metadata file + * should be written to the file */ + if((file=H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR; + + /* Create and write data set */ + if((space=H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; + + if((dset=H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR; + + for(i=0; i<MULTI_SIZE; i++) + for(j=0; j<MULTI_SIZE; j++) + buf[i][j] = i*10000+j; + if(H5Dwrite(dset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) + TEST_ERROR; + + if(H5Sclose(space) < 0) + TEST_ERROR; + + if(H5Fclose(file) < 0) + TEST_ERROR; + + /* Reopen the file for read only again. Verify the library can handle + * the EOA correctly */ + if((file=H5Fopen(newname, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR; + + if((dset = H5Dopen2(file, DSET1_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) + TEST_ERROR; + + if((dset = H5Dopen2(file, DSET2_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if(H5Dclose(dset) < 0) + TEST_ERROR; + + if(H5Fclose(file) < 0) + TEST_ERROR; + + h5_cleanup(FILENAME, fapl); + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY { + H5Sclose(space); + H5Dclose(dset); + H5Pclose(fapl); + H5Fclose(file); + } H5E_END_TRY; + return -1; +} + + +/*------------------------------------------------------------------------- * Function: test_log * * Purpose: Tests the file handle interface for log driver @@ -1226,7 +1397,6 @@ test_stdio(void) FILE *fhandle = NULL; hsize_t file_size = 0; - TESTING("STDIO file driver"); /* Set property list and file name for STDIO driver. */ @@ -1299,7 +1469,7 @@ error: static herr_t test_windows(void) { -#ifdef _WIN32 +#ifdef H5_HAVE_WINDOWS hid_t file = -1; hid_t fapl = -1; @@ -1308,16 +1478,16 @@ test_windows(void) int *fhandle = NULL; hsize_t file_size = 0; -#endif /*_WIN32*/ +#endif /*H5_HAVE_WINDOWS*/ TESTING("WINDOWS file driver"); -#ifndef _WIN32 +#ifndef H5_HAVE_WINDOWS SKIPPED(); return 0; -#else /*_WIN32*/ +#else /* H5_HAVE_WINDOWS */ /* Set property list and file name for WINDOWS driver. */ fapl = h5_fileaccess(); @@ -1370,7 +1540,7 @@ error: } H5E_END_TRY; return -1; -#endif /*_WIN32*/ +#endif /* H5_HAVE_WINDOWS */ } @@ -1402,15 +1572,16 @@ main(void) nerrors += test_family() < 0 ? 1 : 0; nerrors += test_family_compat() < 0 ? 1 : 0; nerrors += test_multi() < 0 ? 1 : 0; + nerrors += test_multi_compat() < 0 ? 1 : 0; nerrors += test_direct() < 0 ? 1 : 0; nerrors += test_log() < 0 ? 1 : 0; nerrors += test_stdio() < 0 ? 1 : 0; nerrors += test_windows() < 0 ? 1 : 0; if(nerrors) { - printf("***** %d Virtual File Driver TEST%s FAILED! *****\n", - nerrors, nerrors > 1 ? "S" : ""); - return 1; + printf("***** %d Virtual File Driver TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + return 1; } printf("All Virtual File Driver tests passed.\n"); diff --git a/test/vms_data.h5 b/test/vms_data.h5 Binary files differdeleted file mode 100644 index 14aeef2..0000000 --- a/test/vms_data.h5 +++ /dev/null |