diff options
author | Quincey Koziol <koziol@koziol.gov> | 2019-04-29 22:51:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@koziol.gov> | 2019-04-29 22:51:55 (GMT) |
commit | 08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e (patch) | |
tree | 22cf73b009673a79dcb0bf892e804cc38493e0dd /test | |
parent | 92f30fd3d99b5e278de7353b87d73e29e4ecf4b2 (diff) | |
parent | 3d904f8141f246f3bca6e58222a6569b7b0e005f (diff) | |
download | hdf5-08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e.zip hdf5-08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e.tar.gz hdf5-08b009cc4ab2a8d8d289697d6d4688c0e5c53c6e.tar.bz2 |
Merge remote-tracking branch 'origin/develop' into merge_hyperslab_update_01
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 25 | ||||
-rw-r--r-- | test/CMakePassthroughVOLTests.cmake (renamed from test/CMakeVOLTests.cmake) | 4 | ||||
-rw-r--r-- | test/CMakeTests.cmake | 195 | ||||
-rw-r--r-- | test/CMakeVFDTests.cmake | 2 | ||||
-rw-r--r-- | test/Makefile.am | 20 | ||||
-rw-r--r-- | test/enc_dec_plist.c | 878 | ||||
-rw-r--r-- | test/external.c | 262 | ||||
-rw-r--r-- | test/external_common.c | 127 | ||||
-rw-r--r-- | test/external_common.h | 50 | ||||
-rw-r--r-- | test/external_env.c | 213 | ||||
-rw-r--r-- | test/gen_plist.c | 4 | ||||
-rw-r--r-- | test/h5test.c | 78 | ||||
-rw-r--r-- | test/h5test.h | 1 | ||||
-rw-r--r-- | test/null_vol_connector.c | 25 | ||||
-rw-r--r-- | test/tattr.c | 109 | ||||
-rw-r--r-- | test/testexternal_env.sh.in | 42 | ||||
-rw-r--r-- | test/testvds_env.sh.in | 44 | ||||
-rw-r--r-- | test/tfile.c | 277 | ||||
-rw-r--r-- | test/th5s.c | 900 | ||||
-rw-r--r-- | test/trefer.c | 58 | ||||
-rw-r--r-- | test/vds.c | 280 | ||||
-rw-r--r-- | test/vds_env.c | 364 | ||||
-rw-r--r-- | test/vol.c | 1 |
23 files changed, 2848 insertions, 1111 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 772f790..c7888b8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,12 +14,14 @@ set (TEST_LIB_SOURCES ${HDF5_TEST_SOURCE_DIR}/h5test.c ${HDF5_TEST_SOURCE_DIR}/testframe.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c + ${HDF5_TEST_SOURCE_DIR}/external_common.c ${HDF5_TEST_SOURCE_DIR}/swmr_common.c ) set (TEST_LIB_HEADERS ${HDF5_TEST_SOURCE_DIR}/h5test.h ${HDF5_TEST_SOURCE_DIR}/cache_common.h + ${HDF5_TEST_SOURCE_DIR}/external_common.h ${HDF5_TEST_SOURCE_DIR}/swmr_common.h ) @@ -60,7 +62,7 @@ if (BUILD_SHARED_LIBS) endif () ################################################################################# -# If filter plugin tests can be tested +# If filter and vol plugin tests can be tested ################################################################################# if (BUILD_SHARED_LIBS) # make plugins dir @@ -129,6 +131,11 @@ if (BUILD_SHARED_LIBS) ) endforeach () + ################################################################################# + # make vol plugins dir + ################################################################################# + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/null_vol_plugin_dir") + #----------------------------------------------------------------------------- # Define VOL Plugin Test Sources #----------------------------------------------------------------------------- @@ -157,7 +164,7 @@ if (BUILD_SHARED_LIBS) COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "$<TARGET_FILE:${HDF5_VOL_PLUGIN_LIB_TARGET}>" - "${CMAKE_BINARY_DIR}/vol/$<TARGET_FILE_NAME:${HDF5_VOL_PLUGIN_LIB_TARGET}>" + "${CMAKE_BINARY_DIR}/null_vol_plugin_dir/$<TARGET_FILE_NAME:${HDF5_VOL_PLUGIN_LIB_TARGET}>" ) endforeach () endif () @@ -236,6 +243,7 @@ set (H5_TESTS extend direct_chunk # compression lib link external + external_env efc objcopy links @@ -263,6 +271,7 @@ set (H5_TESTS freespace mf vds + vds_env file_image unregister cache_logging @@ -454,12 +463,24 @@ if (BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (filter_plugin SHARED) target_link_libraries (filter_plugin PRIVATE ${HDF5_TEST_LIB_TARGET}) set_target_properties (filter_plugin PROPERTIES FOLDER test) + + add_executable (vol_plugin ${HDF5_TEST_SOURCE_DIR}/vol_plugin.c) + target_include_directories(vol_plugin PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (vol_plugin SHARED) + target_link_libraries (vol_plugin PRIVATE ${HDF5_TEST_LIB_TARGET}) + set_target_properties (vol_plugin PROPERTIES FOLDER test) else () add_executable (filter_plugin ${HDF5_TEST_SOURCE_DIR}/filter_plugin.c) target_include_directories(filter_plugin PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (filter_plugin STATIC) target_link_libraries (filter_plugin PRIVATE ${HDF5_TEST_LIB_TARGET}) set_target_properties (filter_plugin PROPERTIES FOLDER test) + + add_executable (vol_plugin ${HDF5_TEST_SOURCE_DIR}/vol_plugin.c) + target_include_directories(vol_plugin PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + TARGET_C_PROPERTIES (vol_plugin STATIC) + target_link_libraries (vol_plugin PRIVATE ${HDF5_TEST_LIB_TARGET}) + set_target_properties (vol_plugin PROPERTIES FOLDER test) endif () ############################################################################## diff --git a/test/CMakeVOLTests.cmake b/test/CMakePassthroughVOLTests.cmake index cf47291..928654e 100644 --- a/test/CMakeVOLTests.cmake +++ b/test/CMakePassthroughVOLTests.cmake @@ -99,6 +99,8 @@ endif () tcheck_version testmeta links_env + external_env + vds_env ) if (NOT CYGWIN) list (REMOVE_ITEM H5_VOL_SKIP_TESTS big cache) @@ -340,7 +342,7 @@ endif () set_tests_properties (VOL-${volname}-cache-shared PROPERTIES TIMEOUT ${CTEST_VERY_LONG_TIMEOUT}) endif () endif () - if (HDF5_TEST_FHEAP_VOL) + if (HDF5_TEST_FHEAP_PASSTHROUGH_VOL) add_test ( NAME VOL-${volname}-fheap-clear-objects COMMAND ${CMAKE_COMMAND} diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index c606eb1..3e6add0 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -542,8 +542,10 @@ set (H5TEST_SEPARATE_TESTS testhdf5 cache cache_image + external_env flush1 flush2 + vds_env ) foreach (h5_test ${H5_TESTS}) if (NOT h5_test IN_LIST H5TEST_SEPARATE_TESTS) @@ -679,6 +681,83 @@ set_tests_properties (H5TEST-cache_image PROPERTIES ) endif () +#-- Adding test for external_env +add_test ( + NAME H5TEST-clear-external_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + extern_1r.raw + extern_2r.raw + extern_3r.raw + extern_4r.raw + extern_1w.raw + extern_2w.raw + extern_3w.raw + extern_4w.raw + external_env.txt + external_env.out + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-external_env-objects PROPERTIES FIXTURES_SETUP external_env_clear_objects) +if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5TEST-external_env COMMAND $<TARGET_FILE:external_env>) +else () + add_test (NAME H5TEST-external_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:external_env>" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_EXTFILE_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=external_env.txt" + #-D "TEST_REFERENCE=external_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) +endif () +set_tests_properties (H5TEST-external_env PROPERTIES + FIXTURES_REQUIRED external_env_clear_objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + +#-- Adding test for vds_env +add_test ( + NAME H5TEST-clear-vds_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + vds_virt_0.h5 + vds_virt_3.h5 + vds_src_2.h5 + vds_env.txt + vds_env.out + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-vds_env-objects PROPERTIES FIXTURES_SETUP vds_env_clear_objects) +if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5TEST-vds_env COMMAND $<TARGET_FILE:vds_env>) +else () + add_test (NAME H5TEST-vds_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:vds_env>" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_VDS_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}/tmp" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=vds_env.txt" + #-D "TEST_REFERENCE=vds_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) +endif () +set_tests_properties (H5TEST-vds_env PROPERTIES + FIXTURES_REQUIRED vds_env_clear_objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + if (BUILD_SHARED_LIBS) #-- Adding test for cache if (NOT CYGWIN AND NOT WIN32) @@ -922,20 +1001,24 @@ add_test (NAME H5TEST-clear-links_env-objects ${HDF5_TEST_BINARY_DIR}/H5TEST ) set_tests_properties (H5TEST-clear-links_env-objects PROPERTIES FIXTURES_SETUP links_env_clear_objects) -add_test (NAME H5TEST-links_env COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:links_env>" - -D "TEST_ARGS:STRING=" - -D "TEST_ENV_VAR:STRING=HDF5_EXT_PREFIX" - -D "TEST_ENV_VALUE:STRING=.:tmp" - -D "TEST_EXPECT=0" - -D "TEST_OUTPUT=links_env.txt" - -D "TEST_REFERENCE=links_env.out" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" -) +if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5TEST-links_env COMMAND $<TARGET_FILE:links_env>) +else () + add_test (NAME H5TEST-links_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:links_env>" + -D "TEST_ARGS:STRING=" + #-D "TEST_ENV_VAR:STRING=HDF5_EXT_PREFIX" + #-D "TEST_ENV_VALUE:STRING=.:tmp" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=links_env.txt" + -D "TEST_REFERENCE=links_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) +endif () set_tests_properties (H5TEST-links_env PROPERTIES FIXTURES_REQUIRED links_env_clear_objects - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5_EXT_PREFIX=.:tmp" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) @@ -1027,8 +1110,8 @@ if (BUILD_SHARED_LIBS) add_test (NAME H5TEST-shared-links_env COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:links_env-shared>" -D "TEST_ARGS:STRING=" - -D "TEST_ENV_VAR:STRING=HDF5_EXT_PREFIX" - -D "TEST_ENV_VALUE:STRING=.:tmp" + #-D "TEST_ENV_VAR:STRING=HDF5_EXT_PREFIX" + #-D "TEST_ENV_VALUE:STRING=.:tmp" -D "TEST_EXPECT=0" -D "TEST_OUTPUT=links_env.txt" -D "TEST_REFERENCE=links_env.out" @@ -1037,6 +1120,67 @@ if (BUILD_SHARED_LIBS) ) set_tests_properties (H5TEST-shared-links_env PROPERTIES FIXTURES_REQUIRED shared_links_env_clear_objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared;HDF5_EXT_PREFIX=.:tmp" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for external_env + add_test (NAME H5TEST-shared-clear-external_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + extern_1r.raw + extern_2r.raw + extern_3r.raw + extern_4r.raw + extern_1w.raw + extern_2w.raw + extern_3w.raw + extern_4w.raw + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + set_tests_properties (H5TEST-shared-clear-external_env-objects PROPERTIES FIXTURES_SETUP shared_external_env_clear_objects) + add_test (NAME H5TEST-shared-external_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:external_env-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_EXTFILE_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=external_env.txt" + -D "TEST_REFERENCE=external_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-external_env PROPERTIES + FIXTURES_REQUIRED shared_external_env_clear_objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for vds_env + add_test (NAME H5TEST-shared-clear-vds_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + vds_virt_0.h5 + vds_virt_3.h5 + vds_src_2.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + set_tests_properties (H5TEST-shared-clear-vds_env-objects PROPERTIES FIXTURES_SETUP shared_vds_env_clear_objects) + add_test (NAME H5TEST-shared-vds_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:vds_env-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_VDS_PREFIX" + -D "TEST_ENV_VALUE:STRING=\${ORIGIN}/tmp" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=vds_env.txt" + -D "TEST_REFERENCE=vds_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-vds_env PROPERTIES + FIXTURES_REQUIRED shared_vds_env_clear_objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) @@ -1149,8 +1293,27 @@ endif () ############################################################################## ############################################################################## -if (HDF5_TEST_VOL) - include (CMakeVOLTests.cmake) +############################################################################## +### V O L P L U G I N T E S T S +############################################################################## +if (BUILD_SHARED_LIBS) + if (WIN32) + set (CMAKE_SEP "\;") + set (BIN_REL_PATH "../../") + else () + set (CMAKE_SEP ":") + set (BIN_REL_PATH "../") + endif () + + add_test (NAME H5PLUGIN-vol_plugin COMMAND $<TARGET_FILE:vol_plugin>) + set_tests_properties (H5PLUGIN-vol_plugin PROPERTIES + ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/null_vol_plugin_dir;srcdir=${HDF5_TEST_BINARY_DIR}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} + ) +endif () + +if (HDF5_TEST_PASSTHROUGH_VOL) + include (CMakePassthroughVOLTests.cmake) endif () ############################################################################## diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 64ccacd..383b2f4 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -102,6 +102,8 @@ endif () tcheck_version testmeta links_env + external_env + vds_env ) if (NOT CYGWIN) list (REMOVE_ITEM H5_VFD_SKIP_TESTS big cache) diff --git a/test/Makefile.am b/test/Makefile.am index 88dc542..1b82aa4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -26,21 +26,23 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testlibinfo.sh: # testcheck_version.sh: tcheck_version # testlinks_env.sh: links_env +# testexternal_env.sh: external_env # testflushrefresh.sh: flushrefresh +# testvds_env.sh: vds_env # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* # testabort_fail.sh: filenotclosed.c and del_many_dense_attrs.c # test_filter_plugin.sh: filter_plugin.c # test_usecases.sh: use_append_chunk, use_append_mchunks, use_disable_mdc_flushes -TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh \ - testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh +TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh testexternal_env.sh \ + testswmr.sh testvds_env.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh testabort_fail.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) \ - filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ + external_env$(EXEEXT) filenotclosed$(EXEEXT) del_many_dense_attrs$(EXEEXT) \ flushrefresh$(EXEEXT) use_append_chunk$(EXEEXT) use_append_mchunks$(EXEEXT) use_disable_mdc_flushes$(EXEEXT) \ 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_start_write$(EXEEXT) \ - vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) + vds_env$(EXEEXT) vds_swmr_gen$(EXEEXT) vds_swmr_reader$(EXEEXT) vds_swmr_writer$(EXEEXT) if HAVE_SHARED_CONDITIONAL TEST_SCRIPT += test_filter_plugin.sh test_vol_plugin.sh SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) @@ -69,21 +71,23 @@ TEST_PROG= testhdf5 \ # accum_swmr_reader is used by accum.c. # atomic_writer and atomic_reader are standalone programs. # links_env is used by testlinks_env.sh +# external_env is used by testexternal_env.sh # filenotclosed and del_many_dense_attrs are used by testabort_fail.sh # flushrefresh is used by testflushrefresh.sh. # use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh # swmr_* files (besides swmr.c) are used by testswmr.sh. # vds_swmr_* files are used by testvdsswmr.sh +# vds_env is used by testvds_env.sh # 'make check' doesn't run them directly, so they are not included in TEST_PROG. # Also build testmeta, which is used for timings test. It builds quickly, # and this lets automake keep all its test programs in one place. check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version \ - testmeta accum_swmr_reader atomic_writer atomic_reader \ + testmeta accum_swmr_reader atomic_writer atomic_reader external_env \ links_env filenotclosed del_many_dense_attrs flushrefresh \ use_append_chunk use_append_mchunks use_disable_mdc_flushes \ swmr_generator swmr_start_write swmr_reader swmr_writer swmr_remove_reader \ swmr_remove_writer swmr_addrem_writer swmr_sparse_reader swmr_sparse_writer \ - swmr_check_compat_vfd vds_swmr_gen vds_swmr_reader vds_swmr_writer + swmr_check_compat_vfd vds_env vds_swmr_gen vds_swmr_reader vds_swmr_writer if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= filter_plugin vol_plugin endif @@ -131,7 +135,7 @@ else noinst_LTLIBRARIES=libh5test.la endif -libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c +libh5test_la_SOURCES=h5test.c testframe.c cache_common.c swmr_common.c external_common.c # Use libhd5test.la to compile all of the tests LDADD=libh5test.la $(LIBHDF5) @@ -223,7 +227,7 @@ use_disable_mdc_flushes_SOURCES=use_disable_mdc_flushes.c # Temporary files. DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_filter_plugin.sh \ - testswmr.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh testabort_fail.sh \ + testexternal_env.sh testswmr.sh testvds_env.sh testvdsswmr.sh test_usecases.sh testflushrefresh.sh testabort_fail.sh \ test_vol_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 33d23dc..2c8f691 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -15,75 +15,139 @@ * Serial tests for encoding/decoding plists */ -#include "h5test.h" +#include "testhdf5.h" #include "H5ACprivate.h" #include "H5Pprivate.h" +#define SRC_FNAME "source_file.h5" +#define SRC_DSET "src_dset" + static int -test_encode_decode(hid_t orig_pl) +test_encode_decode(hid_t orig_pl, H5F_libver_t low, H5F_libver_t high, hbool_t support_virtual) { - hid_t pl = (-1); /* Decoded property list */ + hid_t pl = (-1); /* Decoded property list */ + hid_t fapl = -1; /* File access property list */ void *temp_buf = NULL; /* Pointer to encoding buffer */ size_t temp_size = 0; /* Size of encoding buffer */ + herr_t ret; /* Return value */ - /* first call to encode returns only the size of the buffer needed */ - if(H5Pencode(orig_pl, NULL, &temp_size) < 0) - STACK_ERROR + /* Create file access property list */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + TEST_ERROR - if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + /* Set library version bounds */ + if(H5Pset_libver_bounds(fapl, low, high) < 0) TEST_ERROR - if(H5Pencode(orig_pl, temp_buf, &temp_size) < 0) - STACK_ERROR + H5E_BEGIN_TRY { + ret = H5Pencode2(orig_pl, NULL, &temp_size, fapl); + } H5E_END_TRY; + + if(support_virtual && high < H5F_LIBVER_V110) + VERIFY(ret, FAIL, "H5Pencode2"); + else { + + VERIFY(ret, SUCCEED, "H5Pencode2"); + + /* Allocate the buffer for encoding */ + if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + TEST_ERROR + + /* Encode the property list to the buffer */ + if(H5Pencode2(orig_pl, temp_buf, &temp_size, fapl) < 0) + TEST_ERROR + + /* Decode the buffer */ + if((pl = H5Pdecode(temp_buf)) < 0) + STACK_ERROR + + /* Check if the original and the decoded property lists are equal */ + if(!H5Pequal(orig_pl, pl)) + PUTS_ERROR("encoding-decoding cycle failed\n") + + /* Close the decoded property list */ + if((H5Pclose(pl)) < 0) + TEST_ERROR + + /* Free the buffer */ + if(temp_buf) + HDfree(temp_buf); + +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* Test H5Pencode1() */ + + /* first call to encode returns only the size of the buffer needed */ + if(H5Pencode1(orig_pl, NULL, &temp_size) < 0) + STACK_ERROR + + if(NULL == (temp_buf = (void *)HDmalloc(temp_size))) + TEST_ERROR + + if(H5Pencode1(orig_pl, temp_buf, &temp_size) < 0) + STACK_ERROR - if((pl = H5Pdecode(temp_buf)) < 0) - STACK_ERROR + if((pl = H5Pdecode(temp_buf)) < 0) + STACK_ERROR - if(!H5Pequal(orig_pl, pl)) - PUTS_ERROR("encoding-decoding cycle failed\n") + if(!H5Pequal(orig_pl, pl)) + PUTS_ERROR("encoding-decoding cycle failed\n") - if((H5Pclose(pl)) < 0) - STACK_ERROR + if((H5Pclose(pl)) < 0) + STACK_ERROR - HDfree(temp_buf); + if(temp_buf) + HDfree(temp_buf); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + } + + if((H5Pclose(fapl)) < 0) + TEST_ERROR /* Success */ return(0); error: - if(pl > 0) - H5Pclose(pl); if(temp_buf) HDfree(temp_buf); + H5E_BEGIN_TRY { + H5Pclose(pl); + H5Pclose(fapl); + } H5E_END_TRY; + return(-1); } /* end test_encode_decode() */ int main(void) { - hid_t dcpl; /* dataset create prop. list */ - hid_t dapl; /* dataset access prop. list */ - hid_t dxpl; /* dataset xfer prop. list */ - hid_t gcpl; /* group create prop. list */ - hid_t ocpypl; /* object copy prop. list */ - hid_t ocpl; /* object create prop. list */ - hid_t lcpl; /* link create prop. list */ - hid_t lapl; /* link access prop. list */ - hid_t fapl; /* file access prop. list */ - hid_t fcpl; /* file create prop. list */ - hid_t strcpl; /* string create prop. list */ - hid_t acpl; /* attribute create prop. list */ - + hid_t dcpl; /* dataset create prop. list */ + hid_t dapl; /* dataset access prop. list */ + hid_t dxpl; /* dataset xfer prop. list */ + hid_t gcpl; /* group create prop. list */ + hid_t ocpypl; /* object copy prop. list */ + hid_t ocpl; /* object create prop. list */ + hid_t lcpl; /* link create prop. list */ + hid_t lapl; /* link access prop. list */ + hid_t fapl; /* file access prop. list */ + hid_t fcpl; /* file create prop. list */ + hid_t strcpl; /* string create prop. list */ + hid_t acpl; /* attribute create prop. list */ + hid_t srcspace = -1; /* Source dataspaces */ + hid_t vspace = -1; /* Virtual dset dataspaces */ + hsize_t dims[1] = {3}; /* Data space current size */ hsize_t chunk_size[2] = {16384, 4}; /* chunk size */ - double fill = 2.7f; /* Fill value */ - hsize_t max_size[1]; /* data space maximum size */ + double fill = 2.7f; /* Fill value */ + hsize_t max_size[1]; /* data space maximum size */ size_t nslots = 521 * 2; size_t nbytes = 1048576 * 10; double w0 = 0.5f; unsigned max_compact; unsigned min_dense; const char* c_to_f = "x+32"; + H5F_libver_t low, high; /* Low and high bounds */ + H5AC_cache_config_t my_cache_config = { H5AC__CURR_CACHE_CONFIG_VERSION, TRUE, @@ -115,467 +179,511 @@ main(void) 0.2f, (256 * 2048), H5AC__DEFAULT_METADATA_WRITE_STRATEGY}; + H5AC_cache_image_config_t my_cache_image_config = { - H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, - TRUE, + H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, + TRUE, FALSE, - -1}; - - if(VERBOSE_MED) - printf("Encode/Decode DCPLs\n"); + -1 }; + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char* low_string; /* The low bound string */ + char* high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing ENCODE/DECODE with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + + if(VERBOSE_MED) + printf("Encode/Decode DCPLs\n"); + + /******* ENCODE/DECODE DCPLS *****/ + TESTING("Default DCPL Encoding/Decoding"); + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DCPL Encoding/Decoding"); + + if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) + FAIL_STACK_ERROR + + if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) + FAIL_STACK_ERROR + + max_size[0] = 100; + if((H5Pset_external(dcpl, "ext1.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext2.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext3.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + if((H5Pset_external(dcpl, "ext4.data", (off_t)0, + (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding property list */ + if(test_encode_decode(dcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dcpl)) < 0) + FAIL_STACK_ERROR + + PASSED(); + + /******* ENCODE/DECODE DCPLS *****/ + TESTING("DCPL Encoding/Decoding for virtual layout"); + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Set virtual layout */ + if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0) + TEST_ERROR + + /* Create source dataspace */ + if((srcspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace = H5Screate_simple(1, dims, NULL)) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace, SRC_FNAME, SRC_DSET, srcspace) < 0) + TEST_ERROR + + if(test_encode_decode(dcpl, low, high, TRUE) < 0) + FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dcpl)) < 0) + FAIL_STACK_ERROR + + /******* ENCODE/DECODE DAPLS *****/ + TESTING("Default DAPL Encoding/Decoding"); + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(dapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + + PASSED(); + + TESTING("DAPL Encoding/Decoding"); + + if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding property list */ + if(test_encode_decode(dapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") + + /* release resource */ + if((H5Pclose(dapl)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE DCPLS *****/ - TESTING("Default DCPL Encoding/Decoding"); - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(dcpl) < 0) - FAIL_PUTS_ERROR("Default DCPL encoding/decoding failed\n") + /******* ENCODE/DECODE OCPLS *****/ + TESTING("Default OCPL Encoding/Decoding"); + if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("DCPL Encoding/Decoding"); + TESTING("OCPL Encoding/Decoding"); - if((H5Pset_chunk(dcpl, 2, chunk_size)) < 0) - FAIL_STACK_ERROR + if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + FAIL_STACK_ERROR - if((H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE)) < 0) - FAIL_STACK_ERROR + if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) + FAIL_STACK_ERROR - if((H5Pset_fill_value(dcpl, H5T_NATIVE_DOUBLE, &fill)) < 0) - FAIL_STACK_ERROR + if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) + FAIL_STACK_ERROR - if((H5Pset_dset_no_attrs_hint(dcpl, FALSE)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(ocpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") - max_size[0] = 100; - if((H5Pset_external(dcpl, "ext1.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext2.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext3.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR - if((H5Pset_external(dcpl, "ext4.data", (off_t)0, - (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(ocpl)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(dcpl) < 0) - FAIL_PUTS_ERROR("DCPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(dcpl)) < 0) - FAIL_STACK_ERROR + PASSED(); - PASSED(); + /******* ENCODE/DECODE DXPLS *****/ + TESTING("Default DXPL Encoding/Decoding"); + if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) + FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(dxpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") - /******* ENCODE/DECODE DAPLS *****/ - TESTING("Default DAPL Encoding/Decoding"); - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(dapl) < 0) - FAIL_PUTS_ERROR("Default DAPL encoding/decoding failed\n") + TESTING("DXPL Encoding/Decoding"); - PASSED(); + if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) + FAIL_STACK_ERROR + if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) + FAIL_STACK_ERROR - TESTING("DAPL Encoding/Decoding"); +#ifdef H5_HAVE_PARALLEL + if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) + FAIL_STACK_ERROR + if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) + FAIL_STACK_ERROR +#endif/* H5_HAVE_PARALLEL */ + if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) + FAIL_STACK_ERROR + if((H5Pset_data_transform(dxpl, c_to_f)) < 0) + FAIL_STACK_ERROR - if((H5Pset_chunk_cache(dapl, nslots, nbytes, w0)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(dxpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") - /* Test encoding & decoding property list */ - if(test_encode_decode(dapl) < 0) - FAIL_PUTS_ERROR("DAPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(dapl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(dxpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + /******* ENCODE/DECODE GCPLS *****/ + TESTING("Default GCPL Encoding/Decoding"); + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + FAIL_STACK_ERROR + + /* Test encoding & decoding default property list */ + if(test_encode_decode(gcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") - /******* ENCODE/DECODE OCPLS *****/ - TESTING("Default OCPL Encoding/Decoding"); - if((ocpl = H5Pcreate(H5P_OBJECT_CREATE)) < 0) - FAIL_STACK_ERROR + PASSED(); - /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpl) < 0) - FAIL_PUTS_ERROR("Default OCPL encoding/decoding failed\n") + TESTING("GCPL Encoding/Decoding"); - PASSED(); + if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) + FAIL_STACK_ERROR - TESTING("OCPL Encoding/Decoding"); + if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) + FAIL_STACK_ERROR - if((H5Pset_attr_creation_order(ocpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - FAIL_STACK_ERROR + /* Query the group creation properties */ + if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) + FAIL_STACK_ERROR - if((H5Pset_attr_phase_change (ocpl, 110, 105)) < 0) - FAIL_STACK_ERROR + if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) + FAIL_STACK_ERROR - if((H5Pset_filter (ocpl, H5Z_FILTER_FLETCHER32, 0, (size_t)0, NULL)) < 0) - FAIL_STACK_ERROR + if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(ocpl) < 0) - FAIL_PUTS_ERROR("OCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(gcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(ocpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(gcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + /******* ENCODE/DECODE LCPLS *****/ + TESTING("Default LCPL Encoding/Decoding"); + if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE DXPLS *****/ - TESTING("Default DXPL Encoding/Decoding"); - if((dxpl = H5Pcreate(H5P_DATASET_XFER)) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding default property list */ + if(test_encode_decode(lcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") - /* Test encoding & decoding default property list */ - if(test_encode_decode(dxpl) < 0) - FAIL_PUTS_ERROR("Default DXPL encoding/decoding failed\n") + PASSED(); - PASSED(); + TESTING("LCPL Encoding/Decoding"); - TESTING("DXPL Encoding/Decoding"); + if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) + FAIL_STACK_ERROR - if((H5Pset_btree_ratios(dxpl, 0.2f, 0.6f, 0.2f)) < 0) - FAIL_STACK_ERROR - if((H5Pset_hyper_vector_size(dxpl, 5)) < 0) - FAIL_STACK_ERROR -#ifdef H5_HAVE_PARALLEL - if((H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_collective_opt(dxpl, H5FD_MPIO_INDIVIDUAL_IO)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt(dxpl, H5FD_MPIO_CHUNK_MULTI_IO)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_ratio(dxpl, 30)) < 0) - FAIL_STACK_ERROR - if((H5Pset_dxpl_mpio_chunk_opt_num(dxpl, 40)) < 0) - FAIL_STACK_ERROR -#endif/* H5_HAVE_PARALLEL */ - if((H5Pset_edc_check(dxpl, H5Z_DISABLE_EDC)) < 0) - FAIL_STACK_ERROR - if((H5Pset_data_transform(dxpl, c_to_f)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(dxpl) < 0) - FAIL_PUTS_ERROR("DXPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(lcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(dxpl)) < 0) - FAIL_STACK_ERROR - - PASSED(); + /* release resource */ + if((H5Pclose(lcpl)) < 0) + FAIL_STACK_ERROR + PASSED(); - /******* ENCODE/DECODE GCPLS *****/ - TESTING("Default GCPL Encoding/Decoding"); - if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) - FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(gcpl) < 0) - FAIL_PUTS_ERROR("Default GCPL encoding/decoding failed\n") + /******* ENCODE/DECODE LAPLS *****/ + TESTING("Default LAPL Encoding/Decoding"); + if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) + FAIL_STACK_ERROR - PASSED(); + /* Test encoding & decoding default property list */ + if(test_encode_decode(lapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") - TESTING("GCPL Encoding/Decoding"); - - if((H5Pset_local_heap_size_hint(gcpl, 256)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_link_phase_change(gcpl, 2, 2)) < 0) - FAIL_STACK_ERROR - - /* Query the group creation properties */ - if((H5Pget_link_phase_change(gcpl, &max_compact, &min_dense)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_est_link_info(gcpl, 3, 9)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_link_creation_order(gcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED))) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(gcpl) < 0) - FAIL_PUTS_ERROR("GCPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(gcpl)) < 0) - FAIL_STACK_ERROR + PASSED(); - PASSED(); + TESTING("LAPL Encoding/Decoding"); + if((H5Pset_nlinks(lapl, (size_t)134)) < 0) + FAIL_STACK_ERROR - /******* ENCODE/DECODE LCPLS *****/ - TESTING("Default LCPL Encoding/Decoding"); - if((lcpl = H5Pcreate(H5P_LINK_CREATE)) < 0) - FAIL_STACK_ERROR + if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(lcpl) < 0) - FAIL_PUTS_ERROR("Default LCPL encoding/decoding failed\n") + if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) + FAIL_STACK_ERROR - PASSED(); + /* Create FAPL for the elink FAPL */ + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR + if((H5Pset_alignment(fapl, 2, 1024)) < 0) + FAIL_STACK_ERROR - TESTING("LCPL Encoding/Decoding"); + if((H5Pset_elink_fapl(lapl, fapl)) < 0) + FAIL_STACK_ERROR - if((H5Pset_create_intermediate_group(lcpl, TRUE)) < 0) - FAIL_STACK_ERROR + /* Close the elink's FAPL */ + if((H5Pclose(fapl)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(lcpl) < 0) - FAIL_PUTS_ERROR("LCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(lapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(lcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(lapl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE LAPLS *****/ - TESTING("Default LAPL Encoding/Decoding"); - if((lapl = H5Pcreate(H5P_LINK_ACCESS)) < 0) - FAIL_STACK_ERROR + /******* ENCODE/DECODE OCPYPLS *****/ + TESTING("Default OCPYPL Encoding/Decoding"); + if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(lapl) < 0) - FAIL_PUTS_ERROR("Default LAPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("LAPL Encoding/Decoding"); + TESTING("OCPYPL Encoding/Decoding"); - if((H5Pset_nlinks(lapl, (size_t)134)) < 0) - FAIL_STACK_ERROR + if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) + FAIL_STACK_ERROR - if((H5Pset_elink_acc_flags(lapl, H5F_ACC_RDONLY)) < 0) - FAIL_STACK_ERROR + if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) + FAIL_STACK_ERROR + if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) + FAIL_STACK_ERROR - if((H5Pset_elink_prefix(lapl, "/tmpasodiasod")) < 0) - FAIL_STACK_ERROR - - /* Create FAPL for the elink FAPL */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) - FAIL_STACK_ERROR - - if((H5Pset_elink_fapl(lapl, fapl)) < 0) - FAIL_STACK_ERROR - - /* Close the elink's FAPL */ - if((H5Pclose(fapl)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(lapl) < 0) - FAIL_PUTS_ERROR("LAPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(ocpypl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(lapl)) < 0) - FAIL_STACK_ERROR - - PASSED(); + /* release resource */ + if((H5Pclose(ocpypl)) < 0) + FAIL_STACK_ERROR + PASSED(); - /******* ENCODE/DECODE OCPYPLS *****/ - TESTING("Default OCPYPL Encoding/Decoding"); - if((ocpypl = H5Pcreate(H5P_OBJECT_COPY)) < 0) - FAIL_STACK_ERROR + /******* ENCODE/DECODE FAPLS *****/ + TESTING("Default FAPL Encoding/Decoding"); + if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(ocpypl) < 0) - FAIL_PUTS_ERROR("Default OCPYPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(fapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("OCPYPL Encoding/Decoding"); + TESTING("FAPL Encoding/Decoding"); - if((H5Pset_copy_object(ocpypl, H5O_COPY_EXPAND_EXT_LINK_FLAG)) < 0) - FAIL_STACK_ERROR + if((H5Pset_family_offset(fapl, 1024)) < 0) + FAIL_STACK_ERROR + if((H5Pset_meta_block_size(fapl, 2098452)) < 0) + FAIL_STACK_ERROR + if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) + FAIL_STACK_ERROR + if((H5Pset_alignment(fapl, 2, 1024)) < 0) + FAIL_STACK_ERROR + if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) + FAIL_STACK_ERROR + if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) + FAIL_STACK_ERROR + if((H5Pset_gc_references(fapl, 1)) < 0) + FAIL_STACK_ERROR + if((H5Pset_small_data_block_size(fapl, 2048)) < 0) + FAIL_STACK_ERROR + if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) + FAIL_STACK_ERROR + if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) + FAIL_STACK_ERROR + if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) + FAIL_STACK_ERROR + if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) + FAIL_STACK_ERROR + if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) + FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "foo")) < 0) - FAIL_STACK_ERROR - if((H5Padd_merge_committed_dtype_path(ocpypl, "bar")) < 0) - FAIL_STACK_ERROR + /* Test encoding & decoding property list */ + if(test_encode_decode(fapl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") - /* Test encoding & decoding property list */ - if(test_encode_decode(ocpypl) < 0) - FAIL_PUTS_ERROR("OCPYPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(ocpypl)) < 0) - FAIL_STACK_ERROR - - PASSED(); - - - /******* ENCODE/DECODE FAPLS *****/ - TESTING("Default FAPL Encoding/Decoding"); - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding default property list */ - if(test_encode_decode(fapl) < 0) - FAIL_PUTS_ERROR("Default FAPL encoding/decoding failed\n") - - PASSED(); - - TESTING("FAPL Encoding/Decoding"); - - if((H5Pset_family_offset(fapl, 1024)) < 0) - FAIL_STACK_ERROR - if((H5Pset_meta_block_size(fapl, 2098452)) < 0) - FAIL_STACK_ERROR - if((H5Pset_sieve_buf_size(fapl, 1048576)) < 0) - FAIL_STACK_ERROR - if((H5Pset_alignment(fapl, 2, 1024)) < 0) - FAIL_STACK_ERROR - if((H5Pset_cache(fapl, 1024, 128, 10485760, 0.3f)) < 0) - FAIL_STACK_ERROR - if((H5Pset_elink_file_cache_size(fapl, 10485760)) < 0) - FAIL_STACK_ERROR - if((H5Pset_gc_references(fapl, 1)) < 0) - FAIL_STACK_ERROR - if((H5Pset_small_data_block_size(fapl, 2048)) < 0) - FAIL_STACK_ERROR - if((H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST)) < 0) - FAIL_STACK_ERROR - if((H5Pset_fclose_degree(fapl, H5F_CLOSE_WEAK)) < 0) - FAIL_STACK_ERROR - if((H5Pset_multi_type(fapl, H5FD_MEM_GHEAP)) < 0) - FAIL_STACK_ERROR - if((H5Pset_mdc_config(fapl, &my_cache_config)) < 0) - FAIL_STACK_ERROR - if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) - FAIL_STACK_ERROR - - /* Test encoding & decoding property list */ - if(test_encode_decode(fapl) < 0) - FAIL_PUTS_ERROR("FAPL encoding/decoding failed\n") - - /* release resource */ - if((H5Pclose(fapl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(fapl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE FCPLS *****/ - TESTING("Default FCPL Encoding/Decoding"); + /******* ENCODE/DECODE FCPLS *****/ + TESTING("Default FCPL Encoding/Decoding"); - if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) - FAIL_STACK_ERROR + if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(fcpl) < 0) - FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(fcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default FCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("FCPL Encoding/Decoding"); + TESTING("FCPL Encoding/Decoding"); - if((H5Pset_userblock(fcpl, 1024) < 0)) - FAIL_STACK_ERROR + if((H5Pset_userblock(fcpl, 1024) < 0)) + FAIL_STACK_ERROR - if((H5Pset_istore_k(fcpl, 3) < 0)) - FAIL_STACK_ERROR + if((H5Pset_istore_k(fcpl, 3) < 0)) + FAIL_STACK_ERROR - if((H5Pset_sym_k(fcpl, 4, 5) < 0)) - FAIL_STACK_ERROR + if((H5Pset_sym_k(fcpl, 4, 5) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_nindexes(fcpl, 8) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_index(fcpl, 1, H5O_SHMESG_SDSPACE_FLAG, 32) < 0)) + FAIL_STACK_ERROR - if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) - FAIL_STACK_ERROR + if((H5Pset_shared_mesg_phase_change(fcpl, 60, 20) < 0)) + FAIL_STACK_ERROR - if((H5Pset_sizes(fcpl, 8, 4) < 0)) - FAIL_STACK_ERROR + if((H5Pset_sizes(fcpl, 8, 4) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(fcpl) < 0) - FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(fcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("FCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(fcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(fcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE STRCPLS *****/ - TESTING("Default STRCPL Encoding/Decoding"); + /******* ENCODE/DECODE STRCPLS *****/ + TESTING("Default STRCPL Encoding/Decoding"); - if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) - FAIL_STACK_ERROR + if((strcpl = H5Pcreate(H5P_STRING_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(strcpl) < 0) - FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(strcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default STRCPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("STRCPL Encoding/Decoding"); + TESTING("STRCPL Encoding/Decoding"); - if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_char_encoding(strcpl, H5T_CSET_UTF8) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(strcpl) < 0) - FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(strcpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("STRCPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(strcpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(strcpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); - /******* ENCODE/DECODE ACPLS *****/ - TESTING("Default ACPL Encoding/Decoding"); + /******* ENCODE/DECODE ACPLS *****/ + TESTING("Default ACPL Encoding/Decoding"); - if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) - FAIL_STACK_ERROR + if((acpl = H5Pcreate(H5P_ATTRIBUTE_CREATE)) < 0) + FAIL_STACK_ERROR - /* Test encoding & decoding default property list */ - if(test_encode_decode(acpl) < 0) - FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") + /* Test encoding & decoding default property list */ + if(test_encode_decode(acpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("Default ACPL encoding/decoding failed\n") - PASSED(); + PASSED(); - TESTING("ACPL Encoding/Decoding"); + TESTING("ACPL Encoding/Decoding"); - if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) - FAIL_STACK_ERROR + if((H5Pset_char_encoding(acpl, H5T_CSET_UTF8) < 0)) + FAIL_STACK_ERROR - /* Test encoding & decoding property list */ - if(test_encode_decode(acpl) < 0) - FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") + /* Test encoding & decoding property list */ + if(test_encode_decode(acpl, low, high, FALSE) < 0) + FAIL_PUTS_ERROR("ACPL encoding/decoding failed\n") - /* release resource */ - if((H5Pclose(acpl)) < 0) - FAIL_STACK_ERROR + /* release resource */ + if((H5Pclose(acpl)) < 0) + FAIL_STACK_ERROR - PASSED(); + PASSED(); + } /* end high */ + } /* end low */ return 0; diff --git a/test/external.c b/test/external.c index 20a9ed8..6aa9d1b 100644 --- a/test/external.c +++ b/test/external.c @@ -17,25 +17,7 @@ * * Purpose: Tests datasets stored in external raw files. */ -#include "h5test.h" - -const char *FILENAME[] = { - "extern_1", - "extern_2", - "extern_3", - "extern_4", - "extern_dir/file_1", - "extern_5", - NULL -}; - -/* A similar collection of files is used for the tests that - * perform file I/O. - */ -#define N_EXT_FILES 4 -#define PART_SIZE 25 -#define TOTAL_SIZE 100 -#define GARBAGE_PER_FILE 10 +#include "external_common.h" /*------------------------------------------------------------------------- @@ -99,106 +81,6 @@ out: /*------------------------------------------------------------------------- - * Function: reset_raw_data_files - * - * Purpose: Resets the data in the raw data files for tests that - * perform dataset I/O on a set of files. - * - * Return: SUCCEED/FAIL - * - * Programmer: Dana Robinson - * February 2016 - * - *------------------------------------------------------------------------- - */ -static herr_t -reset_raw_data_files(void) -{ - int fd = 0; /* external file descriptor */ - size_t i, j; /* iterators */ - hssize_t n; /* bytes of I/O */ - char filename[1024]; /* file name */ - int data[PART_SIZE]; /* raw data buffer */ - uint8_t *garbage = NULL; /* buffer of garbage data */ - size_t garbage_count; /* size of garbage buffer */ - size_t garbage_bytes; /* # of garbage bytes written to file */ - - /* Set up garbage buffer */ - garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; - if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) - goto error; - for(i = 0; i < garbage_count; i++) - garbage[i] = 0xFF; - - /* The *r files are pre-filled with data and are used to - * verify that read operations work correctly. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Fill array with data */ - for(j = 0; j < PART_SIZE; j++) { - data[j] = (int)(i * 25 + j); - } /* end for */ - - /* Write raw data to the file. */ - n = HDwrite(fd, data, sizeof(data)); - if(n != sizeof(data)) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - - /* The *w files are only pre-filled with the garbage data and are - * used to verify that write operations work correctly. The individual - * tests fill in the actual data. - */ - for(i = 0; i < N_EXT_FILES; i++) { - - /* Open file */ - HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); - if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) - goto error; - - /* Write garbage data to the file. This allows us to test the - * the ability to set an offset in the raw data file. - */ - garbage_bytes = i * 10; - n = HDwrite(fd, garbage, garbage_bytes); - if(n < 0 || (size_t)n != garbage_bytes) - goto error; - - /* Close this file */ - HDclose(fd); - - } /* end for */ - HDfree(garbage); - return SUCCEED; - -error: - if(fd) - HDclose(fd); - if(garbage) - HDfree(garbage); - return FAIL; -} /* end reset_raw_data_files() */ - - -/*------------------------------------------------------------------------- * Function: test_non_extendible * * Purpose: Tests a non-extendible dataset with a single external file. @@ -753,14 +635,14 @@ test_read_file_set(hid_t fapl) TEST_ERROR /* Reset the raw data files */ - if(reset_raw_data_files() < 0) + if(reset_raw_data_files(0) < 0) TEST_ERROR /* Create the file and an initial group. This causes messages about * debugging to be emitted before we start playing games with what the * output looks like. */ - h5_fixname(FILENAME[1], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[1], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR if((grp = H5Gcreate2(file, "emit-diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -871,7 +753,7 @@ test_write_file_set(hid_t fapl) TEST_ERROR /* Create another file */ - h5_fixname(FILENAME[2], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[2], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR @@ -893,7 +775,7 @@ test_write_file_set(hid_t fapl) } /* end for */ /* Reset the raw data files */ - if(reset_raw_data_files() < 0) + if(reset_raw_data_files(0) < 0) TEST_ERROR /* Create the dataset */ @@ -989,12 +871,12 @@ test_path_absolute(hid_t fapl) TESTING("absolute filenames for external file"); - h5_fixname(FILENAME[3], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[3], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR /* Reset the raw data files */ - if(reset_raw_data_files() < 0) + if(reset_raw_data_files(0) < 0) TEST_ERROR /* Create the dcpl */ @@ -1085,12 +967,12 @@ test_path_relative(hid_t fapl) if (HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; /* Reset the raw data files */ - if(reset_raw_data_files() < 0) + if(reset_raw_data_files(0) < 0) TEST_ERROR /* Create the dataset */ @@ -1180,12 +1062,12 @@ test_path_relative_cwd(hid_t fapl) if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) TEST_ERROR; - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[4], fapl, filename, sizeof(filename)); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR; /* Reset the raw data files */ - if(reset_raw_data_files() < 0) + if(reset_raw_data_files(0) < 0) TEST_ERROR /* Create the dataset */ @@ -1297,116 +1179,6 @@ error: /*------------------------------------------------------------------------- - * Function: test_path_env - * - * Purpose: Test whether the value of HDF5_EXTFILE_PREFIX will overwrite - * the efile_prefix dataset access property. - * This will create an HDF5 file in a subdirectory which will - * refer to ../extern_*a.raw - * The files are then accessed by setting the HDF5_EXTFILE_PREFIX - * environment variable to "${ORIGIN}". - * The efile_prefix dataset access property is set to "someprefix", - * which will cause an error if the value is not overwritten by - * the environment variable. - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: Steffen Kiess - * March 10, 2015 - * - *------------------------------------------------------------------------- - */ -static int -test_path_env(hid_t fapl) -{ - hid_t file = -1; /* file to write to */ - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* data space */ - hid_t dapl = -1; /* dataset access property list */ - hid_t dset = -1; /* dataset */ - size_t i; /* miscellaneous counters */ - char cwdpath[1024]; /* working directory */ - char filename[1024]; /* file name */ - int part[PART_SIZE]; /* raw data buffer (partial) */ - int whole[TOTAL_SIZE]; /* raw data buffer (total) */ - hsize_t cur_size; /* current data space size */ - char buffer[1024]; /* buffer to read efile_prefix */ - - TESTING("prefix in HDF5_EXTFILE_PREFIX"); - - if(HDsetenv("HDF5_EXTFILE_PREFIX", "${ORIGIN}", 1)) - TEST_ERROR - - if(HDmkdir("extern_dir", (mode_t)0755) < 0 && errno != EEXIST) - TEST_ERROR; - - h5_fixname(FILENAME[4], fapl, filename, sizeof(filename)); - if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - FAIL_STACK_ERROR - - /* Reset the raw data files */ - if(reset_raw_data_files() < 0) - TEST_ERROR - - /* Create the dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR - if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) - TEST_ERROR - for(i = 0; i < N_EXT_FILES; i++) { - HDsnprintf(filename, sizeof(filename), "..%sextern_%dr.raw", H5_DIR_SEPS, (int) i + 1); - if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) - FAIL_STACK_ERROR - } /* end for */ - - cur_size = TOTAL_SIZE; - if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) - FAIL_STACK_ERROR - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - FAIL_STACK_ERROR - - /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if(H5Pset_efile_prefix(dapl, "someprefix") < 0) - FAIL_STACK_ERROR - if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) - FAIL_STACK_ERROR - if(HDstrcmp(buffer, "someprefix") != 0) - FAIL_PUTS_ERROR("efile prefix not set correctly"); - - /* Create dataset */ - if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) - FAIL_STACK_ERROR - - /* Read the entire dataset and compare with the original */ - HDmemset(whole, 0, sizeof(whole)); - if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) - FAIL_STACK_ERROR - for(i = 0; i < TOTAL_SIZE; i++) - if(whole[i] != (signed)i) - FAIL_PUTS_ERROR("Incorrect value(s) read."); - - if(H5Dclose(dset) < 0) FAIL_STACK_ERROR - if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR - if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR - if(H5Sclose(space) < 0) FAIL_STACK_ERROR - if(H5Fclose(file) < 0) FAIL_STACK_ERROR - PASSED(); - return 0; - -error: - H5E_BEGIN_TRY { - H5Pclose(dapl); - H5Dclose(dset); - H5Pclose(dcpl); - H5Sclose(space); - H5Fclose(file); - } H5E_END_TRY; - return 1; -} /* end test_path_env() */ - - -/*------------------------------------------------------------------------- * Function: test_h5d_get_access_plist * * Purpose: Ensure that H5Dget_access_plist returns correct values. @@ -1437,11 +1209,11 @@ test_h5d_get_access_plist(hid_t fapl_id) TEST_ERROR /* Reset the raw data files */ - if(reset_raw_data_files() < 0) + if(reset_raw_data_files(0) < 0) TEST_ERROR /* Create the file */ - h5_fixname(FILENAME[5], fapl_id, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[5], fapl_id, filename, sizeof(filename)); if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) FAIL_STACK_ERROR @@ -1532,7 +1304,7 @@ main(void) /* Get a fapl for the old (default) file format */ fapl_id_old = h5_fileaccess(); - h5_fixname(FILENAME[0], fapl_id_old, filename, sizeof(filename)); + h5_fixname(EXT_FNAME[0], fapl_id_old, filename, sizeof(filename)); /* Copy and set up a fapl for the latest file format */ if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) @@ -1585,10 +1357,9 @@ main(void) nerrors += test_path_absolute(current_fapl_id); nerrors += test_path_relative(current_fapl_id); nerrors += test_path_relative_cwd(current_fapl_id); - nerrors += test_path_env(current_fapl_id); /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, current_fapl_id) < 0 ? 1 : 0); + nerrors += (h5_verify_cached_stabs(EXT_FNAME, current_fapl_id) < 0 ? 1 : 0); /* Close the common file */ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR @@ -1603,7 +1374,7 @@ main(void) HDputs("All external storage tests passed."); /* Clean up files used by file set tests */ - if(h5_cleanup(FILENAME, fapl_id_old)) { + if(h5_cleanup(EXT_FNAME, fapl_id_old)) { HDremove("extern_1r.raw"); HDremove("extern_2r.raw"); HDremove("extern_3r.raw"); @@ -1630,4 +1401,3 @@ error: printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); return EXIT_FAILURE; } /* end main() */ - diff --git a/test/external_common.c b/test/external_common.c new file mode 100644 index 0000000..c3aa455 --- /dev/null +++ b/test/external_common.c @@ -0,0 +1,127 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu <songyulu@hdfgroup.org> + * April, 2019 + * + * Purpose: Private function for external.c and external_env.c + */ + +#include "external_common.h" + + +/*------------------------------------------------------------------------- + * Function: reset_raw_data_files + * + * Purpose: Resets the data in the raw data files for tests that + * perform dataset I/O on a set of files. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * February 2016 + * + *------------------------------------------------------------------------- + */ +herr_t +reset_raw_data_files(int is_env) +{ + int fd = 0; /* external file descriptor */ + size_t i, j; /* iterators */ + hssize_t n; /* bytes of I/O */ + char filename[1024]; /* file name */ + int data[PART_SIZE]; /* raw data buffer */ + uint8_t *garbage = NULL; /* buffer of garbage data */ + size_t garbage_count; /* size of garbage buffer */ + size_t garbage_bytes; /* # of garbage bytes written to file */ + + /* Set up garbage buffer */ + garbage_count = N_EXT_FILES * GARBAGE_PER_FILE; + if(NULL == (garbage = (uint8_t *)HDcalloc(garbage_count, sizeof(uint8_t)))) + goto error; + for(i = 0; i < garbage_count; i++) + garbage[i] = 0xFF; + + /* The *r files are pre-filled with data and are used to + * verify that read operations work correctly. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + if(is_env) + HDsprintf(filename, "extern_env_%lur.raw", (unsigned long)i + 1); + else + HDsprintf(filename, "extern_%lur.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Fill array with data */ + for(j = 0; j < PART_SIZE; j++) { + data[j] = (int)(i * 25 + j); + } /* end for */ + + /* Write raw data to the file. */ + n = HDwrite(fd, data, sizeof(data)); + if(n != sizeof(data)) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + + /* The *w files are only pre-filled with the garbage data and are + * used to verify that write operations work correctly. The individual + * tests fill in the actual data. + */ + for(i = 0; i < N_EXT_FILES; i++) { + + /* Open file */ + if(is_env) + HDsprintf(filename, "extern_env_%luw.raw", (unsigned long)i + 1); + else + HDsprintf(filename, "extern_%luw.raw", (unsigned long)i + 1); + if((fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW)) < 0) + goto error; + + /* Write garbage data to the file. This allows us to test the + * the ability to set an offset in the raw data file. + */ + garbage_bytes = i * 10; + n = HDwrite(fd, garbage, garbage_bytes); + if(n < 0 || (size_t)n != garbage_bytes) + goto error; + + /* Close this file */ + HDclose(fd); + + } /* end for */ + HDfree(garbage); + return SUCCEED; + +error: + if(fd) + HDclose(fd); + if(garbage) + HDfree(garbage); + return FAIL; +} diff --git a/test/external_common.h b/test/external_common.h new file mode 100644 index 0000000..cc2b5fb --- /dev/null +++ b/test/external_common.h @@ -0,0 +1,50 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Raymond Lu <songyulu@hdfgroup.org> + * April, 2019 + * + * Purpose: Private function for external.c and external_env.c + */ +#ifndef _EXTERNAL_COMMON_H +#define _EXTERNAL_COMMON_H + +/* Include test header files */ +#include "h5test.h" + +static const char *EXT_FNAME[] = { + "extern_1", + "extern_2", + "extern_3", + "extern_4", + "extern_dir/file_1", + "extern_5", + NULL +}; + +static const char *EXT_ENV_FNAME[] = { + "extern_env_dir/env_file_1", + NULL +}; + +/* A similar collection of files is used for the tests that + * perform file I/O. + */ +#define N_EXT_FILES 4 +#define PART_SIZE 25 +#define TOTAL_SIZE 100 +#define GARBAGE_PER_FILE 10 + +H5TEST_DLL herr_t reset_raw_data_files(int); +#endif /* _EXTERNAL_COMMON_H */ diff --git a/test/external_env.c b/test/external_env.c new file mode 100644 index 0000000..55f68be --- /dev/null +++ b/test/external_env.c @@ -0,0 +1,213 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Tests datasets stored in external raw files. + */ +#include "external_common.h" + + +/*------------------------------------------------------------------------- + * Function: test_path_env + * + * Purpose: Test whether the value of HDF5_EXTFILE_PREFIX will overwrite + * the efile_prefix dataset access property. + * This will create an HDF5 file in a subdirectory which will + * refer to ../extern_*a.raw + * The files are then accessed by setting the HDF5_EXTFILE_PREFIX + * environment variable to "${ORIGIN}". + * The efile_prefix dataset access property is set to "someprefix", + * which will cause an error if the value is not overwritten by + * the environment variable. + * + * Return: Success: 0 + * Failure: 1 + * + * Programmer: Steffen Kiess + * March 10, 2015 + * + *------------------------------------------------------------------------- + */ +static int +test_path_env(hid_t fapl) +{ + hid_t file = -1; /* file to write to */ + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* data space */ + hid_t dapl = -1; /* dataset access property list */ + hid_t dset = -1; /* dataset */ + size_t i; /* miscellaneous counters */ + char cwdpath[1024]; /* working directory */ + char filename[1024]; /* file name */ + int part[PART_SIZE]; /* raw data buffer (partial) */ + int whole[TOTAL_SIZE]; /* raw data buffer (total) */ + hsize_t cur_size; /* current data space size */ + char buffer[1024]; /* buffer to read efile_prefix */ + + TESTING("prefix in HDF5_EXTFILE_PREFIX"); + + if(HDmkdir("extern_env_dir", (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR; + + h5_fixname(EXT_ENV_FNAME[0], fapl, filename, sizeof(filename)); + if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + FAIL_STACK_ERROR + + /* Reset the raw data files */ + if(reset_raw_data_files(1) < 0) + TEST_ERROR + + /* Create the dataset */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + FAIL_STACK_ERROR + if(NULL == HDgetcwd(cwdpath, sizeof(cwdpath))) + TEST_ERROR + for(i = 0; i < N_EXT_FILES; i++) { + HDsnprintf(filename, sizeof(filename), "..%sextern_env_%dr.raw", H5_DIR_SEPS, (int) i + 1); + if(H5Pset_external(dcpl, filename, (off_t)(i * GARBAGE_PER_FILE), (hsize_t)sizeof(part)) < 0) + FAIL_STACK_ERROR + } /* end for */ + + cur_size = TOTAL_SIZE; + if((space = H5Screate_simple(1, &cur_size, NULL)) < 0) + FAIL_STACK_ERROR + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + FAIL_STACK_ERROR + + /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ + if(H5Pset_efile_prefix(dapl, "someprefix") < 0) + FAIL_STACK_ERROR + if(H5Pget_efile_prefix(dapl, buffer, sizeof(buffer)) < 0) + FAIL_STACK_ERROR + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("efile prefix not set correctly"); + + /* Create dataset */ + if((dset = H5Dcreate2(file, "dset1", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, dapl)) < 0) + FAIL_STACK_ERROR + + /* Read the entire dataset and compare with the original */ + HDmemset(whole, 0, sizeof(whole)); + if(H5Dread(dset, H5T_NATIVE_INT, space, space, H5P_DEFAULT, whole) < 0) + FAIL_STACK_ERROR + for(i = 0; i < TOTAL_SIZE; i++) + if(whole[i] != (signed)i) + FAIL_PUTS_ERROR("Incorrect value(s) read."); + + if(H5Dclose(dset) < 0) FAIL_STACK_ERROR + if(H5Pclose(dapl) < 0) FAIL_STACK_ERROR + if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if(H5Sclose(space) < 0) FAIL_STACK_ERROR + if(H5Fclose(file) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(dapl); + H5Dclose(dset); + H5Pclose(dcpl); + H5Sclose(space); + H5Fclose(file); + } H5E_END_TRY; + return 1; +} /* end test_path_env() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Runs external dataset tests. + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + * Programmer: Robb Matzke + * Tuesday, March 3, 1998 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl_id_old = -1; /* file access properties (old format) */ + hid_t fapl_id_new = -1; /* file access properties (new format) */ + hid_t fid = -1; /* file for test_1* functions */ + hid_t gid = -1; /* group to emit diagnostics */ + unsigned latest_format; /* default or latest file format */ + int nerrors = 0; /* number of errors */ + + h5_reset(); + + /* Get a fapl for the old (default) file format */ + fapl_id_old = h5_fileaccess(); + + /* Copy and set up a fapl for the latest file format */ + if((fapl_id_new = H5Pcopy(fapl_id_old)) < 0) + FAIL_STACK_ERROR + if(H5Pset_libver_bounds(fapl_id_new, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + FAIL_STACK_ERROR + + /* Test with old & new format groups */ + for(latest_format = FALSE; latest_format <= TRUE; latest_format++) { + hid_t current_fapl_id = -1; + + /* Set the fapl for different file formats */ + if(latest_format) { + HDputs("\nTesting with the latest file format:"); + current_fapl_id = fapl_id_new; + } /* end if */ + else { + HDputs("Testing with the default file format:"); + current_fapl_id = fapl_id_old; + } /* end else */ + + nerrors += test_path_env(current_fapl_id); + } /* end for */ + + if(nerrors > 0) goto error; + + /* Close the new ff fapl. h5_cleanup will take care of the old ff fapl */ + if(H5Pclose(fapl_id_new) < 0) FAIL_STACK_ERROR + + HDputs("All external storage tests passed."); + + /* Clean up files used by file set tests */ + if(h5_cleanup(EXT_FNAME, fapl_id_old)) { + HDremove("extern_env_1r.raw"); + HDremove("extern_env_2r.raw"); + HDremove("extern_env_3r.raw"); + HDremove("extern_env_4r.raw"); + + HDremove("extern_env_1w.raw"); + HDremove("extern_env_2w.raw"); + HDremove("extern_env_3w.raw"); + HDremove("extern_env_4w.raw"); + + HDrmdir("extern_env_dir"); + } /* end if */ + + return EXIT_SUCCESS; + +error: + H5E_BEGIN_TRY { + H5Fclose(fid); + H5Pclose(fapl_id_old); + H5Pclose(fapl_id_new); + H5Gclose(gid); + } H5E_END_TRY; + nerrors = MAX(1, nerrors); + printf("%d TEST%s FAILED.\n", nerrors, 1 == nerrors ? "" : "s"); + return EXIT_FAILURE; +} /* end main() */ + diff --git a/test/gen_plist.c b/test/gen_plist.c index 68da6cc..8f38b1a 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -466,13 +466,13 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil HDassert(ret > 0); /* first call to encode returns only the size of the buffer needed */ - if((ret = H5Pencode(plist_id, NULL, &temp_size)) < 0) + if((ret = H5Pencode2(plist_id, NULL, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); temp_buf = (void *)HDmalloc(temp_size); HDassert(temp_buf); - if((ret = H5Pencode(plist_id, temp_buf, &temp_size)) < 0) + if((ret = H5Pencode2(plist_id, temp_buf, &temp_size, H5P_DEFAULT)) < 0) HDassert(ret > 0); fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); diff --git a/test/h5test.c b/test/h5test.c index 8634a4d..dba8cf7 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -115,8 +115,8 @@ const char *LIBVER_NAMES[] = { static H5E_auto2_t err_func = NULL; static herr_t h5_errors(hid_t estack, void *client_data); -static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *suffix, - char *fullname, size_t size, hbool_t nest_printf); +static char *h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, + char *fullname, size_t size, hbool_t nest_printf, hbool_t subst_for_superblock); /*------------------------------------------------------------------------- @@ -471,7 +471,33 @@ h5_test_init(void) char * h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) { - return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, FALSE)); + return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, FALSE, FALSE)); +} + + +/*------------------------------------------------------------------------- + * Function: h5_fixname_superblock + * + * Purpose: Like h5_fixname() but returns the name of the file you'd + * open to find the superblock. Useful for when you have to + * open a file with open(2) but the h5_fixname() string + * contains stuff like format strings. + * + * 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. + * + * Programmer: Dana Robinson + * Spring 2019 + * + *------------------------------------------------------------------------- + */ +char * +h5_fixname_superblock(const char *base_name, hid_t fapl_id, char *fullname, size_t size) +{ + return (h5_fixname_real(base_name, fapl_id, ".h5", fullname, size, FALSE, TRUE)); } @@ -491,7 +517,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) char * h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size) { - return (h5_fixname_real(base_name, fapl, NULL, fullname, size, FALSE)); + return (h5_fixname_real(base_name, fapl, NULL, fullname, size, FALSE, FALSE)); } @@ -517,7 +543,7 @@ h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t s char * h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size) { - return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, TRUE)); + return (h5_fixname_real(base_name, fapl, ".h5", fullname, size, TRUE, FALSE)); } @@ -545,9 +571,10 @@ h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size */ static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, - char *fullname, size_t size, hbool_t nest_printf) + char *fullname, size_t size, hbool_t nest_printf, hbool_t subst_for_superblock) { const char *prefix = NULL; + const char *env = NULL; /* HDF5_DRIVER environment variable */ char *ptr, last = '\0'; const char *suffix = _suffix; size_t i, j; @@ -565,17 +592,46 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, return NULL; if(suffix) { - if(H5FD_FAMILY == driver) - suffix = nest_printf ? "%%05d.h5" : "%05d.h5"; - else if (H5FD_MULTI == driver) - suffix = NULL; + if(H5FD_FAMILY == driver) { + if(subst_for_superblock) + suffix = "00000.h5"; + else + suffix = nest_printf ? "%%05d.h5" : "%05d.h5"; + } + else if (H5FD_MULTI == driver) { + + /* Get the environment variable, if it exists, in case + * we are using the split driver since both of those + * use the multi VFD under the hood. + */ + env = HDgetenv("HDF5_DRIVER"); +#ifdef HDF5_DRIVER + /* Use the environment variable, then the compile-time constant */ + if(!env) + env = HDF5_DRIVER; +#endif + if(!HDstrcmp(env, "split")) { + /* split VFD */ + if(subst_for_superblock) + suffix = "-m.h5"; + else + suffix = NULL; + } + else { + /* multi VFD */ + if(subst_for_superblock) + suffix = "-s.h5"; + else + 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); + isppdriver = H5P_DEFAULT != fapl && (H5FD_MPIO == driver); /* Check HDF5_NOCLEANUP environment setting. * (The #ifdef is needed to prevent compile failure in case MPI is not diff --git a/test/h5test.h b/test/h5test.h index ada52ad..448813e 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -133,6 +133,7 @@ extern "C" { H5TEST_DLL void h5_clean_files(const char *base_name[], hid_t fapl); 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); +H5TEST_DLL char *h5_fixname_superblock(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL char *h5_fixname_printf(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL hid_t h5_fileaccess(void); diff --git a/test/null_vol_connector.c b/test/null_vol_connector.c index b62b370..b78e859 100644 --- a/test/null_vol_connector.c +++ b/test/null_vol_connector.c @@ -27,16 +27,21 @@ static const H5VL_class_t null_vol_g = { 0, /* capability flags */ NULL, /* initialize */ NULL, /* terminate */ - (size_t)0, /* info size */ - NULL, /* info copy */ - NULL, /* info compare */ - NULL, /* info free */ - NULL, /* info to str */ - NULL, /* str to info */ - NULL, /* get_object */ - NULL, /* get_wrap_ctx */ - NULL, /* wrap_object */ - NULL, /* free_wrap_ctx */ + { /* info_cls */ + (size_t)0, /* size */ + NULL, /* copy */ + NULL, /* compare */ + NULL, /* free */ + NULL, /* to_str */ + NULL, /* from_str */ + }, + { /* wrap_cls */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* unwrap_object */ + NULL, /* free_wrap_ctx */ + }, { /* attribute_cls */ NULL, /* create */ NULL, /* open */ diff --git a/test/tattr.c b/test/tattr.c index 454ea71..37763da 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -2626,6 +2626,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); + unsigned use_corder; /* Track creation order or not */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -2641,7 +2642,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Pset_file_space_strategy"); } fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); if (use_min_dset_oh) CHECK(H5Pclose(fcpl), FAIL, "H5Pclose"); @@ -2656,76 +2657,92 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); - CHECK(fid, FAIL, "H5Fopen"); + CHECK(fid, H5I_INVALID_HID, "H5Fopen"); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); - CHECK(sid, FAIL, "H5Screate"); + CHECK(sid, H5I_INVALID_HID, "H5Screate"); /* need DCPL to query the group creation properties */ if (use_min_dset_oh) { dcpl = H5Pcopy(dcpl_g); - CHECK(dcpl, FAIL, "H5Pcopy"); + CHECK(dcpl, H5I_INVALID_HID, "H5Pcopy"); } else { dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + CHECK(dcpl, H5I_INVALID_HID, "H5Pcreate"); } - /* Create a dataset */ - dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); - CHECK(dataset, FAIL, "H5Dcreate2"); - /* Retrieve limits for compact/dense attribute storage */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); CHECK(ret, FAIL, "H5Pget_attr_phase_change"); - /* Close property list */ - ret = H5Pclose(dcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Using creation order or not */ + for(use_corder = FALSE; use_corder <= TRUE; use_corder++) { - /* Check on dataset's attribute storage status */ - is_dense = H5O__is_attr_dense_test(dataset); - VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); + if(use_corder) { + ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED); + CHECK(ret, FAIL, "H5Pset_attr_creation_order"); + } - /* Add attributes, until well into dense storage */ - for(u = 0; u < (max_compact * 2); u++) { - /* Create attribute */ - sprintf(attrname, "attr %02u", u); - attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Acreate2"); + /* Create a dataset */ + dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); + CHECK(dataset, H5I_INVALID_HID, "H5Dcreate2"); - /* Write data into the attribute */ - ret = H5Awrite(attr, H5T_NATIVE_UINT, &u); - CHECK(ret, FAIL, "H5Awrite"); + /* Check on dataset's attribute storage status */ + is_dense = H5O__is_attr_dense_test(dataset); + VERIFY(is_dense, FALSE, "H5O__is_attr_dense_test"); - /* Close attribute */ - ret = H5Aclose(attr); - CHECK(ret, FAIL, "H5Aclose"); + /* Add attributes, until well into dense storage */ + for(u = 0; u < (max_compact * 2); u++) { + /* Create attribute */ + sprintf(attrname, "attr %02u", u); + attr = H5Acreate2(dataset, attrname, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(attr, H5I_INVALID_HID, "H5Acreate2"); - /* Rename attribute */ - sprintf(new_attrname, "new attr %02u", u); + /* Write data into the attribute */ + ret = H5Awrite(attr, H5T_NATIVE_UINT, &u); + CHECK(ret, FAIL, "H5Awrite"); - /* Rename attribute */ - ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Arename_by_name"); + /* Close attribute */ + ret = H5Aclose(attr); + CHECK(ret, FAIL, "H5Aclose"); - /* Check # of attributes */ - ret = H5Oget_info2(dataset, &oinfo, H5O_INFO_NUM_ATTRS); - CHECK(ret, FAIL, "H5Oget_info"); - VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info"); - } /* end for */ + /* Rename attribute */ + sprintf(new_attrname, "new attr %02u", u); - /* Check on dataset's attribute storage status */ - is_dense = H5O__is_attr_dense_test(dataset); - VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); + /* Rename attribute */ + ret = H5Arename_by_name(fid, DSET1_NAME, attrname, new_attrname, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Arename_by_name"); + + /* Check # of attributes */ + ret = H5Oget_info2(dataset, &oinfo, H5O_INFO_NUM_ATTRS); + CHECK(ret, FAIL, "H5Oget_info"); + VERIFY(oinfo.num_attrs, (u + 1), "H5Oget_info"); + } /* end for */ + + /* Check on dataset's attribute storage status */ + is_dense = H5O__is_attr_dense_test(dataset); + VERIFY(is_dense, TRUE, "H5O__is_attr_dense_test"); + + /* Close Dataset */ + ret = H5Dclose(dataset); + CHECK(ret, FAIL, "H5Dclose"); + + if(!use_corder) { + /* Unlink dataset with attributes */ + ret = H5Ldelete(fid, DSET1_NAME, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Ldelete"); + } + + } /* end for use_corder */ /* Close dataspace */ ret = H5Sclose(sid); CHECK(ret, FAIL, "H5Sclose"); - /* Close Dataset */ - ret = H5Dclose(dataset); - CHECK(ret, FAIL, "H5Dclose"); + /* Close property list */ + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); /* Close file */ ret = H5Fclose(fid); @@ -2734,11 +2751,11 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) /* Re-open file */ fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl); - CHECK(fid, FAIL, "H5Fopen"); + CHECK(fid, H5I_INVALID_HID, "H5Fopen"); /* Open dataset */ dataset = H5Dopen2(fid, DSET1_NAME, H5P_DEFAULT); - CHECK(dataset, FAIL, "H5Dopen2"); + CHECK(dataset, H5I_INVALID_HID, "H5Dopen2"); /* Verify renamed attributes */ for(u = 0; u < (max_compact * 2); u++) { @@ -2747,7 +2764,7 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) /* Open attribute */ sprintf(attrname, "new attr %02u", u); attr = H5Aopen(dataset, attrname, H5P_DEFAULT); - CHECK(attr, FAIL, "H5Aopen"); + CHECK(attr, H5I_INVALID_HID, "H5Aopen"); /* Read data from the attribute */ ret = H5Aread(attr, H5T_NATIVE_UINT, &value); diff --git a/test/testexternal_env.sh.in b/test/testexternal_env.sh.in new file mode 100644 index 0000000..3cc140d --- /dev/null +++ b/test/testexternal_env.sh.in @@ -0,0 +1,42 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external file with environment variable: HDF5_EXTFILE_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for external file with HDF5_EXTFILE_PREFIX +echo "Testing external file with HDF5_EXTFILE_PREFIX" +TEST_NAME=external_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_EXTFILE_PREFIX=\${ORIGIN}" # The environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_EXTFILE_PREFIX PASSED" + else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_EXTFILE_PREFIX test***" +fi +exit $nerrors diff --git a/test/testvds_env.sh.in b/test/testvds_env.sh.in new file mode 100644 index 0000000..894e52e --- /dev/null +++ b/test/testvds_env.sh.in @@ -0,0 +1,44 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# Copyright by the Board of Trustees of the University of Illinois. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# Test for external file with environment variable: HDF5_VDS_PREFIX + +srcdir=@srcdir@ + +nerrors=0 + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + +# test for VDS with HDF5_VDS_PREFIX +echo "Testing basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix" +TEST_NAME=vds_env # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +ENVCMD="env HDF5_VDS_PREFIX=\${ORIGIN}/tmp" # Set the environment variable & value +UNENVCMD="unset HDF5_VDS_PREFIX" # Unset the environment variable & value +# +# Run the test +# echo "$ENVCMD $RUNSERIAL $TEST_BIN" +$ENVCMD $RUNSERIAL $TEST_BIN +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test prefix for HDF5_VDS_PREFIX PASSED" + else + nerrors="`expr $nerrors + 1`" + echo "***Error encountered for HDF5_VDS_PREFIX test***" +fi +$UNENVCMD +exit $nerrors diff --git a/test/tfile.c b/test/tfile.c index 430bc85..695d437 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1594,54 +1594,72 @@ test_file_perm2(void) ** H5Fis_accessible() API call. ** *****************************************************************/ +#define FILE_IS_ACCESSIBLE "tfile_is_accessible" static void test_file_is_accessible(const char *env_h5_drvr) { - hid_t fid; /* File opened with read-write permission */ - hid_t fcpl_id; /* File creation property list */ - hid_t fapl = -1; /* File access property list */ - int fd; /* POSIX file descriptor */ - char filename[FILENAME_LEN]; /* Filename to use */ - ssize_t nbytes; /* Number of bytes written */ - unsigned u; /* Local index variable */ - unsigned char buf[1024]; /* Buffer of data to write */ - htri_t status; /* Whether a file is an HDF5 file */ - hbool_t single_file_vfd; /* Whether VFD used is a single file */ - herr_t ret; + hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ + hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ + int fd; /* POSIX file descriptor */ + char filename[FILENAME_LEN]; /* Filename to use */ + char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ + ssize_t nbytes; /* Number of bytes written */ + unsigned u; /* Local index variable */ + unsigned char buf[1024]; /* Buffer of data to write */ + htri_t is_hdf5; /* Whether a file is an HDF5 file */ + int posix_ret; /* Return value from POSIX calls */ + herr_t ret; /* Return value from HDF5 calls */ /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files\n")); /* Get FAPL */ - fapl = h5_fileaccess(); - CHECK(fapl, FAIL, "H5Pcreate"); - h5_fixname(FILE1, fapl, filename, sizeof filename); + fapl_id = h5_fileaccess(); + CHECK(fapl_id, H5I_INVALID_HID, "H5Pcreate"); + + /* Fix up filenames + * For VFDs that create multiple files, we also need the name + * of the file with the superblock. With single-file VFDs, this + * will be equal to the one from h5_fixname(). + */ + h5_fixname(FILE_IS_ACCESSIBLE, fapl_id, filename, sizeof(filename)); + h5_fixname_superblock(FILE_IS_ACCESSIBLE, fapl_id, sb_filename, sizeof(filename)); + + /****************/ + /* Normal usage */ + /****************/ /* Create a file */ - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_accessible(filename, fapl); - VERIFY(status, TRUE, "H5Fis_accessible"); + is_hdf5 = H5Fis_accessible(filename, fapl_id); + VERIFY(is_hdf5, TRUE, "H5Fis_accessible"); + /*******************************/ + /* Non-default user block size */ + /*******************************/ - /* This test is not currently working for the family VFD */ + /* This test is not currently working for the family VFD. + * There are failures when creating files with userblocks. + */ if(0 != HDstrcmp(env_h5_drvr, "family")) { /* Create a file creation property list with a non-default user block size */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl_id, FAIL, "H5Pcreate"); + CHECK(fcpl_id, H5I_INVALID_HID, "H5Pcreate"); ret = H5Pset_userblock(fcpl_id, (hsize_t)2048); CHECK(ret, FAIL, "H5Pset_userblock"); /* Create file with non-default user block */ - fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl); - CHECK(fid, FAIL, "H5Fcreate"); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Release file-creation property list */ ret = H5Pclose(fcpl_id); @@ -1652,37 +1670,56 @@ test_file_is_accessible(const char *env_h5_drvr) CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_accessible(filename, fapl); - VERIFY(status, TRUE, "H5Fis_accessible"); + is_hdf5 = H5Fis_accessible(filename, fapl_id); + VERIFY(is_hdf5, TRUE, "H5Fis_accessible"); } /* end if */ + /***********************/ + /* EMPTY non-HDF5 file */ + /***********************/ - /* This test only works for VFDs with a single file */ - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); - if(single_file_vfd) { - /* Create non-HDF5 file and check it */ - fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); - CHECK(fd, FAIL, "HDopen"); + /* Create non-HDF5 file and check it */ + fd = HDopen(sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + CHECK(fd, (-1), "HDopen"); - /* Initialize information to write */ - for (u=0; u<1024; u++) - buf[u]=(unsigned char)u; + /* Close the file */ + posix_ret = HDclose(fd); + CHECK(posix_ret, (-1), "HDclose"); - /* Write some information */ - nbytes = HDwrite(fd, buf, (size_t)1024); - VERIFY(nbytes, 1024, "HDwrite"); + /* Verify that the file is NOT an HDF5 file */ + is_hdf5 = H5Fis_accessible(filename, fapl_id); + VERIFY(is_hdf5, FALSE, "H5Fis_accessible (empty non-HDF5 file)"); - /* Close the file */ - ret = HDclose(fd); - CHECK(ret, FAIL, "HDclose"); + /***************************/ + /* Non-empty non-HDF5 file */ + /***************************/ - /* Verify that the file is not an HDF5 file */ - status = H5Fis_accessible(filename, fapl); - VERIFY(status, FALSE, "H5Fis_accessible"); - } /* end if */ + /* Create non-HDF5 file and check it */ + fd = HDopen(sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + CHECK(fd, (-1), "HDopen"); + + /* Initialize information to write */ + for (u = 0; u < 1024; u++) + buf[u]=(unsigned char)u; + + /* Write some information */ + nbytes = HDwrite(fd, buf, (size_t)1024); + VERIFY(nbytes, 1024, "HDwrite"); + + /* Close the file */ + posix_ret = HDclose(fd); + CHECK(posix_ret, (-1), "HDclose"); + + /* Verify that the file is not an HDF5 file */ + is_hdf5 = H5Fis_accessible(filename, fapl_id); + VERIFY(is_hdf5, FALSE, "H5Fis_accessible (non-HDF5 file)"); + + + /* Clean up files */ + h5_delete_test_file(filename, fapl_id); /* Close property list */ - ret = H5Pclose(fapl); + ret = H5Pclose(fapl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end test_file_is_accessible() */ @@ -1697,70 +1734,97 @@ test_file_is_accessible(const char *env_h5_drvr) *****************************************************************/ #ifndef H5_NO_DEPRECATED_SYMBOLS static void -test_file_ishdf5(void) +test_file_ishdf5(const char *env_h5_drvr) { - hid_t file; /* File opened with read-write permission */ - hid_t fcpl; /* File creation property list */ - hid_t fapl = -1; /* File access property list */ - int fd; /* File Descriptor */ - char filename[FILENAME_LEN]; /* Filename to use */ - ssize_t nbytes; /* Number of bytes written */ - unsigned u; /* Local index variable */ - unsigned char buf[1024]; /* Buffer of data to write */ - htri_t status; /* Whether a file is an HDF5 file */ - herr_t ret; + hid_t fid = H5I_INVALID_HID; /* File opened with read-write permission */ + hid_t fcpl_id = H5I_INVALID_HID; /* File creation property list */ + hid_t fapl_id = H5I_INVALID_HID; /* File access property list */ + int fd; /* POSIX file descriptor */ + char filename[FILENAME_LEN]; /* Filename to use */ + char sb_filename[FILENAME_LEN]; /* Name of file w/ superblock */ + ssize_t nbytes; /* Number of bytes written */ + unsigned u; /* Local index variable */ + unsigned char buf[1024]; /* Buffer of data to write */ + htri_t is_hdf5; /* Whether a file is an HDF5 file */ + int posix_ret; /* Return value from POSIX calls */ + herr_t ret; /* Return value from HDF5 calls */ /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files (using deprecated H5Fis_hdf5() call)\n")); /* Get FAPL */ - fapl = h5_fileaccess(); - CHECK(fapl, FAIL, "H5Pcreate"); - h5_fixname(FILE1, fapl, filename, sizeof filename); + fapl_id = h5_fileaccess(); + CHECK(fapl_id, H5I_INVALID_HID, "H5Pcreate"); + + /* Fix up filenames + * For VFDs that create multiple files, we also need the name + * of the file with the superblock. With single-file VFDs, this + * will be equal to the one from h5_fixname(). + */ + h5_fixname(FILE_IS_ACCESSIBLE, fapl_id, filename, sizeof(filename)); + h5_fixname_superblock(FILE_IS_ACCESSIBLE, fapl_id, sb_filename, sizeof(filename)); + + /****************/ + /* Normal usage */ + /****************/ /* Create a file */ - file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); - CHECK(file, FAIL, "H5Fcreate"); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); /* Close file */ - ret = H5Fclose(file); + ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_hdf5(filename); - VERIFY(status, TRUE, "H5Fis_hdf5"); + is_hdf5 = H5Fis_hdf5(sb_filename); + VERIFY(is_hdf5, TRUE, "H5Fis_hdf5"); + /*******************************/ + /* Non-default user block size */ + /*******************************/ - /* Create a file creation property list with a non-default user block size */ - fcpl = H5Pcreate(H5P_FILE_CREATE); - CHECK(fcpl, FAIL, "H5Pcreate"); + /* This test is not currently working for the family VFD. + * There are failures when creating files with userblocks. + */ + if(0 != HDstrcmp(env_h5_drvr, "family")) { + /* Create a file creation property list with a non-default user block size */ + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK(fcpl_id, H5I_INVALID_HID, "H5Pcreate"); - ret = H5Pset_userblock(fcpl, (hsize_t)2048); - CHECK(ret, FAIL, "H5Pset_userblock"); + ret = H5Pset_userblock(fcpl_id, (hsize_t)2048); + CHECK(ret, FAIL, "H5Pset_userblock"); - /* Create file with non-default user block */ - file = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl, fapl); - CHECK(file, FAIL, "H5Fcreate"); + /* Create file with non-default user block */ + fid = H5Fcreate(filename, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK(fid, H5I_INVALID_HID, "H5Fcreate"); - /* Release file-creation property list */ - ret = H5Pclose(fcpl); - CHECK(ret, FAIL, "H5Pclose"); + /* Release file creation property list */ + ret = H5Pclose(fcpl_id); + CHECK(ret, FAIL, "H5Pclose"); - /* Close file */ - ret = H5Fclose(file); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(fid); + CHECK(ret, FAIL, "H5Fclose"); - /* Verify that the file is an HDF5 file */ - status = H5Fis_hdf5(filename); - VERIFY(status, TRUE, "H5Fis_hdf5"); + /* Verify that the file is an HDF5 file */ + is_hdf5 = H5Fis_hdf5(sb_filename); + VERIFY(is_hdf5, TRUE, "H5Fis_hdf5"); + } /* end if */ + /***************************/ + /* Non-empty non-HDF5 file */ + /***************************/ - /* Create non-HDF5 file and check it */ - fd = HDopen(filename, O_RDWR|O_CREAT|O_TRUNC, H5_POSIX_CREATE_MODE_RW); - CHECK(fd, FAIL, "HDopen"); + /* Create non-HDF5 file. Use the calculated superblock + * filename to avoid the format strings that will make + * open(2) sad. + */ + fd = HDopen(sb_filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); + CHECK(fd, (-1), "HDopen"); /* Initialize information to write */ - for(u=0; u<1024; u++) + for(u = 0; u < 1024; u++) buf[u]=(unsigned char)u; /* Write some information */ @@ -1768,15 +1832,19 @@ test_file_ishdf5(void) VERIFY(nbytes, 1024, "HDwrite"); /* Close the file */ - ret = HDclose(fd); - CHECK(ret, FAIL, "HDclose"); + posix_ret = HDclose(fd); + CHECK(posix_ret, (-1), "HDclose"); /* Verify that the file is not an HDF5 file */ - status = H5Fis_hdf5(filename); - VERIFY(status, FALSE, "H5Fis_hdf5"); + is_hdf5 = H5Fis_hdf5(sb_filename); + VERIFY(is_hdf5, FALSE, "H5Fis_hdf5"); + + + /* Clean up files */ + h5_delete_test_file(filename, fapl_id); /* Close property list */ - ret = H5Pclose(fapl); + ret = H5Pclose(fapl_id); CHECK(ret, FAIL, "H5Pclose"); } /* end test_file_ishdf5() */ @@ -1921,6 +1989,7 @@ test_file_open_overlap(void) hid_t sid; ssize_t nobjs; /* # of open objects */ unsigned intent; + unsigned long fileno1, fileno2; /* File number */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -1939,6 +2008,19 @@ test_file_open_overlap(void) CHECK(ret, FAIL, "H5Fget_intent"); VERIFY(intent, H5F_ACC_RDWR, "H5Fget_intent"); + /* Check the file numbers */ + fileno1 = 0; + ret = H5Fget_fileno(fid1, &fileno1); + CHECK(ret, FAIL, "H5Fget_fileno"); + fileno2 = 0; + ret = H5Fget_fileno(fid2, &fileno2); + CHECK(ret, FAIL, "H5Fget_fileno"); + VERIFY(fileno1, fileno2, "H5Fget_fileno"); + + /* Check that a file number pointer of NULL is ignored */ + ret = H5Fget_fileno(fid1, NULL); + CHECK(ret, FAIL, "H5Fget_fileno"); + /* Create a group in file */ gid = H5Gcreate2(fid1, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(gid, FAIL, "H5Gcreate2"); @@ -2652,6 +2734,7 @@ test_userblock_file_size(void) hid_t fcpl2_id; hsize_t dims[2] = {3, 4}; hsize_t filesize1, filesize2, filesize; + unsigned long fileno1, fileno2; /* File number */ herr_t ret; /* Generic return value */ /* Output message about test being performed */ @@ -2669,6 +2752,15 @@ test_userblock_file_size(void) file2_id = H5Fcreate(FILE2, H5F_ACC_TRUNC, fcpl2_id, H5P_DEFAULT); CHECK(file2_id, FAIL, "H5Fcreate"); + /* Check the file numbers */ + fileno1 = 0; + ret = H5Fget_fileno(file1_id, &fileno1); + CHECK(ret, FAIL, "H5Fget_fileno"); + fileno2 = 0; + ret = H5Fget_fileno(file2_id, &fileno2); + CHECK(ret, FAIL, "H5Fget_fileno"); + CHECK(fileno1, fileno2, "H5Fget_fileno"); + /* Create groups */ group1_id = H5Gcreate2(file1_id, GROUP1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(group1_id, FAIL, "H5Gcreate2"); @@ -7513,7 +7605,6 @@ test_deprec(void) void test_file(void) { - hbool_t single_file_vfd; /* Whether VFD used is a single file */ const char *env_h5_drvr; /* File Driver value from environment */ /* Output message about test being performed */ @@ -7523,7 +7614,6 @@ test_file(void) env_h5_drvr = HDgetenv("HDF5_DRIVER"); if(env_h5_drvr == NULL) env_h5_drvr = "nomatch"; - single_file_vfd = (hbool_t)(HDstrcmp(env_h5_drvr, "split") && HDstrcmp(env_h5_drvr, "multi") && HDstrcmp(env_h5_drvr, "family")); test_file_create(); /* Test file creation(also creation templates)*/ test_file_open(); /* Test file opening */ @@ -7569,10 +7659,7 @@ test_file(void) test_incr_filesize(); /* Test H5Fincrement_filesize() and H5Fget_eoa() */ test_min_dset_ohdr(); /* Test datset object header minimization */ #ifndef H5_NO_DEPRECATED_SYMBOLS - if(single_file_vfd) - test_file_ishdf5(); /* Test detecting HDF5 files correctly */ - else - MESSAGE(5, ("Skipping testing detection of HDF5 Files (using deprecated H5Fis_hdf5() call for non-single file VFDs)\n")); + test_file_ishdf5(env_h5_drvr); /* Test detecting HDF5 files correctly */ test_deprec(); /* Test deprecated routines */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ } /* test_file() */ diff --git a/test/th5s.c b/test/th5s.c index 07d31ed..6632a4c 100644 --- a/test/th5s.c +++ b/test/th5s.c @@ -90,7 +90,21 @@ struct space4_struct { unsigned u; float f; char c2; - } space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ +} space4_data={'v',987123,-3.14F,'g'}; /* Test data for 4th dataspace */ + +/* + * Testing configuration defines used by: + * test_h5s_encode_regular_hyper() + * test_h5s_encode_irregular_hyper() + * test_h5s_encode_points() + */ +#define CONFIG_8 1 +#define CONFIG_16 2 +#define CONFIG_32 3 +#define POWER8 256 /* 2^8 */ +#define POWER16 65536 /* 2^16 */ +#define POWER32 4294967296 /* 2^32 */ + /**************************************************************** ** @@ -1163,27 +1177,30 @@ test_h5s_zero_dim(void) ** ** test_h5s_encode(): Test H5S (dataspace) encoding and decoding. ** +** Note: See "RFC: H5Sencode/H5Sdecode Format Change". +** ****************************************************************/ static void -test_h5s_encode(void) +test_h5s_encode(H5F_libver_t low, H5F_libver_t high) { - hid_t sid1, sid2, sid3; /* Dataspace ID */ - hid_t decoded_sid1, decoded_sid2, decoded_sid3; - int rank; /* Logical rank of dataspace */ - hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; - size_t sbuf_size=0, null_size=0, scalar_size=0; - unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - hsize_t start[] = {0, 0, 0}; - hsize_t stride[] = {2, 5, 3}; - hsize_t count[] = {2, 2, 2}; - hsize_t block[] = {1, 3, 1}; - H5S_sel_type sel_type; - H5S_class_t space_type; - hssize_t nblocks; - hid_t ret_id; /* Generic hid_t return value */ - herr_t ret; /* Generic return value */ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hid_t fapl = -1; /* File access property list ID */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size=0, null_size=0, scalar_size=0; + unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspace Encoding and Decoding\n")); @@ -1192,26 +1209,40 @@ test_h5s_encode(void) * Test encoding and decoding of simple dataspace and hyperslab selection. *------------------------------------------------------------------------- */ + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Set the hyperslab selection */ ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Encode simple data space in a buffer */ - ret = H5Sencode(sid1, NULL, &sbuf_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode simple data space in a buffer with the fapl setting */ + ret = H5Sencode2(sid1, NULL, &sbuf_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); - if(sbuf_size>0) + if(sbuf_size>0) { sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "HDcalloc"); + } /* Try decoding bogus buffer */ H5E_BEGIN_TRY { - ret_id = H5Sdecode(sbuf); + ret_id = H5Sdecode(sbuf); } H5E_END_TRY; VERIFY(ret_id, FAIL, "H5Sdecode"); - ret = H5Sencode(sid1, sbuf, &sbuf_size); + /* Encode the simple data space in a buffer with the fapl setting */ + ret = H5Sencode2(sid1, sbuf, &sbuf_size, fapl); CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ @@ -1224,22 +1255,26 @@ test_h5s_encode(void) VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, "H5Sget_simple_extent_npoints"); + /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + /* Retrieve and verify the dataspace dimensions */ rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, "H5Sget_simple_extent_dims"); - /* Verify hyperslabe selection */ + /* Verify the type of dataspace selection */ sel_type = H5Sget_select_type(decoded_sid1); VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type"); + /* Verify the number of hyperslab blocks */ nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + /* Close the dataspaces */ ret = H5Sclose(sid1); CHECK(ret, FAIL, "H5Sclose"); @@ -1254,23 +1289,27 @@ test_h5s_encode(void) CHECK(sid2, FAIL, "H5Screate"); /* Encode null data space in a buffer */ - ret = H5Sencode(sid2, NULL, &null_size); + ret = H5Sencode2(sid2, NULL, &null_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(null_size>0) + if(null_size>0) { null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + CHECK(null_sbuf, NULL, "HDcalloc"); + } - ret = H5Sencode(sid2, null_sbuf, &null_size); - CHECK(ret, FAIL, "H5Sencode"); + /* Encode the null data space in the buffer */ + ret = H5Sencode2(sid2, null_sbuf, &null_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); /* Decode from the dataspace buffer and return an object handle */ decoded_sid2=H5Sdecode(null_sbuf); CHECK(decoded_sid2, FAIL, "H5Sdecode"); - /* Verify decoded dataspace */ + /* Verify the decoded dataspace type */ space_type = H5Sget_simple_extent_type(decoded_sid2); VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type"); + /* Close the dataspaces */ ret = H5Sclose(sid2); CHECK(ret, FAIL, "H5Sclose"); @@ -1286,16 +1325,211 @@ test_h5s_encode(void) CHECK(sid3, FAIL, "H5Screate_simple"); /* Encode scalar data space in a buffer */ - ret = H5Sencode(sid3, NULL, &scalar_size); + ret = H5Sencode2(sid3, NULL, &scalar_size, fapl); CHECK(ret, FAIL, "H5Sencode"); - if(scalar_size>0) + if(scalar_size>0) { scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + CHECK(scalar_buf, NULL, "HDcalloc"); + } + + /* Encode the scalar data space in the buffer */ + ret = H5Sencode2(sid3, scalar_buf, &scalar_size, fapl); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid3=H5Sdecode(scalar_buf); + CHECK(decoded_sid3, FAIL, "H5Sdecode"); + + /* Verify extent type */ + space_type = H5Sget_simple_extent_type(decoded_sid3); + VERIFY(space_type, H5S_SCALAR, "H5Sget_simple_extent_type"); + + /* Verify decoded dataspace */ + n = H5Sget_simple_extent_npoints(decoded_sid3); + CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + + /* Retrieve and verify the dataspace rank */ + rank = H5Sget_simple_extent_ndims(decoded_sid3); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, 0, "H5Sget_simple_extent_ndims"); - ret = H5Sencode(sid3, scalar_buf, &scalar_size); + /* Close the dataspaces */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close the file access property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Release resources */ + if(sbuf) + HDfree(sbuf); + if(null_sbuf) + HDfree(null_sbuf); + if(scalar_buf) + HDfree(scalar_buf); +} /* test_h5s_encode() */ + +#ifndef H5_NO_DEPRECATED_SYMBOLS + +/**************************************************************** +** +** test_h5s_encode(): Test H5S (dataspace) encoding and decoding. +** +****************************************************************/ +static void +test_h5s_encode1(void) +{ + hid_t sid1, sid2, sid3; /* Dataspace ID */ + hid_t decoded_sid1, decoded_sid2, decoded_sid3; + int rank; /* Logical rank of dataspace */ + hsize_t dims1[] = {SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}; + size_t sbuf_size=0, null_size=0, scalar_size=0; + unsigned char *sbuf=NULL, *null_sbuf=NULL, *scalar_buf=NULL; + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + hsize_t start[] = {0, 0, 0}; + hsize_t stride[] = {2, 5, 3}; + hsize_t count[] = {2, 2, 2}; + hsize_t block[] = {1, 3, 1}; + H5S_sel_type sel_type; + H5S_class_t space_type; + hssize_t nblocks; + hid_t ret_id; /* Generic hid_t return value */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace Encoding (H5Sencode1) and Decoding\n")); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of simple dataspace and hyperslab selection. + *------------------------------------------------------------------------- + */ + /* Create the dataspace */ + sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); + CHECK(sid1, FAIL, "H5Screate_simple"); + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Encode simple data space in a buffer with the fapl setting */ + ret = H5Sencode1(sid1, NULL, &sbuf_size); + CHECK(ret, FAIL, "H5Sencode2"); + + if(sbuf_size>0) { + sbuf = (unsigned char*)HDcalloc((size_t)1, sbuf_size); + CHECK(sbuf, NULL, "HDcalloc"); + } + + /* Try decoding bogus buffer */ + H5E_BEGIN_TRY { + ret_id = H5Sdecode(sbuf); + } H5E_END_TRY; + VERIFY(ret_id, FAIL, "H5Sdecode"); + + /* Encode the simple data space in a buffer */ + ret = H5Sencode1(sid1, sbuf, &sbuf_size); CHECK(ret, FAIL, "H5Sencode"); /* Decode from the dataspace buffer and return an object handle */ + decoded_sid1=H5Sdecode(sbuf); + CHECK(decoded_sid1, FAIL, "H5Sdecode"); + + /* Verify the decoded dataspace */ + n = H5Sget_simple_extent_npoints(decoded_sid1); + CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); + VERIFY(n, SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3, + "H5Sget_simple_extent_npoints"); + + /* Retrieve and verify the dataspace rank */ + rank = H5Sget_simple_extent_ndims(decoded_sid1); + CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); + VERIFY(rank, SPACE1_RANK, "H5Sget_simple_extent_ndims"); + + /* Retrieve and verify the dataspace dimensions */ + rank = H5Sget_simple_extent_dims(decoded_sid1, tdims, NULL); + CHECK(rank, FAIL, "H5Sget_simple_extent_dims"); + VERIFY(HDmemcmp(tdims, dims1, SPACE1_RANK * sizeof(hsize_t)), 0, + "H5Sget_simple_extent_dims"); + + /* Verify the type of dataspace selection */ + sel_type = H5Sget_select_type(decoded_sid1); + VERIFY(sel_type, H5S_SEL_HYPERSLABS, "H5Sget_select_type"); + + /* Verify the number of hyperslab blocks */ + nblocks = H5Sget_select_hyper_nblocks(decoded_sid1); + VERIFY(nblocks, 2*2*2, "H5Sget_select_hyper_nblocks"); + + /* Close the dataspaces */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of null dataspace. + *------------------------------------------------------------------------- + */ + sid2 = H5Screate(H5S_NULL); + CHECK(sid2, FAIL, "H5Screate"); + + /* Encode null data space in a buffer */ + ret = H5Sencode1(sid2, NULL, &null_size); + CHECK(ret, FAIL, "H5Sencode"); + + if(null_size>0) { + null_sbuf = (unsigned char*)HDcalloc((size_t)1, null_size); + CHECK(null_sbuf, NULL, "HDcalloc"); + } + + /* Encode the null data space in the buffer */ + ret = H5Sencode1(sid2, null_sbuf, &null_size); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ + decoded_sid2=H5Sdecode(null_sbuf); + CHECK(decoded_sid2, FAIL, "H5Sdecode"); + + /* Verify the decoded dataspace type */ + space_type = H5Sget_simple_extent_type(decoded_sid2); + VERIFY(space_type, H5S_NULL, "H5Sget_simple_extent_type"); + + /* Close the dataspaces */ + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Sclose(decoded_sid2); + CHECK(ret, FAIL, "H5Sclose"); + + /*------------------------------------------------------------------------- + * Test encoding and decoding of scalar dataspace. + *------------------------------------------------------------------------- + */ + /* Create scalar dataspace */ + sid3 = H5Screate(H5S_SCALAR); + CHECK(sid3, FAIL, "H5Screate_simple"); + + /* Encode scalar data space in a buffer */ + ret = H5Sencode1(sid3, NULL, &scalar_size); + CHECK(ret, FAIL, "H5Sencode"); + + if(scalar_size>0) { + scalar_buf = (unsigned char*)HDcalloc((size_t)1, scalar_size); + CHECK(scalar_buf, NULL, "HDcalloc"); + } + + /* Encode the scalar data space in the buffer */ + ret = H5Sencode1(sid3, scalar_buf, &scalar_size); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode from the dataspace buffer and return an object handle */ decoded_sid3=H5Sdecode(scalar_buf); CHECK(decoded_sid3, FAIL, "H5Sdecode"); @@ -1308,20 +1542,551 @@ test_h5s_encode(void) CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + /* Retrieve and verify the dataspace rank */ rank = H5Sget_simple_extent_ndims(decoded_sid3); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, 0, "H5Sget_simple_extent_ndims"); + /* Close the dataspaces */ ret = H5Sclose(sid3); CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(decoded_sid3); CHECK(ret, FAIL, "H5Sclose"); - HDfree(sbuf); - HDfree(null_sbuf); - HDfree(scalar_buf); -} /* test_h5s_encode() */ + /* Release resources */ + if(sbuf) + HDfree(sbuf); + if(null_sbuf) + HDfree(null_sbuf); + if(scalar_buf) + HDfree(scalar_buf); +} /* test_h5s_encode1() */ + +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + +/**************************************************************** +** +** test_h5s_check_encoding(): +** This is the helper routine to verify that H5Sencode2() +** works as specified in the RFC for the library format setting +** in the file access property list. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +** This routine is used by: +** test_h5s_encode_regular_hyper() +** test_h5s_encode_irregular_hyper() +** test_h5s_encode_points() +** +****************************************************************/ +static herr_t +test_h5s_check_encoding(hid_t in_fapl, hid_t in_sid, + uint32_t expected_version, uint8_t expected_enc_size, hbool_t expected_to_fail) +{ + char *buf = NULL; /* Pointer to the encoded buffer */ + size_t buf_size; /* Size of the encoded buffer */ + hid_t d_sid = -1; /* The decoded dataspace ID */ + htri_t check; + hsize_t in_low_bounds[1]; /* The low bounds for the selection for in_sid */ + hsize_t in_high_bounds[1]; /* The high bounds for the selection for in_sid */ + hsize_t d_low_bounds[1]; /* The low bounds for the selection for d_sid */ + hsize_t d_high_bounds[1]; /* The high bounds for the selection for d_sid */ + herr_t ret; /* Return value */ + + /* Get buffer size for encoding with the format setting in in_fapl */ + H5E_BEGIN_TRY { + ret = H5Sencode2(in_sid, NULL, &buf_size, in_fapl); + } H5E_END_TRY + + if(expected_to_fail) { + VERIFY(ret, FAIL, "H5Screate_simple"); + } else { + + CHECK(ret, FAIL, "H5Sencode2"); + + /* Allocate the buffer for encoding */ + buf = (char *)HDmalloc(buf_size); + CHECK(buf, NULL, "H5Dmalloc"); + + /* Encode according to the setting in in_fapl */ + ret = H5Sencode2(in_sid, buf, &buf_size, in_fapl); + CHECK(ret, FAIL, "H5Sencode2"); + + /* Decode the buffer */ + d_sid = H5Sdecode(buf); + CHECK(d_sid, FAIL, "H5Sdecode"); + + /* Verify the number of selected points for in_sid and d_sid */ + VERIFY(H5Sget_select_npoints(in_sid), H5Sget_select_npoints(d_sid), "Compare npoints"); + + /* Verify if the two dataspace selections (in_sid, d_sid) are the same shape */ + check = H5S__select_shape_same_test(in_sid, d_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); + + /* Compare the starting/ending coordinates of the bounding box for in_sid and d_sid */ + ret = H5Sget_select_bounds(in_sid, in_low_bounds, in_high_bounds); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + ret = H5Sget_select_bounds(d_sid, d_low_bounds, d_high_bounds); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(in_low_bounds[0], d_low_bounds[0], "Compare selection low bounds"); + VERIFY(in_high_bounds[0], d_high_bounds[0], "Compare selection high bounds"); + + /* + * See "RFC: H5Sencode/H5Sdeocde Format Change" for the verification of: + * H5S_SEL_POINTS: + * --the expected version for point selection info + * --the expected encoded size (version 2 points selection info) + * H5S_SEL_HYPERSLABS: + * --the expected version for hyperslab selection info + * --the expected encoded size (version 3 hyperslab selection info) + */ + + if(H5Sget_select_type(in_sid) == H5S_SEL_POINTS) { + + /* Verify the version */ + VERIFY((uint32_t)buf[35], expected_version, "Version for point selection"); + + /* Verify the encoded size for version 2 */ + if(expected_version == 2) + VERIFY((uint8_t)buf[39], expected_enc_size, "Encoded size of point selection info"); + } + + if(H5Sget_select_type(in_sid) == H5S_SEL_HYPERSLABS) { + + /* Verify the version */ + VERIFY((uint32_t)buf[35], expected_version, "Version for hyperslab selection info"); + + /* Verify the encoded size for version 3 */ + if(expected_version == 3) + VERIFY((uint8_t)buf[40], expected_enc_size, "Encoded size of selection info"); + + } /* hyperslab selection */ + + ret = H5Sclose(d_sid); + CHECK(ret, FAIL, "H5Sclose"); + if(buf) + HDfree(buf); + + } + + return(0); + +} /* test_h5s_check_encoding */ + +/**************************************************************** +** +** test_h5s_encode_regular_hyper(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for regular hyperslabs. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_regular_hyper(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + unsigned config; /* Testing configuration */ + unsigned unlim; /* H5S_UNLIMITED setting or not */ + herr_t ret; /* Generic return value */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of regular hyperslabs\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Testing with each configuration */ + for(config = CONFIG_16; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; + + /* Testing with unlimited or not */ + for(unlim = 0; unlim <= 1; unlim++) { + start = 0; + count = unlim? H5S_UNLIMITED : 2; + + if((high <= H5F_LIBVER_V18) && + (unlim || config == CONFIG_32)) + expected_to_fail = TRUE; + + if(low >= H5F_LIBVER_V112) + expected_version = 3; + else if(config == CONFIG_16 && !unlim) + expected_version = 1; + else + expected_version = 2; + + /* test 1 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = 4; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = 4; + expected_enc_size = expected_version == 3 ? 4 : 8; + + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 2 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = POWER16 - 2; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = POWER32 - 2; + expected_enc_size = expected_version == 3 ? 4 : 8; + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 3 */ + switch(config) { + case CONFIG_16: + stride = POWER16 - 1; + block = POWER16 - 1; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32 - 1; + block = POWER32 - 1; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 4 */ + switch(config) { + case CONFIG_16: + stride = POWER16; + block = POWER16 - 2; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32; + block = POWER32 - 2; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } /* end switch */ + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 5 */ + switch(config) { + case CONFIG_16: + stride = POWER16; + block = 1; + expected_enc_size = 4; + break; + case CONFIG_32: + stride = POWER32; + block = 1; + expected_enc_size = 8; + break; + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Verify the version and encoded size expected for this configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + } /* for unlim */ + } /* for config */ + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + +} /* test_h5s_encode_regular_hyper() */ + +/**************************************************************** +** +** test_h5s_encode_irregular_hyper(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for irregular hyperslabs. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_irregular_hyper(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimension size */ + unsigned num_dsets = 513; /* Used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t start, stride, count, block; /* Selection info */ + htri_t is_regular; /* Is this a regular hyperslab */ + unsigned config; /* Testing configuration */ + herr_t ret; /* Generic return value */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of irregular hyperslabs\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* Testing with each configuration */ + for(config = CONFIG_8; config <= CONFIG_32; config++) { + hbool_t expected_to_fail = FALSE; /* Whether H5Sencode2 is expected to fail */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size for selection info */ + + start = 0; + count = 2; + block = 4; + + /* H5Sencode2 is expected to fail for library v110 and below + when the selection exceeds the 32 bits integer limit */ + if(high <= H5F_LIBVER_V110 && config == CONFIG_32) + expected_to_fail = TRUE; + + if(low >= H5F_LIBVER_V112 || config == CONFIG_32) + expected_version = 3; + else + expected_version = 1; + + switch(config) { + case CONFIG_8: + stride = POWER8 - 2; + break; + + case CONFIG_16: + stride = POWER16 - 2; + break; + + case CONFIG_32: + stride = POWER32 - 2; + break; + + default: + HDassert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_SET, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + start = 8; + count = 5; + block = 2; + + switch(config) { + case CONFIG_8: + stride = POWER8; + expected_enc_size = expected_version == 3 ? 2 : 4; + break; + + case CONFIG_16: + stride = POWER16; + expected_enc_size = 4; + break; + + case CONFIG_32: + stride = POWER32; + expected_enc_size = 8; + break; + + default: + assert(0); + break; + } + + /* Set the hyperslab selection */ + ret = H5Sselect_hyperslab(sid, H5S_SELECT_OR, &start, &stride, &count, &block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); + + /* Should be irregular hyperslab */ + is_regular = H5Sis_regular_hyperslab(sid); + VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + } /* for config */ + + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_irregular_hyper() */ + +/**************************************************************** +** +** test_h5s_encode_points(): +** This test verifies that H5Sencode2() works as specified in +** the RFC for point selection. +** See "RFC: H5Sencode/H5Sdeocde Format Change". +** +****************************************************************/ +static void +test_h5s_encode_points(H5F_libver_t low, H5F_libver_t high) +{ + hid_t fapl = -1; /* File access property list ID */ + hid_t sid; /* Dataspace ID */ + hsize_t numparticles = 8388608; /* Used to calculate dimenion size */ + unsigned num_dsets = 513; /* used to calculate dimension size */ + hsize_t total_particles = numparticles * num_dsets; + hsize_t vdsdims[1] = {total_particles}; /* Dimension size */ + hsize_t coord[4]; /* The point coordinates */ + herr_t ret; /* Generic return value */ + hbool_t expected_to_fail = FALSE; /* Expected to fail or not */ + uint32_t expected_version = 0; /* Expected version for selection info */ + uint8_t expected_enc_size = 0; /* Expected encoded size of selection info */ + + /* Output message about test being performed */ + MESSAGE(5, ("Testing Dataspace encoding of points selection\n")); + + /* Create the file access property list */ + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Set the low/high bounds in the fapl */ + ret = H5Pset_libver_bounds(fapl, low, high); + CHECK(ret, FAIL, "H5Pset_libver_bounds"); + + /* Create the dataspace */ + sid = H5Screate_simple(1, vdsdims, NULL); + CHECK(sid, FAIL, "H5Screate_simple"); + + /* test 1 */ + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER16; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + expected_to_fail = FALSE; + expected_enc_size = 4; + expected_version = 1; + + if(low >= H5F_LIBVER_V112) + expected_version = 2; + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 2 */ + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER32 - 1; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Expected result same as test 1 */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* test 3 */ + if(high <= H5F_LIBVER_V110) + expected_to_fail = TRUE; + + if(high >= H5F_LIBVER_V112) { + expected_version = 2; + expected_enc_size = 8; + } + + coord[0] = 5; + coord[1] = 15; + coord[2] = POWER32 + 1; + coord[3] = 19; + ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + /* Verify the version and encoded size expected for the configuration */ + ret = test_h5s_check_encoding(fapl, sid, expected_version, expected_enc_size, expected_to_fail); + CHECK(ret, FAIL, "test_h5s_check_encoding"); + + /* Close the dataspace */ + ret = H5Sclose(sid); + CHECK(ret, FAIL, "H5Sclose"); + +} /* test_h5s_encode_points() */ /**************************************************************** ** @@ -1362,7 +2127,7 @@ test_h5s_encode_length(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Encode simple data space in a buffer */ - ret = H5Sencode(sid, NULL, &sbuf_size); + ret = H5Sencode2(sid, NULL, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); /* Allocate the buffer */ @@ -1372,7 +2137,7 @@ test_h5s_encode_length(void) } /* Encode the dataspace */ - ret = H5Sencode(sid, sbuf, &sbuf_size); + ret = H5Sencode2(sid, sbuf, &sbuf_size, H5P_DEFAULT); CHECK(ret, FAIL, "H5Sencode"); /* Verify that length stored at this location in the buffer is correct */ @@ -1400,7 +2165,6 @@ test_h5s_encode_length(void) } /* test_h5s_encode_length() */ - /**************************************************************** ** ** test_h5s_scalar_write(): Test scalar H5S (dataspace) writing code. @@ -1409,14 +2173,14 @@ test_h5s_encode_length(void) static void test_h5s_scalar_write(void) { - hid_t fid1; /* HDF5 File IDs */ - hid_t dataset; /* Dataset ID */ - hid_t sid1; /* Dataspace ID */ - int rank; /* Logical rank of dataspace */ - hsize_t tdims[4]; /* Dimension array to test with */ - hssize_t n; /* Number of dataspace elements */ - H5S_class_t ext_type; /* Extent type */ - herr_t ret; /* Generic return value */ + hid_t fid1; /* HDF5 File IDs */ + hid_t dataset; /* Dataset ID */ + hid_t sid1; /* Dataspace ID */ + int rank; /* Logical rank of dataspace */ + hsize_t tdims[4]; /* Dimension array to test with */ + hssize_t n; /* Number of dataspace elements */ + H5S_class_t ext_type; /* Extent type */ + herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Scalar Dataspace Manipulation during Writing\n")); @@ -1435,14 +2199,17 @@ test_h5s_scalar_write(void) sid1 = H5Screate_simple(SPACE3_RANK, NULL, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); + /* Retrieve the number of elements in the dataspace selection */ n = H5Sget_simple_extent_npoints(sid1); CHECK(n, FAIL, "H5Sget_simple_extent_npoints"); VERIFY(n, 1, "H5Sget_simple_extent_npoints"); + /* Get the dataspace rank */ rank = H5Sget_simple_extent_ndims(sid1); CHECK(rank, FAIL, "H5Sget_simple_extent_ndims"); VERIFY(rank, SPACE3_RANK, "H5Sget_simple_extent_ndims"); + /* Get the dataspace dimension sizes */ rank = H5Sget_simple_extent_dims(sid1, tdims, NULL); VERIFY(rank, 0, "H5Sget_simple_extent_dims"); @@ -1454,6 +2221,7 @@ test_h5s_scalar_write(void) dataset = H5Dcreate2(fid1, "Dataset1", H5T_NATIVE_UINT, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); + /* Write to the dataset */ ret = H5Dwrite(dataset, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, &space3_data); CHECK(ret, FAIL, "H5Dwrite"); @@ -1468,7 +2236,7 @@ test_h5s_scalar_write(void) /* Close file */ ret = H5Fclose(fid1); CHECK(ret, FAIL, "H5Fclose"); -} /* test_h5s_scalar_write() */ +} /* test_h5s_scalar_write() */ /**************************************************************** ** @@ -2587,16 +3355,38 @@ test_versionbounds(void) void test_h5s(void) { + H5F_libver_t low, high; /* Low and high bounds */ + /* Output message about test being performed */ MESSAGE(5, ("Testing Dataspaces\n")); - test_h5s_basic(); /* Test basic H5S code */ - test_h5s_null(); /* Test Null dataspace H5S code */ + test_h5s_basic(); /* Test basic H5S code */ + test_h5s_null(); /* Test Null dataspace H5S code */ test_h5s_zero_dim(); /* Test dataspace with zero dimension size */ - test_h5s_encode(); /* Test encoding and decoding */ - test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + test_h5s_encode(low, high); /* Test encoding and decoding */ + test_h5s_encode_regular_hyper(low, high); /* Test encoding regular hyperslabs */ + test_h5s_encode_irregular_hyper(low, high); /* Test encoding irregular hyperslabs */ + test_h5s_encode_points(low, high); /* Test encoding points */ + + } /* end high bound */ + } /* end low bound */ + + test_h5s_encode_length(); /* Test version 2 hyperslab encoding length is correct */ +#ifndef H5_NO_DEPRECATED_SYMBOLS + test_h5s_encode1(); /* Test operations with old API routine (H5Sencode1) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + test_h5s_scalar_write(); /* Test scalar H5S writing code */ - test_h5s_scalar_read(); /* Test scalar H5S reading code */ + test_h5s_scalar_read(); /* Test scalar H5S reading code */ test_h5s_compound_scalar_write(); /* Test compound datatype scalar H5S writing code */ test_h5s_compound_scalar_read(); /* Test compound datatype scalar H5S reading code */ diff --git a/test/trefer.c b/test/trefer.c index 938f040..4bf9caf 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -490,16 +490,20 @@ test_reference_obj(void) ** test_reference_region(): Test basic H5R (reference) object reference code. ** Tests references to various kinds of objects ** +** Note: The libver_low/libver_high parameters are added to create the file +** with the low and high bounds setting in fapl. +** Please see the RFC for "H5Sencode/H5Sdecode Format Change". +** ****************************************************************/ static void test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) { - hid_t fid1; /* HDF5 File IDs */ + hid_t fid1; /* HDF5 File IDs */ hid_t fapl = -1; /* File access property list */ - hid_t dset1, /* Dataset ID */ + hid_t dset1, /* Dataset ID */ dset2; /* Dereferenced dataset ID */ - hid_t sid1, /* Dataspace ID #1 */ - sid2; /* Dataspace ID #2 */ + 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}; @@ -508,24 +512,24 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) hsize_t count[SPACE2_RANK]; /* Element count of hyperslab */ hsize_t block[SPACE2_RANK]; /* Block size of hyperslab */ hsize_t coord1[POINT1_NPOINTS][SPACE2_RANK]; /* Coordinates for point selection */ - hsize_t *coords; /* Coordinate buffer */ - hsize_t low[SPACE2_RANK]; /* Selection bounds */ - hsize_t high[SPACE2_RANK]; /* Selection bounds */ - hdset_reg_ref_t *wbuf, /* buffer to write to disk */ - *rbuf; /* buffer read from disk */ - hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ - uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ - *drbuf; /* Buffer for reading numeric data from disk */ - uint8_t *tu8; /* Temporary pointer to uint8 data */ - H5O_type_t obj_type; /* Type of object */ - int i, j; /* counting variables */ - hssize_t hssize_ret; /* hssize_t return value */ - htri_t tri_ret; /* htri_t return value */ - herr_t ret; /* Generic return value */ - haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ - hid_t dset_NA; /* Dataset id for undefined reference */ - hid_t space_NA; /* Dataspace id for undefined reference */ - hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ + hsize_t *coords; /* Coordinate buffer */ + hsize_t low[SPACE2_RANK]; /* Selection bounds */ + hsize_t high[SPACE2_RANK]; /* Selection bounds */ + hdset_reg_ref_t *wbuf, /* buffer to write to disk */ + *rbuf; /* buffer read from disk */ + hdset_reg_ref_t nvrbuf[3]={{0},{101},{255}}; /* buffer with non-valid refs */ + uint8_t *dwbuf, /* Buffer for writing numeric data to disk */ + *drbuf; /* Buffer for reading numeric data from disk */ + uint8_t *tu8; /* Temporary pointer to uint8 data */ + H5O_type_t obj_type; /* Type of object */ + int i, j; /* counting variables */ + hssize_t hssize_ret; /* hssize_t return value */ + htri_t tri_ret; /* htri_t return value */ + herr_t ret; /* Generic return value */ + haddr_t addr = HADDR_UNDEF; /* test for undefined reference */ + hid_t dset_NA; /* Dataset id for undefined reference */ + hid_t space_NA; /* Dataspace id for undefined reference */ + hsize_t dims_NA[1] = {1}; /* Dims array for undefined reference */ hdset_reg_ref_t wdata_NA[1], /* Write buffer */ rdata_NA[1]; /* Read buffer */ @@ -634,8 +638,14 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); /* Store third dataset region */ - ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); - CHECK(ret, FAIL, "H5Rcreate"); + H5E_BEGIN_TRY { + ret = H5Rcreate(&wbuf[2], fid1, "/Dataset2", H5R_DATASET_REGION, sid2); + } H5E_END_TRY; + + if(libver_high < H5F_LIBVER_V110) + VERIFY(ret, FAIL, "H5Rcreate"); + else + CHECK(ret, FAIL, "H5Rcreate"); ret = H5Rget_obj_type2(dset1, H5R_DATASET_REGION, &wbuf[0], &obj_type); CHECK(ret, FAIL, "H5Rget_obj_type2"); @@ -420,11 +420,11 @@ test_api_get_ex_dcpl(test_api_config_t config, hid_t fapl, hid_t dcpl, size_t plist_buf_size; /* Encode property list to plist_buf */ - if(H5Pencode(dcpl, NULL, &plist_buf_size) < 0) + if(H5Pencode2(dcpl, NULL, &plist_buf_size, fapl) < 0) TEST_ERROR if(NULL == (plist_buf = HDmalloc(plist_buf_size))) TEST_ERROR - if(H5Pencode(dcpl, plist_buf, &plist_buf_size) < 0) + if(H5Pencode2(dcpl, plist_buf, &plist_buf_size, fapl) < 0) TEST_ERROR /* Decode serialized property list to *ex_dcpl */ @@ -469,7 +469,7 @@ error: /* Main test function */ static int -test_api(test_api_config_t config, hid_t fapl) +test_api(test_api_config_t config, hid_t fapl, H5F_libver_t low) { char filename[FILENAME_BUF_SIZE]; hid_t dcpl = -1; /* Dataset creation property list */ @@ -618,7 +618,8 @@ test_api(test_api_config_t config, hid_t fapl) TEST_ERROR /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)213) < 0) + if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112)?(hsize_t)99:(low >= H5F_LIBVER_V110?174:213)) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ @@ -1025,7 +1026,8 @@ test_api(test_api_config_t config, hid_t fapl) } /* Get examination DCPL */ - if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, (hsize_t)697) < 0) + if(test_api_get_ex_dcpl(config, fapl, dcpl, &ex_dcpl, vspace[0], filename, + (low >= H5F_LIBVER_V112)?(hsize_t)607:(hsize_t)697) < 0) TEST_ERROR /* Test H5Pget_virtual_count */ @@ -1119,7 +1121,7 @@ error: } /* end test_api() */ /*------------------------------------------------------------------------- - * Function: vds_link_prefix + * Function: test_vds_prefix_first * * Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp" * Should be able to access the target source files in tmp directory via the prefix set @@ -1130,18 +1132,16 @@ error: *------------------------------------------------------------------------- */ static int -test_vds_prefix(unsigned config, hid_t fapl) +test_vds_prefix_first(unsigned config, hid_t fapl) { char srcfilename[FILENAME_BUF_SIZE]; char srcfilename_map[FILENAME_BUF_SIZE]; char vfilename[FILENAME_BUF_SIZE]; - char vfilename2[FILENAME_BUF_SIZE]; char srcfilenamepct[FILENAME_BUF_SIZE]; char srcfilenamepct_map[FILENAME_BUF_SIZE]; const char *srcfilenamepct_map_orig = "vds%%%%_src"; hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ hid_t vfile = -1; /* File with virtual dset */ - hid_t vfile2 = -1; /* File with copied virtual dset */ hid_t dcpl = -1; /* Dataset creation property list */ hid_t dapl = -1; /* Dataset access property list */ hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ @@ -1156,10 +1156,9 @@ test_vds_prefix(unsigned config, hid_t fapl) int i, j; char buffer[1024]; /* buffer to read vds_prefix */ - TESTING("basic virtual dataset I/O via H5Pset_vds_prefix()") + TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection") h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); - h5_fixname(FILENAME[7], fapl, vfilename2, sizeof vfilename2); h5_fixname(FILENAME[8], fapl, srcfilename, sizeof srcfilename); h5_fixname_printf(FILENAME[8], fapl, srcfilename_map, sizeof srcfilename_map); h5_fixname(FILENAME[10], fapl, srcfilenamepct, sizeof srcfilenamepct); @@ -1189,9 +1188,6 @@ test_vds_prefix(unsigned config, hid_t fapl) if(HDstrcmp(buffer, TMPDIR) != 0) FAIL_PUTS_ERROR("vds prefix not set correctly"); - /* - * Test 1: All - all selection - */ /* Create source dataspace */ if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR @@ -1344,187 +1340,6 @@ test_vds_prefix(unsigned config, hid_t fapl) TEST_ERROR dcpl = -1; - /* - * Test 2: All - all selection with ENV prefix - */ - if(HDsetenv("HDF5_VDS_PREFIX", "${ORIGIN}/tmp", 1)) - TEST_ERROR - - /* Create DCPL */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - TEST_ERROR - - /* Set fill value */ - if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) - TEST_ERROR - - /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ - if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) - TEST_ERROR - - if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) - TEST_ERROR - if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) - TEST_ERROR - - if(HDstrcmp(buffer, "someprefix") != 0) - FAIL_PUTS_ERROR("vds prefix not set correctly"); - - /* Create source dataspace */ - if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR - - /* Create virtual dataspace */ - if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) - TEST_ERROR - - /* Select all (should not be necessary, but just to be sure) */ - if(H5Sselect_all(srcspace[0]) < 0) - TEST_ERROR - if(H5Sselect_all(vspace[0]) < 0) - TEST_ERROR - - /* Add virtual layout mapping */ - if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) - TEST_ERROR - - /* Create virtual file */ - if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - - /* Create source file if requested */ - if(config & TEST_IO_DIFFERENT_FILE) { - HDgetcwd(buffer, 1024); - HDchdir(TMPDIR); - if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) - TEST_ERROR - HDchdir(buffer); - } - else { - srcfile[0] = vfile; - if(H5Iinc_ref(srcfile[0]) < 0) - TEST_ERROR - } - - /* Create source dataset */ - if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - TEST_ERROR - - /* Create virtual dataset */ - if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) - TEST_ERROR - - /* Populate write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; - - /* Write data directly to source dataset */ - if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR - - /* Close srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(H5Dclose(srcdset[0]) < 0) - TEST_ERROR - srcdset[0] = -1; - - if(config & TEST_IO_DIFFERENT_FILE) { - if(H5Fclose(srcfile[0]) < 0) - TEST_ERROR - srcfile[0] = -1; - } - } - - /* Reopen virtual dataset and file if config option specified */ - if(config & TEST_IO_REOPEN_VIRT) { - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) - TEST_ERROR - if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) - TEST_ERROR - } - - /* Read data through virtual dataset */ - HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR - - /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) { - TEST_ERROR - } - } - - /* Adjust write buffer */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); - - /* Write data through virtual dataset */ - if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) - TEST_ERROR - - /* Reopen srcdset and srcfile if config option specified */ - if(config & TEST_IO_CLOSE_SRC) { - if(config & TEST_IO_DIFFERENT_FILE) { - HDgetcwd(buffer, 1024); - HDchdir(TMPDIR); - if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) - TEST_ERROR - HDchdir(buffer); - } - if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) - TEST_ERROR - } - - /* Read data directly from source dataset */ - HDmemset(rbuf[0], 0, sizeof(rbuf)); - if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) - TEST_ERROR - - /* Verify read data */ - for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) - for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) - if(rbuf[i][j] != buf[i][j]) - TEST_ERROR - - /* Close */ - if(H5Dclose(vdset) < 0) - TEST_ERROR - vdset = -1; - if(H5Dclose(srcdset[0]) < 0) - TEST_ERROR - srcdset[0] = -1; - if(H5Fclose(srcfile[0]) < 0) - TEST_ERROR - srcfile[0] = -1; - if(H5Fclose(vfile) < 0) - TEST_ERROR - vfile = -1; - if(H5Sclose(srcspace[0]) < 0) - TEST_ERROR - srcspace[0] = -1; - if(H5Sclose(vspace[0]) < 0) - TEST_ERROR - vspace[0] = -1; - if(H5Pclose(dapl) < 0) - TEST_ERROR - dapl = -1; - if(H5Pclose(dcpl) < 0) - TEST_ERROR - dcpl = -1; - - if(HDsetenv("HDF5_VDS_PREFIX", "", 1) < 0) - TEST_ERROR - PASSED(); return 0; @@ -1536,7 +1351,6 @@ test_vds_prefix(unsigned config, hid_t fapl) for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) H5Fclose(srcfile[i]); H5Fclose(vfile); - H5Fclose(vfile2); for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) H5Sclose(srcspace[i]); for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) @@ -1550,7 +1364,7 @@ test_vds_prefix(unsigned config, hid_t fapl) TEST_ERROR return 1; -} /* end vds_link_prefix() */ +} /* end test_vds_prefix */ /*------------------------------------------------------------------------- @@ -11598,6 +11412,11 @@ test_dapl_values(hid_t fapl_id) * * Purpose: Tests datasets with virtual layout * + * Note: + * Tests are modified to test with the low/high bounds combination + * set in fapl. + * Please see RFC for "H5Sencode/H5Sdecode Format Change". + * * Return: EXIT_SUCCESS/EXIT_FAILURE *------------------------------------------------------------------------- */ @@ -11606,8 +11425,11 @@ main(void) { char filename[FILENAME_BUF_SIZE]; hid_t fapl; + hid_t my_fapl = -1; /* File access property list */ int test_api_config; unsigned bit_config; + unsigned latest = FALSE; /* Using the latest library version bound */ + H5F_libver_t low, high; /* Low and high bounds */ int nerrors = 0; /* Testing setup */ @@ -11616,21 +11438,59 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); - for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++) - nerrors += test_api((test_api_config_t)test_api_config, fapl); - for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { - HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); - nerrors += test_basic_io(bit_config, fapl); - nerrors += test_vds_prefix(bit_config, fapl); - nerrors += test_unlim(bit_config, fapl); - nerrors += test_printf(bit_config, fapl); - nerrors += test_all(bit_config, fapl); - } + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; low++) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { + char msg[80]; /* Message for file version bounds */ + char *low_string; /* The low bound string */ + char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Whether to use latest hyperslab/point selection version */ + if(low >= H5F_LIBVER_V112) + latest = TRUE; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + for(test_api_config = (int)TEST_API_BASIC; test_api_config < (int)TEST_API_NTESTS; test_api_config++) + nerrors += test_api((test_api_config_t)test_api_config, my_fapl, low); + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_basic_io(bit_config, my_fapl); + nerrors += test_vds_prefix_first(bit_config, my_fapl); + nerrors += test_unlim(bit_config, my_fapl); + nerrors += test_printf(bit_config, my_fapl); + nerrors += test_all(bit_config, my_fapl); + } + + nerrors += test_dapl_values(my_fapl); - nerrors += test_dapl_values(fapl); + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); - /* Verify symbol table messages are cached */ - nerrors += (h5_verify_cached_stabs(FILENAME, fapl) < 0 ? 1 : 0); + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR if(nerrors) goto error; diff --git a/test/vds_env.c b/test/vds_env.c new file mode 100644 index 0000000..abdd7b7 --- /dev/null +++ b/test/vds_env.c @@ -0,0 +1,364 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Neil Fortner <nfortne2@hdfgroup.org> + * Monday, February 16, 2015 + * + * Purpose: Tests datasets with virtual layout. + */ +#include "h5test.h" + +const char *FILENAME[] = { + "vds_env_virt_0", + "vds_env_virt_3", + "vds_env_src_2", + "vds_env%%_src2", + NULL +}; + +/* I/O test config flags */ +#define TEST_IO_CLOSE_SRC 0x01u +#define TEST_IO_DIFFERENT_FILE 0x02u +#define TEST_IO_REOPEN_VIRT 0x04u +#define TEST_IO_NTESTS 0x08u + +#define FILENAME_BUF_SIZE 1024 + +#define TMPDIR "tmp/" + +/*------------------------------------------------------------------------- + * Function: test_vds_prefix_second + * + * Purpose: Set up vds link prefix via H5Pset_virtual_prefix() to be "tmp" + * Should be able to access the target source files in tmp directory via the prefix set + * by H5Pset_virtual_prefix() + * + * Return: Success: 0 + * Failure: -1 + *------------------------------------------------------------------------- + */ +static int +test_vds_prefix_second(unsigned config, hid_t fapl) +{ + char srcfilename[FILENAME_BUF_SIZE]; + char srcfilename_map[FILENAME_BUF_SIZE]; + char vfilename[FILENAME_BUF_SIZE]; + char vfilename2[FILENAME_BUF_SIZE]; + char srcfilenamepct[FILENAME_BUF_SIZE]; + char srcfilenamepct_map[FILENAME_BUF_SIZE]; + const char *srcfilenamepct_map_orig = "vds%%%%_src"; + hid_t srcfile[4] = {-1, -1, -1, -1}; /* Files with source dsets */ + hid_t vfile = -1; /* File with virtual dset */ + hid_t dcpl = -1; /* Dataset creation property list */ + hid_t dapl = -1; /* Dataset access property list */ + hid_t srcspace[4] = {-1, -1, -1, -1}; /* Source dataspaces */ + hid_t vspace[4] = {-1, -1, -1, -1}; /* Virtual dset dataspaces */ + hid_t memspace = -1; /* Memory dataspace */ + hid_t srcdset[4] = {-1, -1, -1, -1}; /* Source datsets */ + hid_t vdset = -1; /* Virtual dataset */ + hsize_t dims[4] = {10, 26, 0, 0}; /* Data space current size */ + int buf[10][26]; /* Write and expected read buffer */ + int rbuf[10][26]; /* Read buffer */ + int fill = -1; /* Fill value */ + int i, j; + char buffer[1024]; /* buffer to read vds_prefix */ + + TESTING("basic virtual dataset I/O via H5Pset_vds_prefix(): all selection with ENV prefix") + + h5_fixname(FILENAME[0], fapl, vfilename, sizeof vfilename); + h5_fixname(FILENAME[1], fapl, vfilename2, sizeof vfilename2); + h5_fixname(FILENAME[2], fapl, srcfilename, sizeof srcfilename); + h5_fixname_printf(FILENAME[2], fapl, srcfilename_map, sizeof srcfilename_map); + h5_fixname(FILENAME[3], fapl, srcfilenamepct, sizeof srcfilenamepct); + h5_fixname_printf(srcfilenamepct_map_orig, fapl, srcfilenamepct_map, sizeof srcfilenamepct_map); + + /* create tmp directory and get current working directory path */ + if (HDmkdir(TMPDIR, (mode_t)0755) < 0 && errno != EEXIST) + TEST_ERROR + + /* Create DCPL */ + if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) + TEST_ERROR + + /* Set fill value */ + if(H5Pset_fill_value(dcpl, H5T_NATIVE_INT, &fill) < 0) + TEST_ERROR + + /* Set prefix to a nonexistent directory, will be overwritten by environment variable */ + if((dapl = H5Pcreate(H5P_DATASET_ACCESS)) < 0) + TEST_ERROR + + if(H5Pset_virtual_prefix(dapl, "someprefix") < 0) + TEST_ERROR + if(H5Pget_virtual_prefix(dapl, buffer, sizeof(buffer)) < 0) + TEST_ERROR + + if(HDstrcmp(buffer, "someprefix") != 0) + FAIL_PUTS_ERROR("vds prefix not set correctly"); + + /* Create source dataspace */ + if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + + /* Create virtual dataspace */ + if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR + + /* Select all (should not be necessary, but just to be sure) */ + if(H5Sselect_all(srcspace[0]) < 0) + TEST_ERROR + if(H5Sselect_all(vspace[0]) < 0) + TEST_ERROR + + /* Add virtual layout mapping */ + if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset", srcspace[0]) < 0) + TEST_ERROR + + /* Create virtual file */ + if((vfile = H5Fcreate(vfilename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Create source file if requested */ + if(config & TEST_IO_DIFFERENT_FILE) { + HDgetcwd(buffer, 1024); + HDchdir(TMPDIR); + if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + HDchdir(buffer); + } + else { + srcfile[0] = vfile; + if(H5Iinc_ref(srcfile[0]) < 0) + TEST_ERROR + } + + /* Create source dataset */ + if((srcdset[0] = H5Dcreate2(srcfile[0], "src_dset", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create virtual dataset */ + if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, dapl)) < 0) + TEST_ERROR + + /* Populate write buffer */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j; + + /* Write data directly to source dataset */ + if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR + + /* Close srcdset and srcfile if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + + if(config & TEST_IO_DIFFERENT_FILE) { + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + } + } + + /* Reopen virtual dataset and file if config option specified */ + if(config & TEST_IO_REOPEN_VIRT) { + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if((vfile = H5Fopen(vfilename2, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + if((vdset = H5Dopen2(vfile, "v_dset", dapl)) < 0) + TEST_ERROR + } + + /* Read data through virtual dataset */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); + if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) { + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if(rbuf[i][j] != buf[i][j]) { + TEST_ERROR + } + } + + /* Adjust write buffer */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0])); + + /* Write data through virtual dataset */ + if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) + TEST_ERROR + + /* Reopen srcdset and srcfile if config option specified */ + if(config & TEST_IO_CLOSE_SRC) { + if(config & TEST_IO_DIFFERENT_FILE) { + HDgetcwd(buffer, 1024); + HDchdir(TMPDIR); + if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0) + TEST_ERROR + HDchdir(buffer); + } + if((srcdset[0] = H5Dopen2(srcfile[0], "src_dset", H5P_DEFAULT)) < 0) + TEST_ERROR + } + + /* Read data directly from source dataset */ + HDmemset(rbuf[0], 0, sizeof(rbuf)); + if(H5Dread(srcdset[0], H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0) + TEST_ERROR + + /* Verify read data */ + for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++) + for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++) + if(rbuf[i][j] != buf[i][j]) + TEST_ERROR + + /* Close */ + if(H5Dclose(vdset) < 0) + TEST_ERROR + vdset = -1; + if(H5Dclose(srcdset[0]) < 0) + TEST_ERROR + srcdset[0] = -1; + if(H5Fclose(srcfile[0]) < 0) + TEST_ERROR + srcfile[0] = -1; + if(H5Fclose(vfile) < 0) + TEST_ERROR + vfile = -1; + if(H5Sclose(srcspace[0]) < 0) + TEST_ERROR + srcspace[0] = -1; + if(H5Sclose(vspace[0]) < 0) + TEST_ERROR + vspace[0] = -1; + if(H5Pclose(dapl) < 0) + TEST_ERROR + dapl = -1; + if(H5Pclose(dcpl) < 0) + TEST_ERROR + dcpl = -1; + + PASSED(); + return 0; + + error: + H5E_BEGIN_TRY { + for(i = 0; i < (int)(sizeof(srcdset) / sizeof(srcdset[0])); i++) + H5Dclose(srcdset[i]); + H5Dclose(vdset); + for(i = 0; i < (int)(sizeof(srcfile) / sizeof(srcfile[0])); i++) + H5Fclose(srcfile[i]); + H5Fclose(vfile); + for(i = 0; i < (int)(sizeof(srcspace) / sizeof(srcspace[0])); i++) + H5Sclose(srcspace[i]); + for(i = 0; i < (int)(sizeof(vspace) / sizeof(vspace[0])); i++) + H5Sclose(vspace[i]); + H5Sclose(memspace); + H5Pclose(dapl); + H5Pclose(dcpl); + } H5E_END_TRY; + + return 1; +} /* end test_vds_prefix2 */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests datasets with virtual layout + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fapl, my_fapl; + unsigned bit_config; + H5F_libver_t low, high; /* Low and high bounds */ + unsigned latest = FALSE; /* Using the latest library version bound */ + int nerrors = 0; + + /* Testing setup */ + h5_reset(); + fapl = h5_fileaccess(); + + /* Set to use the latest file format */ + if((my_fapl = H5Pcopy(fapl)) < 0) TEST_ERROR + + /* Loop through all the combinations of low/high version bounds */ + for(low = H5F_LIBVER_EARLIEST; low < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, low)) { + for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; H5_INC_ENUM(H5F_libver_t, high)) { + char msg[80]; /* Message for file version bounds */ + char *low_string; /* The low bound string */ + char *high_string; /* The high bound string */ + + /* Invalid combinations, just continue */ + if(high == H5F_LIBVER_EARLIEST || high < low) + continue; + + /* Test virtual dataset only for V110 and above */ + if(high < H5F_LIBVER_V110) + continue; + + /* Whether to use latest hyperslab/point selection version */ + if(low >= H5F_LIBVER_V112) + latest = TRUE; + + /* Set the low/high version bounds */ + if(H5Pset_libver_bounds(my_fapl, low, high) < 0) + TEST_ERROR + + /* Display testing info */ + low_string = h5_get_version_string(low); + high_string = h5_get_version_string(high); + HDsprintf(msg, "Testing virtual dataset with file version bounds: (%s, %s):", low_string, high_string); + HDputs(msg); + + for(bit_config = 0; bit_config < TEST_IO_NTESTS; bit_config++) { + HDprintf("Config: %s%s%s\n", bit_config & TEST_IO_CLOSE_SRC ? "closed source dataset, " : "", bit_config & TEST_IO_DIFFERENT_FILE ? "different source file" : "same source file", bit_config & TEST_IO_REOPEN_VIRT ? ", reopen virtual file" : ""); + nerrors += test_vds_prefix_second(bit_config, fapl); + } + + /* Verify symbol table messages are cached */ + nerrors += (h5_verify_cached_stabs(FILENAME, my_fapl) < 0 ? 1 : 0); + + } /* end for high */ + } /* end for low */ + + if(H5Pclose(my_fapl) < 0) + TEST_ERROR + + if(nerrors) + goto error; + HDprintf("All virtual dataset tests passed.\n"); + h5_cleanup(FILENAME, fapl); + + return EXIT_SUCCESS; + +error: + nerrors = MAX(1, nerrors); + HDprintf("***** %d VIRTUAL DATASET TEST%s FAILED! *****\n", + nerrors, 1 == nerrors ? "" : "S"); + return EXIT_FAILURE; +} /* end main() */ @@ -61,6 +61,7 @@ static const H5VL_class_t fake_vol_g = { NULL, /* get_object */ NULL, /* get_wrap_ctx */ NULL, /* wrap_object */ + NULL, /* unwrap_object */ NULL, /* free_wrap_ctx */ }, { /* attribute_cls */ |