diff options
111 files changed, 9119 insertions, 4977 deletions
@@ -489,7 +489,6 @@ ./src/H5Apublic.h ./src/H5AC.c ./src/H5ACdbg.c -./src/H5AClog.c ./src/H5ACmodule.h ./src/H5ACmpio.c ./src/H5ACpkg.h @@ -519,6 +518,9 @@ ./src/H5Cepoch.c ./src/H5Cimage.c ./src/H5Clog.c +./src/H5Clog.h +./src/H5Clog_json.c +./src/H5Clog_trace.c ./src/H5Cmodule.h ./src/H5Cmpio.c ./src/H5Cpkg.h @@ -966,13 +968,13 @@ ./test/cross_read.c ./test/dangle.c ./test/deflate.h5 +./test/del_many_dense_attrs.c ./test/direct_chunk.c ./test/dsets.c ./test/dt_arith.c ./test/dtypes.c ./test/dtransform.c ./test/earray.c -./test/echo_vol.c ./test/efc.c ./test/enc_dec_plist.c ./test/enc_dec_plist_cross_platform.c @@ -1020,6 +1022,7 @@ ./test/gen_deflate.c ./test/gen_file_image.c ./test/gen_filespace.c +./test/gen_filters.c ./test/gen_mergemsg.c ./test/gen_new_array.c ./test/gen_new_fill.c @@ -1063,6 +1066,8 @@ ./test/noencoder.h5 ./test/none.h5 ./test/ntypes.c +./test/null_vol_connector.c +./test/null_vol_connector.h ./test/ohdr.c ./test/objcopy.c ./test/page_buffer.c @@ -1098,17 +1103,20 @@ ./test/tcheck_version.c ./test/tconfig.c ./test/tcoords.c +./test/testabort_fail.sh.in ./test/testcheck_version.sh.in ./test/testerror.sh.in ./test/testlinks_env.sh.in -./test/test_filenotclosed.sh.in ./test/test_filter_plugin.sh.in +./test/test_filters_le.h5 +./test/test_filters_be.h5 ./test/testflushrefresh.sh.in ./test/testframe.c ./test/testhdf5.c ./test/testhdf5.h ./test/testlibinfo.sh.in ./test/test_usecases.sh.in +./test/test_vol_plugin.sh.in ./test/testmeta.c ./test/testswmr.sh.in ./test/testvdsswmr.sh.in @@ -1150,16 +1158,14 @@ ./test/use_common.c ./test/use_disable_mdc_flushes.c ./test/use.h -./test/vfd.c -./test/vol.c -./test/test_filters_le.h5 -./test/test_filters_be.h5 -./test/gen_filters.c ./test/vds.c ./test/vds_swmr.h ./test/vds_swmr_gen.c ./test/vds_swmr_reader.c ./test/vds_swmr_writer.c +./test/vfd.c +./test/vol.c +./test/vol_plugin.c ./test/testfiles/err_compat_1 ./test/testfiles/err_compat_2 @@ -1290,6 +1296,7 @@ ./testpar/t_span_tree.c ./testpar/t_init_term.c ./testpar/testpar.h +./testpar/testpflush.sh.in ./testpar/testphdf5.c ./testpar/testphdf5.h @@ -3185,6 +3192,7 @@ ./config/toolchain/crayle.cmake ./config/toolchain/GCC.cmake ./config/toolchain/intel.cmake +./config/toolchain/PGI.cmake ./config/cmake/cacheinit.cmake ./config/cmake/CMakeFindJavaCommon.cmake diff --git a/config/cmake/CTestScript.cmake b/config/cmake/CTestScript.cmake index 0269ba8..0269ba8 100755..100644 --- a/config/cmake/CTestScript.cmake +++ b/config/cmake/CTestScript.cmake diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 6d1e3ce..459346e 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -28,15 +28,6 @@ if (HDF5_STRICT_FORMAT_CHECKS) endif () MARK_AS_ADVANCED (HDF5_STRICT_FORMAT_CHECKS) -#----------------------------------------------------------------------------- -# Option for --enable-metadata-trace-file -#----------------------------------------------------------------------------- -option (HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF) -if (HDF5_METADATA_TRACE_FILE) - set (${HDF_PREFIX}_METADATA_TRACE_FILE 1) -endif () -MARK_AS_ADVANCED (HDF5_METADATA_TRACE_FILE) - # ---------------------------------------------------------------------- # Decide whether the data accuracy has higher priority during data # conversions. If not, some hard conversions will still be prefered even diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 2ddb740..c42d93a 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -466,9 +466,6 @@ /* Define to enable internal memory allocation sanity checking. */ /* #cmakedefine H5_MEMORY_ALLOC_SANITY_CHECK @H5_MEMORY_ALLOC_SANITY_CHECK@ ** Define in CMakeLists.txt */ -/* Define if the metadata trace file code is to be compiled in */ -#cmakedefine H5_METADATA_TRACE_FILE @H5_METADATA_TRACE_FILE@ - /* Define if we can violate pointer alignment restrictions */ #cmakedefine H5_NO_ALIGNMENT_RESTRICTIONS @H5_NO_ALIGNMENT_RESTRICTIONS@ diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake index 157befd..a24b2e1 100644 --- a/config/cmake/HDF5UseFortran.cmake +++ b/config/cmake/HDF5UseFortran.cmake @@ -18,16 +18,6 @@ ENABLE_LANGUAGE (Fortran) set (HDF_PREFIX "H5") include (CheckFortranFunctionExists) -## Check for non-standard extenstion quadmath.h - -CHECK_INCLUDE_FILES(quadmath.h C_HAVE_QUADMATH) - -if (${C_HAVE_QUADMATH}) - set(${HDF_PREFIX}_HAVE_QUADMATH_H 1) -else () - set(${HDF_PREFIX}_HAVE_QUADMATH_H 0) -endif () - # The provided CMake Fortran macros don't provide a general compile/run function # so this one is used. #----------------------------------------------------------------------------- @@ -40,7 +30,7 @@ macro (FORTRAN_RUN FUNCTION_NAME SOURCE_CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR1 TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 - LINK_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" + LINK_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}" ) if (${COMPILE_RESULT_VAR}) @@ -367,9 +357,9 @@ ENABLE_LANGUAGE (C) #----------------------------------------------------------------------------- macro (C_RUN FUNCTION_NAME SOURCE_CODE RETURN_VAR) message (STATUS "Detecting C ${FUNCTION_NAME}") - if (CMAKE_REQUIRED_LIBRARIES) + if (HDF5_REQUIRED_LIBRARIES) set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") else () set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) endif () diff --git a/config/cmake/HDF5_Examples_options.cmake b/config/cmake/HDF5_Examples_options.cmake index 386e99c..386e99c 100755..100644 --- a/config/cmake/HDF5_Examples_options.cmake +++ b/config/cmake/HDF5_Examples_options.cmake diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 93ebc3c..0a39568 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -9,16 +9,16 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_STANDARD_REQUIRED TRUE) message (STATUS "Warnings Configuration:") +set (CMAKE_C_FLAGS "${CMAKE_C99_STANDARD_COMPILE_OPTION} ${CMAKE_C_FLAGS}") #----------------------------------------------------------------------------- # Compiler specific flags : Shouldn't there be compiler tests for these #----------------------------------------------------------------------------- if (CMAKE_COMPILER_IS_GNUCC) set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") - if (NOT CYGWIN) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") - endif () if (${HDF_CFG_NAME} MATCHES "Debug") if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") diff --git a/config/cmake/libh5cc.in b/config/cmake/libh5cc.in index f462d56..f462d56 100755..100644 --- a/config/cmake/libh5cc.in +++ b/config/cmake/libh5cc.in diff --git a/config/cmake/libhdf5.pc.in b/config/cmake/libhdf5.pc.in index 4a2ebaa..4a2ebaa 100755..100644 --- a/config/cmake/libhdf5.pc.in +++ b/config/cmake/libhdf5.pc.in diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 6a489e7..9a534df 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -79,7 +79,6 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ API Tracing: @HDF5_ENABLE_TRACE@ Using memory checker: @HDF5_ENABLE_USING_MEMCHECKER@ Memory allocation sanity checks: @HDF5_MEMORY_ALLOC_SANITY_CHECK@ - Metadata trace file: @METADATATRACEFILE@ Function Stack Tracing: @HDF5_ENABLE_CODESTACK@ Strict File Format Checks: @HDF5_STRICT_FORMAT_CHECKS@ Optimization Instrumentation: @HDF5_Enable_Instrument@ diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake index 9534b1e..2b0ac81 100755..100644 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -9,261 +9,261 @@ # If you do not have access to either file, you may request a copy from # help@hdfgroup.org. # -cmake_minimum_required (VERSION 3.10)
-########################################################
-# This dashboard is maintained by The HDF Group
-# For any comments please contact cdashhelp@hdfgroup.org
-#
-########################################################
-# -----------------------------------------------------------
-# -- Get environment
-# -----------------------------------------------------------
-if (NOT SITE_OS_NAME)
- ## machine name not provided - attempt to discover with uname
- ## -- set hostname
- ## --------------------------
- find_program (HOSTNAME_CMD NAMES hostname)
- exec_program (${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME)
- set (CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}")
- find_program (UNAME NAMES uname)
- macro (getuname name flag)
- exec_program ("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}")
- endmacro ()
-
- getuname (osname -s)
- getuname (osrel -r)
- getuname (cpu -m)
- message (STATUS "Dashboard script uname output: ${osname}-${osrel}-${cpu}\n")
-
- set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}")
-else ()
- ## machine name provided
- ## --------------------------
- if (CMAKE_HOST_UNIX)
- set (CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}")
- else ()
- set (CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}")
- endif ()
-endif ()
+cmake_minimum_required (VERSION 3.10) +######################################################## +# This dashboard is maintained by The HDF Group +# For any comments please contact cdashhelp@hdfgroup.org +# +######################################################## +# ----------------------------------------------------------- +# -- Get environment +# ----------------------------------------------------------- +if (NOT SITE_OS_NAME) + ## machine name not provided - attempt to discover with uname + ## -- set hostname + ## -------------------------- + find_program (HOSTNAME_CMD NAMES hostname) + exec_program (${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) + set (CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}") + find_program (UNAME NAMES uname) + macro (getuname name flag) + exec_program ("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") + endmacro () + + getuname (osname -s) + getuname (osrel -r) + getuname (cpu -m) + message (STATUS "Dashboard script uname output: ${osname}-${osrel}-${cpu}\n") + + set (CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}") +else () + ## machine name provided + ## -------------------------- + if (CMAKE_HOST_UNIX) + set (CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}") + else () + set (CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}") + endif () +endif () if (SITE_BUILDNAME_SUFFIX) set (CTEST_BUILD_NAME "${SITE_BUILDNAME_SUFFIX}-${CTEST_BUILD_NAME}") endif () set (BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") -
-#-----------------------------------------------------------------------------
-# MAC machines need special option
-#-----------------------------------------------------------------------------
-if (APPLE)
- # Compiler choice
- execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE)
- execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE)
- set (ENV{CC} "${XCODE_CC}")
- set (ENV{CXX} "${XCODE_CXX}")
-
- set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF")
-endif ()
-
-#-----------------------------------------------------------------------------
-set (NEED_REPOSITORY_CHECKOUT 0)
-set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"")
-if (CTEST_USE_TAR_SOURCE)
- ## Uncompress source if tar file provided
- ## --------------------------
- if (WIN32)
- message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} x ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip]")
- execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv)
- else ()
- message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar]")
- execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv)
- endif ()
-
- if (NOT rv EQUAL 0)
- message (STATUS "extracting... [error-(${rv}) clean up]")
- file (REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}")
- message (FATAL_ERROR "error: extract of ${CTEST_USE_TAR_SOURCE} failed")
- endif ()
-
- file (RENAME ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE} ${CTEST_SOURCE_DIRECTORY})
- set (LOCAL_SKIP_UPDATE "TRUE")
-else ()
- if (LOCAL_UPDATE)
- if (CTEST_USE_GIT_SOURCE)
- find_program (CTEST_GIT_COMMAND NAMES git git.cmd)
- set (CTEST_GIT_UPDATE_OPTIONS)
-
- if (NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
- set (NEED_REPOSITORY_CHECKOUT 1)
- endif ()
-
- if (${NEED_REPOSITORY_CHECKOUT})
- if (REPOSITORY_BRANCH)
- set (CTEST_GIT_options "clone \"${REPOSITORY_URL}\" --branch \"${REPOSITORY_BRANCH}\" --single-branch \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules")
- else ()
- set (CTEST_GIT_options "clone \"${REPOSITORY_URL}\" \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules")
- endif ()
- set (CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} ${CTEST_GIT_options}")
- else ()
- set (CTEST_GIT_options "pull")
- endif ()
- set (CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}")
- else ()
- ## --------------------------
- ## use subversion to get source
- #-----------------------------------------------------------------------------
- ## cygwin does not handle the find_package() call
- ## --------------------------
- set (CTEST_UPDATE_COMMAND "SVNCommand")
- if (NOT SITE_CYGWIN})
- find_package (Subversion)
- set (CTEST_SVN_COMMAND "${Subversion_SVN_EXECUTABLE}")
- set (CTEST_UPDATE_COMMAND "${Subversion_SVN_EXECUTABLE}")
- else ()
- set (CTEST_SVN_COMMAND "/usr/bin/svn")
- set (CTEST_UPDATE_COMMAND "/usr/bin/svn")
- endif ()
-
- if (NOT EXISTS "${CTEST_SOURCE_DIRECTORY}")
- set (NEED_REPOSITORY_CHECKOUT 1)
- endif ()
-
- if (NOT CTEST_REPO_VERSION)
- set (CTEST_REPO_VERSION "HEAD")
- endif ()
- if (${NEED_REPOSITORY_CHECKOUT})
- set (CTEST_CHECKOUT_COMMAND
- "\"${CTEST_SVN_COMMAND}\" co ${REPOSITORY_URL} \"${CTEST_SOURCE_DIRECTORY}\" -r ${CTEST_REPO_VERSION}")
- else ()
- if (CTEST_REPO_VERSION)
- set (CTEST_SVN_UPDATE_OPTIONS "-r ${CTEST_REPO_VERSION}")
- endif ()
- endif ()
- endif ()
- endif ()
-endif ()
-
-#-----------------------------------------------------------------------------
-## Clear the build directory
-## --------------------------
-set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE)
-if (NOT EXISTS "${CTEST_BINARY_DIRECTORY}")
- file (MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}")
-else ()
- ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY})
-endif ()
-
-# Use multiple CPU cores to build
-include (ProcessorCount)
-ProcessorCount (N)
+ +#----------------------------------------------------------------------------- +# MAC machines need special option +#----------------------------------------------------------------------------- +if (APPLE) + # Compiler choice + execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set (ENV{CC} "${XCODE_CC}") + set (ENV{CXX} "${XCODE_CXX}") + + set (BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") +endif () + +#----------------------------------------------------------------------------- +set (NEED_REPOSITORY_CHECKOUT 0) +set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") +if (CTEST_USE_TAR_SOURCE) + ## Uncompress source if tar file provided + ## -------------------------- + if (WIN32) + message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} x ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip]") + execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) + else () + message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar]") + execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) + endif () + + if (NOT rv EQUAL 0) + message (STATUS "extracting... [error-(${rv}) clean up]") + file (REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") + message (FATAL_ERROR "error: extract of ${CTEST_USE_TAR_SOURCE} failed") + endif () + + file (RENAME ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE} ${CTEST_SOURCE_DIRECTORY}) + set (LOCAL_SKIP_UPDATE "TRUE") +else () + if (LOCAL_UPDATE) + if (CTEST_USE_GIT_SOURCE) + find_program (CTEST_GIT_COMMAND NAMES git git.cmd) + set (CTEST_GIT_UPDATE_OPTIONS) + + if (NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + set (NEED_REPOSITORY_CHECKOUT 1) + endif () + + if (${NEED_REPOSITORY_CHECKOUT}) + if (REPOSITORY_BRANCH) + set (CTEST_GIT_options "clone \"${REPOSITORY_URL}\" --branch \"${REPOSITORY_BRANCH}\" --single-branch \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules") + else () + set (CTEST_GIT_options "clone \"${REPOSITORY_URL}\" \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules") + endif () + set (CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} ${CTEST_GIT_options}") + else () + set (CTEST_GIT_options "pull") + endif () + set (CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") + else () + ## -------------------------- + ## use subversion to get source + #----------------------------------------------------------------------------- + ## cygwin does not handle the find_package() call + ## -------------------------- + set (CTEST_UPDATE_COMMAND "SVNCommand") + if (NOT SITE_CYGWIN}) + find_package (Subversion) + set (CTEST_SVN_COMMAND "${Subversion_SVN_EXECUTABLE}") + set (CTEST_UPDATE_COMMAND "${Subversion_SVN_EXECUTABLE}") + else () + set (CTEST_SVN_COMMAND "/usr/bin/svn") + set (CTEST_UPDATE_COMMAND "/usr/bin/svn") + endif () + + if (NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + set (NEED_REPOSITORY_CHECKOUT 1) + endif () + + if (NOT CTEST_REPO_VERSION) + set (CTEST_REPO_VERSION "HEAD") + endif () + if (${NEED_REPOSITORY_CHECKOUT}) + set (CTEST_CHECKOUT_COMMAND + "\"${CTEST_SVN_COMMAND}\" co ${REPOSITORY_URL} \"${CTEST_SOURCE_DIRECTORY}\" -r ${CTEST_REPO_VERSION}") + else () + if (CTEST_REPO_VERSION) + set (CTEST_SVN_UPDATE_OPTIONS "-r ${CTEST_REPO_VERSION}") + endif () + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +## Clear the build directory +## -------------------------- +set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) +if (NOT EXISTS "${CTEST_BINARY_DIRECTORY}") + file (MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +else () + ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY}) +endif () + +# Use multiple CPU cores to build +include (ProcessorCount) +ProcessorCount (N) if (NOT N EQUAL 0) if (MAX_PROC_COUNT) if (N GREATER MAX_PROC_COUNT) set (N ${MAX_PROC_COUNT}) endif () endif () - if (NOT WIN32)
- set (CTEST_BUILD_FLAGS -j${N})
- endif ()
- set (ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
-endif ()
-
-#-----------------------------------------------------------------------------
-# Send the main script as a note.
-list (APPEND CTEST_NOTES_FILES
- "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}"
- "${CMAKE_CURRENT_LIST_FILE}"
- "${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake"
-)
-
-#-----------------------------------------------------------------------------
-# Check for required variables.
-# --------------------------
-foreach (req
- CTEST_CMAKE_GENERATOR
- CTEST_SITE
- CTEST_BUILD_NAME
- )
- if (NOT DEFINED ${req})
- message (FATAL_ERROR "The containing script must set ${req}")
- endif ()
-endforeach ()
-
-#-----------------------------------------------------------------------------
-# Initialize the CTEST commands
-#------------------------------
-if (CMAKE_GENERATOR_TOOLSET)
- set (CTEST_CONFIGURE_TOOLSET "-T${CMAKE_GENERATOR_TOOLSET}")
-else ()
- set (CTEST_CONFIGURE_TOOLSET "")
-endif()
-if (LOCAL_MEMCHECK_TEST)
- find_program (CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
- set (CTEST_CONFIGURE_COMMAND
- "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_CONFIGURE_TOOLSET}\" \"${CTEST_SOURCE_DIRECTORY}\""
- )
-else ()
- if (LOCAL_COVERAGE_TEST)
- find_program (CTEST_COVERAGE_COMMAND NAMES gcov)
- endif ()
- set (CTEST_CONFIGURE_COMMAND
- "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_CONFIGURE_TOOLSET}\" \"${CTEST_SOURCE_DIRECTORY}\""
- )
-endif ()
-
-#-----------------------------------------------------------------------------
-## -- set output to english
-set ($ENV{LC_MESSAGES} "en_EN")
-
-# Print summary information.
-foreach (v
- CTEST_SITE
- CTEST_BUILD_NAME
- CTEST_SOURCE_DIRECTORY
- CTEST_BINARY_DIRECTORY
- CTEST_CMAKE_GENERATOR
- CTEST_CONFIGURATION_TYPE
- CTEST_GIT_COMMAND
- CTEST_CHECKOUT_COMMAND
- CTEST_CONFIGURE_COMMAND
- CTEST_SCRIPT_DIRECTORY
- CTEST_USE_LAUNCHERS
- )
- set (vars "${vars} ${v}=[${${v}}]\n")
-endforeach ()
-message (STATUS "Dashboard script configuration:\n${vars}\n")
-
-#-----------------------------------------------------------------------------
-#-----------------------------------------------------------------------------
- ## NORMAL process
- ## -- LOCAL_UPDATE updates the source folder from svn
- ## -- LOCAL_SUBMIT reports to CDash server
- ## -- LOCAL_SKIP_TEST skips the test process (only builds)
- ## -- LOCAL_MEMCHECK_TEST executes the Valgrind testing
- ## -- LOCAL_COVERAGE_TEST executes code coverage process
- ## --------------------------
- ctest_start (${MODEL} TRACK ${MODEL})
- if (LOCAL_UPDATE)
- ctest_update (SOURCE "${CTEST_SOURCE_DIRECTORY}")
- endif ()
- configure_file (${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake)
- ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}")
- ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res)
- if (LOCAL_SUBMIT)
- ctest_submit (PARTS Update Configure Notes)
- endif ()
- if (${res} LESS 0 OR ${res} GREATER 0)
- file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed Configure: ${res}\n")
- endif ()
-
- ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND RETURN_VALUE res NUMBER_ERRORS errval)
- if (LOCAL_SUBMIT)
- ctest_submit (PARTS Build)
- endif ()
- if (${res} LESS 0 OR ${res} GREATER 0 OR ${errval} GREATER 0)
- file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed ${errval} Build: ${res}\n")
- endif ()
-
- if (NOT LOCAL_SKIP_TEST)
- if (NOT LOCAL_MEMCHECK_TEST)
+ if (NOT WIN32) + set (CTEST_BUILD_FLAGS -j${N}) + endif () + set (ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +endif () + +#----------------------------------------------------------------------------- +# Send the main script as a note. +list (APPEND CTEST_NOTES_FILES + "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}" + "${CMAKE_CURRENT_LIST_FILE}" + "${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake" +) + +#----------------------------------------------------------------------------- +# Check for required variables. +# -------------------------- +foreach (req + CTEST_CMAKE_GENERATOR + CTEST_SITE + CTEST_BUILD_NAME + ) + if (NOT DEFINED ${req}) + message (FATAL_ERROR "The containing script must set ${req}") + endif () +endforeach () + +#----------------------------------------------------------------------------- +# Initialize the CTEST commands +#------------------------------ +if (CMAKE_GENERATOR_TOOLSET) + set (CTEST_CONFIGURE_TOOLSET "-T${CMAKE_GENERATOR_TOOLSET}") +else () + set (CTEST_CONFIGURE_TOOLSET "") +endif() +if (LOCAL_MEMCHECK_TEST) + find_program (CTEST_MEMORYCHECK_COMMAND NAMES valgrind) + set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_CONFIGURE_TOOLSET}\" \"${CTEST_SOURCE_DIRECTORY}\"" + ) +else () + if (LOCAL_COVERAGE_TEST) + find_program (CTEST_COVERAGE_COMMAND NAMES gcov) + endif () + set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_CONFIGURE_TOOLSET}\" \"${CTEST_SOURCE_DIRECTORY}\"" + ) +endif () + +#----------------------------------------------------------------------------- +## -- set output to english +set ($ENV{LC_MESSAGES} "en_EN") + +# Print summary information. +foreach (v + CTEST_SITE + CTEST_BUILD_NAME + CTEST_SOURCE_DIRECTORY + CTEST_BINARY_DIRECTORY + CTEST_CMAKE_GENERATOR + CTEST_CONFIGURATION_TYPE + CTEST_GIT_COMMAND + CTEST_CHECKOUT_COMMAND + CTEST_CONFIGURE_COMMAND + CTEST_SCRIPT_DIRECTORY + CTEST_USE_LAUNCHERS + ) + set (vars "${vars} ${v}=[${${v}}]\n") +endforeach () +message (STATUS "Dashboard script configuration:\n${vars}\n") + +#----------------------------------------------------------------------------- +#----------------------------------------------------------------------------- + ## NORMAL process + ## -- LOCAL_UPDATE updates the source folder from svn + ## -- LOCAL_SUBMIT reports to CDash server + ## -- LOCAL_SKIP_TEST skips the test process (only builds) + ## -- LOCAL_MEMCHECK_TEST executes the Valgrind testing + ## -- LOCAL_COVERAGE_TEST executes code coverage process + ## -------------------------- + ctest_start (${MODEL} TRACK ${MODEL}) + if (LOCAL_UPDATE) + ctest_update (SOURCE "${CTEST_SOURCE_DIRECTORY}") + endif () + configure_file (${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) + ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") + ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE res) + if (LOCAL_SUBMIT) + ctest_submit (PARTS Update Configure Notes) + endif () + if (${res} LESS 0 OR ${res} GREATER 0) + file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed Configure: ${res}\n") + endif () + + ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND RETURN_VALUE res NUMBER_ERRORS errval) + if (LOCAL_SUBMIT) + ctest_submit (PARTS Build) + endif () + if (${res} LESS 0 OR ${res} GREATER 0 OR ${errval} GREATER 0) + file (APPEND ${CTEST_SCRIPT_DIRECTORY}/FailedCTest.txt "Failed ${errval} Build: ${res}\n") + endif () + + if (NOT LOCAL_SKIP_TEST) + if (NOT LOCAL_MEMCHECK_TEST) if (NOT LOCAL_BATCH_TEST) ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) else () diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index dd3b17c..dd3b17c 100755..100644 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake diff --git a/config/cmake/scripts/HDF5options.cmake b/config/cmake/scripts/HDF5options.cmake index d4cc996..d4cc996 100755..100644 --- a/config/cmake/scripts/HDF5options.cmake +++ b/config/cmake/scripts/HDF5options.cmake diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake index 40f1440..0424ed6 100644 --- a/config/cmake_ext_mod/ConfigureChecks.cmake +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -70,7 +70,7 @@ if (WIN32) set (CMAKE_REQUIRED_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1") endif () set (${HDF_PREFIX}_HAVE_WIN32_API 1) - set (CMAKE_REQUIRED_LIBRARIES "ws2_32.lib;wsock32.lib") + set (HDF5_REQUIRED_LIBRARIES "ws2_32.lib;wsock32.lib") if (NOT UNIX AND NOT MINGW) set (WINDOWS 1) set (CMAKE_REQUIRED_FLAGS "/DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1") @@ -109,6 +109,78 @@ endif () # END of WINDOWS Hard code Values # ---------------------------------------------------------------------- +if (NOT WINDOWS) + TEST_BIG_ENDIAN (${HDF_PREFIX}_WORDS_BIGENDIAN) +endif () + +#----------------------------------------------------------------------------- +# Check IF header file exists and add it to the list. +#----------------------------------------------------------------------------- +macro (CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) + CHECK_INCLUDE_FILES ("${USE_INCLUDES};${FILE}" ${VARIABLE}) + if (${VARIABLE}) + set (USE_INCLUDES ${USE_INCLUDES} ${FILE}) + endif () +endmacro () + +#----------------------------------------------------------------------------- +# Check for the existence of certain header files +#----------------------------------------------------------------------------- +CHECK_INCLUDE_FILE_CONCAT ("sys/file.h" ${HDF_PREFIX}_HAVE_SYS_FILE_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/ioctl.h" ${HDF_PREFIX}_HAVE_SYS_IOCTL_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/resource.h" ${HDF_PREFIX}_HAVE_SYS_RESOURCE_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/socket.h" ${HDF_PREFIX}_HAVE_SYS_SOCKET_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/stat.h" ${HDF_PREFIX}_HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/time.h" ${HDF_PREFIX}_HAVE_SYS_TIME_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/types.h" ${HDF_PREFIX}_HAVE_SYS_TYPES_H) +CHECK_INCLUDE_FILE_CONCAT ("features.h" ${HDF_PREFIX}_HAVE_FEATURES_H) +CHECK_INCLUDE_FILE_CONCAT ("dirent.h" ${HDF_PREFIX}_HAVE_DIRENT_H) +CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H) +CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) +CHECK_INCLUDE_FILE_CONCAT ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H) +CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) + +# Darwin +CHECK_INCLUDE_FILE_CONCAT ("mach/mach_time.h" ${HDF_PREFIX}_HAVE_MACH_MACH_TIME_H) + +# Windows +CHECK_INCLUDE_FILE_CONCAT ("io.h" ${HDF_PREFIX}_HAVE_IO_H) +if (NOT CYGWIN) + CHECK_INCLUDE_FILE_CONCAT ("winsock2.h" ${HDF_PREFIX}_HAVE_WINSOCK2_H) +endif () +CHECK_INCLUDE_FILE_CONCAT ("sys/timeb.h" ${HDF_PREFIX}_HAVE_SYS_TIMEB_H) + +if (CMAKE_SYSTEM_NAME MATCHES "OSF") + CHECK_INCLUDE_FILE_CONCAT ("sys/sysinfo.h" ${HDF_PREFIX}_HAVE_SYS_SYSINFO_H) + CHECK_INCLUDE_FILE_CONCAT ("sys/proc.h" ${HDF_PREFIX}_HAVE_SYS_PROC_H) +else () + set (${HDF_PREFIX}_HAVE_SYS_SYSINFO_H "" CACHE INTERNAL "" FORCE) + set (${HDF_PREFIX}_HAVE_SYS_PROC_H "" CACHE INTERNAL "" FORCE) +endif () + +CHECK_INCLUDE_FILE_CONCAT ("globus/common.h" ${HDF_PREFIX}_HAVE_GLOBUS_COMMON_H) +CHECK_INCLUDE_FILE_CONCAT ("pdb.h" ${HDF_PREFIX}_HAVE_PDB_H) +CHECK_INCLUDE_FILE_CONCAT ("pthread.h" ${HDF_PREFIX}_HAVE_PTHREAD_H) +CHECK_INCLUDE_FILE_CONCAT ("srbclient.h" ${HDF_PREFIX}_HAVE_SRBCLIENT_H) +CHECK_INCLUDE_FILE_CONCAT ("string.h" ${HDF_PREFIX}_HAVE_STRING_H) +CHECK_INCLUDE_FILE_CONCAT ("strings.h" ${HDF_PREFIX}_HAVE_STRINGS_H) +CHECK_INCLUDE_FILE_CONCAT ("stdlib.h" ${HDF_PREFIX}_HAVE_STDLIB_H) +CHECK_INCLUDE_FILE_CONCAT ("memory.h" ${HDF_PREFIX}_HAVE_MEMORY_H) +CHECK_INCLUDE_FILE_CONCAT ("dlfcn.h" ${HDF_PREFIX}_HAVE_DLFCN_H) +CHECK_INCLUDE_FILE_CONCAT ("inttypes.h" ${HDF_PREFIX}_HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE_CONCAT ("netinet/in.h" ${HDF_PREFIX}_HAVE_NETINET_IN_H) +# _Bool type support +CHECK_INCLUDE_FILE_CONCAT (stdbool.h ${HDF_PREFIX}_HAVE_STDBOOL_H) + +## Check for non-standard extenstion quadmath.h + +CHECK_INCLUDE_FILES(quadmath.h C_HAVE_QUADMATH) +if (${C_HAVE_QUADMATH}) + set(${HDF_PREFIX}_HAVE_QUADMATH_H 1) +else () + set(${HDF_PREFIX}_HAVE_QUADMATH_H 0) +endif () + if (CYGWIN) set (${HDF_PREFIX}_HAVE_LSEEK64 0) endif () @@ -127,17 +199,13 @@ endif () CHECK_LIBRARY_EXISTS_CONCAT ("ucb" gethostname ${HDF_PREFIX}_HAVE_LIBUCB) # For other tests to use the same libraries -set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LINK_LIBS}) +set (HDF5_REQUIRED_LIBRARIES ${HDF5_REQUIRED_LIBRARIES} ${LINK_LIBS}) set (USE_INCLUDES "") if (WINDOWS) set (USE_INCLUDES ${USE_INCLUDES} "windows.h") endif () -if (NOT WINDOWS) - TEST_BIG_ENDIAN (${HDF_PREFIX}_WORDS_BIGENDIAN) -endif () - # For other specific tests, use this MACRO. macro (HDF_FUNCTION_TEST OTHER_TEST) if (NOT DEFINED ${HDF_PREFIX}_${OTHER_TEST}) @@ -165,7 +233,7 @@ macro (HDF_FUNCTION_TEST OTHER_TEST) ${CMAKE_BINARY_DIR} ${HDF_RESOURCES_EXT_DIR}/HDFTests.c COMPILE_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS}" - LINK_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" + LINK_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}" OUTPUT_VARIABLE OUTPUT ) if (${OTHER_TEST}) @@ -188,63 +256,6 @@ endmacro () HDF_FUNCTION_TEST (STDC_HEADERS) #----------------------------------------------------------------------------- -# Check IF header file exists and add it to the list. -#----------------------------------------------------------------------------- -macro (CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) - CHECK_INCLUDE_FILES ("${USE_INCLUDES};${FILE}" ${VARIABLE}) - if (${VARIABLE}) - set (USE_INCLUDES ${USE_INCLUDES} ${FILE}) - endif () -endmacro () - -#----------------------------------------------------------------------------- -# Check for the existence of certain header files -#----------------------------------------------------------------------------- -CHECK_INCLUDE_FILE_CONCAT ("sys/file.h" ${HDF_PREFIX}_HAVE_SYS_FILE_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/ioctl.h" ${HDF_PREFIX}_HAVE_SYS_IOCTL_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/resource.h" ${HDF_PREFIX}_HAVE_SYS_RESOURCE_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/socket.h" ${HDF_PREFIX}_HAVE_SYS_SOCKET_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/stat.h" ${HDF_PREFIX}_HAVE_SYS_STAT_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/time.h" ${HDF_PREFIX}_HAVE_SYS_TIME_H) -CHECK_INCLUDE_FILE_CONCAT ("sys/types.h" ${HDF_PREFIX}_HAVE_SYS_TYPES_H) -CHECK_INCLUDE_FILE_CONCAT ("features.h" ${HDF_PREFIX}_HAVE_FEATURES_H) -CHECK_INCLUDE_FILE_CONCAT ("dirent.h" ${HDF_PREFIX}_HAVE_DIRENT_H) -CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H) -CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) -CHECK_INCLUDE_FILE_CONCAT ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H) -CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) - -# Darwin -CHECK_INCLUDE_FILE_CONCAT ("mach/mach_time.h" ${HDF_PREFIX}_HAVE_MACH_MACH_TIME_H) - -# Windows -CHECK_INCLUDE_FILE_CONCAT ("io.h" ${HDF_PREFIX}_HAVE_IO_H) -if (NOT CYGWIN) - CHECK_INCLUDE_FILE_CONCAT ("winsock2.h" ${HDF_PREFIX}_HAVE_WINSOCK2_H) -endif () -CHECK_INCLUDE_FILE_CONCAT ("sys/timeb.h" ${HDF_PREFIX}_HAVE_SYS_TIMEB_H) - -if (CMAKE_SYSTEM_NAME MATCHES "OSF") - CHECK_INCLUDE_FILE_CONCAT ("sys/sysinfo.h" ${HDF_PREFIX}_HAVE_SYS_SYSINFO_H) - CHECK_INCLUDE_FILE_CONCAT ("sys/proc.h" ${HDF_PREFIX}_HAVE_SYS_PROC_H) -else () - set (${HDF_PREFIX}_HAVE_SYS_SYSINFO_H "" CACHE INTERNAL "" FORCE) - set (${HDF_PREFIX}_HAVE_SYS_PROC_H "" CACHE INTERNAL "" FORCE) -endif () - -CHECK_INCLUDE_FILE_CONCAT ("globus/common.h" ${HDF_PREFIX}_HAVE_GLOBUS_COMMON_H) -CHECK_INCLUDE_FILE_CONCAT ("pdb.h" ${HDF_PREFIX}_HAVE_PDB_H) -CHECK_INCLUDE_FILE_CONCAT ("pthread.h" ${HDF_PREFIX}_HAVE_PTHREAD_H) -CHECK_INCLUDE_FILE_CONCAT ("srbclient.h" ${HDF_PREFIX}_HAVE_SRBCLIENT_H) -CHECK_INCLUDE_FILE_CONCAT ("string.h" ${HDF_PREFIX}_HAVE_STRING_H) -CHECK_INCLUDE_FILE_CONCAT ("strings.h" ${HDF_PREFIX}_HAVE_STRINGS_H) -CHECK_INCLUDE_FILE_CONCAT ("stdlib.h" ${HDF_PREFIX}_HAVE_STDLIB_H) -CHECK_INCLUDE_FILE_CONCAT ("memory.h" ${HDF_PREFIX}_HAVE_MEMORY_H) -CHECK_INCLUDE_FILE_CONCAT ("dlfcn.h" ${HDF_PREFIX}_HAVE_DLFCN_H) -CHECK_INCLUDE_FILE_CONCAT ("inttypes.h" ${HDF_PREFIX}_HAVE_INTTYPES_H) -CHECK_INCLUDE_FILE_CONCAT ("netinet/in.h" ${HDF_PREFIX}_HAVE_NETINET_IN_H) - -#----------------------------------------------------------------------------- # Check for large file support #----------------------------------------------------------------------------- @@ -408,7 +419,6 @@ endif () #----------------------------------------------------------------------------- # _Bool type support -CHECK_INCLUDE_FILE_CONCAT (stdbool.h ${HDF_PREFIX}_HAVE_STDBOOL_H) if (HAVE_STDBOOL_H) set (CMAKE_EXTRA_INCLUDE_FILES stdbool.h) HDF_CHECK_TYPE_SIZE (bool ${HDF_PREFIX}_SIZEOF_BOOL) @@ -580,7 +590,7 @@ if (WINDOWS) ${CMAKE_BINARY_DIR} ${HDF_RESOURCES_EXT_DIR}/HDFTests.c COMPILE_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS} ${MACRO_CHECK_FUNCTION_DEFINITIONS}" - LINK_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" + LINK_LIBRARIES "${HDF5_REQUIRED_LIBRARIES}" CMAKE_FLAGS "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES} -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}" COMPILE_OUTPUT_VARIABLE OUTPUT ) diff --git a/config/cmake_ext_mod/HDFUseCXX.cmake b/config/cmake_ext_mod/HDFUseCXX.cmake index f293ec5..efaa556 100644 --- a/config/cmake_ext_mod/HDFUseCXX.cmake +++ b/config/cmake_ext_mod/HDFUseCXX.cmake @@ -48,8 +48,8 @@ macro (HDF_CXX_FUNCTION_TEST OTHER_TEST) if (NOT DEFINED ${OTHER_TEST}) set (MACRO_CHECK_FUNCTION_DEFINITIONS "-D${OTHER_TEST} ${CMAKE_REQUIRED_FLAGS}") set (OTHER_TEST_ADD_LIBRARIES) - if (CMAKE_REQUIRED_LIBRARIES) - set (OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + if (HDF5_REQUIRED_LIBRARIES) + set (OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") endif () foreach (def diff --git a/config/cmake_ext_mod/HDFUseFortran.cmake b/config/cmake_ext_mod/HDFUseFortran.cmake index f8f3cea..c68c921 100644 --- a/config/cmake_ext_mod/HDFUseFortran.cmake +++ b/config/cmake_ext_mod/HDFUseFortran.cmake @@ -48,9 +48,9 @@ set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) ${CMAKE_MATCH_1}") #----------------------------------------------------------------------------- macro (CHECK_FORTRAN_FEATURE FUNCTION CODE VARIABLE) message (STATUS "Testing Fortran ${FUNCTION}") - if (CMAKE_REQUIRED_LIBRARIES) + if (HDF5_REQUIRED_LIBRARIES) set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + "-DLINK_LIBRARIES:STRING=${HDF5_REQUIRED_LIBRARIES}") else () set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) endif () diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 8181ff0..026131b 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -97,10 +97,10 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") if (NOT ERROR_APPEND) - # append error output to the stdout output file + # write back to original .err file file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") else () - # write back to original .err file + # append error output to the stdout output file file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") endif () endif () @@ -125,8 +125,11 @@ message (STATUS "COMMAND Error: ${TEST_ERROR}") # remove special output file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) -string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") -file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +string (FIND TEST_STREAM "_pmi_alps" "${TEST_FIND_RESULT}") +if ("${TEST_FIND_RESULT}" GREATER "0") + string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_STREAM}) +endif () # if the output file needs Storage text removed if (TEST_MASK) diff --git a/config/conclude.am b/config/conclude.am index d0dbf3a..9da1da5 100644 --- a/config/conclude.am +++ b/config/conclude.am @@ -249,7 +249,7 @@ build-check-p: $(LIB) $(PROGS) $(chk_TESTS) echo "**** Hint ****"; \ echo "Parallel test files reside in the current directory" \ "by default."; \ - echo "Set HDF5_PARAPREFIX to use another directory. E.g.,"; \ + echo "Set HDF5_PARAPREFIX to use another directory. e.g.,"; \ echo " HDF5_PARAPREFIX=/PFS/user/me"; \ echo " export HDF5_PARAPREFIX"; \ echo " make check"; \ diff --git a/config/toolchain/GCC.cmake b/config/toolchain/GCC.cmake index ddb1641..c41d0ca 100644 --- a/config/toolchain/GCC.cmake +++ b/config/toolchain/GCC.cmake @@ -1,5 +1,6 @@ -# Uncomment the following to use cross-compiling +# Uncomment the following line and the correct system name to use cross-compiling #set(CMAKE_SYSTEM_NAME Linux) + set(CMAKE_COMPILER_VENDOR "GCC") set(CMAKE_C_COMPILER cc) diff --git a/config/toolchain/PGI.cmake b/config/toolchain/PGI.cmake new file mode 100644 index 0000000..ec58cbb --- /dev/null +++ b/config/toolchain/PGI.cmake @@ -0,0 +1,11 @@ +# Uncomment the following to use cross-compiling +#set(CMAKE_SYSTEM_NAME Linux) + +set(CMAKE_COMPILER_VENDOR "PGI") + +set(CMAKE_C_COMPILER pgcc) +set(CMAKE_CXX_COMPILER pgc++) +set(CMAKE_Fortran_COMPILER pgf90) + +# the following is used if cross-compiling +set(CMAKE_CROSSCOMPILING_EMULATOR "") diff --git a/config/toolchain/crayle.cmake b/config/toolchain/crayle.cmake index a83147b..47d8afc 100644 --- a/config/toolchain/crayle.cmake +++ b/config/toolchain/crayle.cmake @@ -1,5 +1,6 @@ -# Uncomment the following to use cross-compiling +# The following line will use cross-compiling set(CMAKE_SYSTEM_NAME Linux) + set(CMAKE_COMPILER_VENDOR "CrayLinuxEnvironment") set(CMAKE_C_COMPILER cc) diff --git a/config/toolchain/intel.cmake b/config/toolchain/intel.cmake index f1a5734..97f6a64 100644 --- a/config/toolchain/intel.cmake +++ b/config/toolchain/intel.cmake @@ -1,5 +1,6 @@ # Uncomment the following to use cross-compiling #set(CMAKE_SYSTEM_NAME Linux) + set(CMAKE_COMPILER_VENDOR "intel") set(CMAKE_C_COMPILER icc) diff --git a/configure.ac b/configure.ac index 0a1370f..21ad68b 100644 --- a/configure.ac +++ b/configure.ac @@ -2289,40 +2289,6 @@ case "X-$CODESTACK" in esac ## ---------------------------------------------------------------------- -## Check if they would like the metadata trace file code compiled in -## -AC_MSG_CHECKING([whether metadata trace file code is enabled]) -AC_ARG_ENABLE([metadata-trace-file], - [AS_HELP_STRING([--enable-metadata-trace-file], - [Enable metadata trace file collection. - [default=no] - ])], - [METADATATRACEFILE=$enableval]) - -## Set the default level. -if test "X-$METADATATRACEFILE" = X- ; then - METADATATRACEFILE=no -fi - -## Allow this variable to be substituted in -## other files (src/libhdf5.settings.in, etc.) -AC_SUBST([METADATATRACEFILE]) - -case "X-$METADATATRACEFILE" in - X-yes) - AC_MSG_RESULT([yes]) - AC_DEFINE([METADATA_TRACE_FILE], [1], - [Define if the metadata trace file code is to be compiled in]) - ;; - X-no) - AC_MSG_RESULT([no]) - ;; - *) - AC_MSG_ERROR([Unrecognized value: $METADATATRACEFILE]) - ;; -esac - -## ---------------------------------------------------------------------- ## Enable tracing of the API ## AC_MSG_CHECKING([for API tracing]); @@ -3433,6 +3399,7 @@ AC_CONFIG_FILES([src/libhdf5.settings src/Makefile test/Makefile test/H5srcdir_str.h + test/testabort_fail.sh test/testcheck_version.sh test/testerror.sh test/testflushrefresh.sh @@ -3440,10 +3407,11 @@ AC_CONFIG_FILES([src/libhdf5.settings test/testlinks_env.sh test/testswmr.sh test/testvdsswmr.sh - test/test_filenotclosed.sh test/test_filter_plugin.sh test/test_usecases.sh + test/test_vol_plugin.sh testpar/Makefile + testpar/testpflush.sh tools/Makefile tools/lib/Makefile tools/src/Makefile diff --git a/hl/fortran/src/Makefile.am b/hl/fortran/src/Makefile.am index a495e220..200a2ce 100644 --- a/hl/fortran/src/Makefile.am +++ b/hl/fortran/src/Makefile.am @@ -50,6 +50,19 @@ libhdf5hl_fortran_la_SOURCES=H5DSfc.c H5LTfc.c H5IMfc.c H5IMcc.c H5TBfc.c \ # HDF5 HL Fortran library depends on HDF5 Library. libhdf5hl_fortran_la_LIBADD=$(LIBH5_HL) $(LIBH5F) +# The name of the lib file doesn't follow the same pattern as the other hl lib +# files, namely libhdf5_hl_*. Add a symlink with the compliant name to the +# actual lib file. +install-exec-hook: + cd $(DESTDIR)$(libdir) && \ + if test -f libhdf5hl_fortran.a; then \ + $(LN_S) libhdf5hl_fortran.a libhdf5_hl_fortran.a; \ + fi; \ + if test -f libhdf5hl_fortran.so; then \ + $(LN_S) libhdf5hl_fortran.so libhdf5_hl_fortran.so; \ + fi; + + # Fortran module files can have different extensions and different names # (e.g., different capitalizations) on different platforms. Write rules # for them explicitly rather than trying to teach automake about them. @@ -72,6 +85,7 @@ uninstall-local: set -x; $(RM) $(includedir)/*.$(F9XMODEXT); \ fi; \ fi + $(RM) $(DESTDIR)$(libdir)/libhdf5_hl_fortran* # These are the helper programs we need to build. noinst_PROGRAMS = H5HL_buildiface diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index e354207..51b0d38 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -3229,13 +3229,56 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Fget_mdc_logging_status(long file_id, boolean[] mdc_logging_status) throws HDF5LibraryException, NullPointerException; + /** + * H5Fget_dset_no_attrs_hint gets the file-level setting to create minimized dataset object headers. + * + * @param file_id + * IN: Identifier of the target file. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native boolean H5Fget_dset_no_attrs_hint(long file_id) + throws HDF5LibraryException; + + + /** + * H5Fset_dset_no_attrs_hint sets the file-level setting to create minimized dataset object headers. + * + * @param file_id + * IN: Identifier of the target file. + * @param minimize + * the minimize hint setting + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native void H5Fset_dset_no_attrs_hint(long file_id, boolean minimize) + throws HDF5LibraryException; + + + /** + * H5Fset_libver_bounds sets a different low and high bounds while a file is open. + * + * @param file_id + * IN: Identifier of the target file. + * @param low + * IN: The earliest version of the library that will be used for writing objects + * @param high + * IN: The latest version of the library that will be used for writing objects. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native void H5Fset_libver_bounds(long file_id, int low, int high) + throws HDF5LibraryException; + // /////// unimplemented //////// // herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); // herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); // ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len); // herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); // ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/); - // herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); // herr_t H5Fformat_convert(hid_t fid); // herr_t H5Freset_page_buffering_stats(hid_t file_id); // herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], @@ -6922,8 +6965,6 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Pset_fill_time(long plist_id, int fill_time) throws HDF5LibraryException, NullPointerException; - // /////// Dataset creation property list (DCPL) routines /////// - /** * H5Pset_chunk_opts Sets the edge chunk option in a dataset creation property list. * @@ -6952,6 +6993,36 @@ public class H5 implements java.io.Serializable { **/ public synchronized static native int H5Pget_chunk_opts(long dcpl_id) throws HDF5LibraryException; + /** + * H5Pget_dset_no_attrs_hint accesses the flag for whether or not datasets created by the given dcpl + * will be created with a "minimized" object header. + * + * @param dcpl_id + * IN: Dataset creation property list + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native boolean H5Pget_dset_no_attrs_hint(long dcpl_id) + throws HDF5LibraryException; + + + /** + * H5Pset_dset_no_attrs_hint sets the dcpl to minimize (or explicitly to not minimized) dataset object + * headers upon creation. + * + * @param dcpl_id + * IN: Dataset creation property list + * + * @param minimize + * the minimize hint setting + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + **/ + public synchronized static native void H5Pset_dset_no_attrs_hint(long dcpl_id, boolean minimize) + throws HDF5LibraryException; + // /////// Dataset access property list (DAPL) routines /////// /** diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 248e654..80adffb 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -149,6 +149,9 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 (JNIEnv *env, jclass clss, jstring name) { htri_t bval = JNI_FALSE; +#ifdef H5_NO_DEPRECATED_SYMBOLS + h5unimplemented(env, "H5Fis_hdf5: not implemented"); +#else const char *fileName; PIN_JAVA_STRING(name, fileName); @@ -162,7 +165,7 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 else if (bval < 0) h5libraryError(env); } - +#endif return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Fis_1hdf5 */ @@ -636,6 +639,66 @@ Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status } /* end else */ } /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fset_dset_no_attrs_hint + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint +(JNIEnv *env, jclass clss, jlong file_id, jboolean minimize) +{ + herr_t retVal = -1; + hbool_t minimize_val; + + if (minimize == JNI_TRUE) + minimize_val = TRUE; + else + minimize_val = FALSE; + + retVal = H5Fset_dset_no_attrs_hint((hid_t)file_id, (hbool_t)minimize_val); + if (retVal < 0) + h5libraryError(env); +} + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_dset_no_attrs_hint + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint +(JNIEnv *env, jclass clss, jlong file_id) +{ + hbool_t minimize = FALSE; + jboolean bval = JNI_FALSE; + + if (H5Fget_dset_no_attrs_hint((hid_t)file_id, (hbool_t *)&minimize) < 0) { + h5libraryError(env); + } + else { + if (minimize == TRUE) + bval = JNI_TRUE; + } /* end else */ + + return bval; +} + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fset_libver_bounds + * Signature: (JII)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds + (JNIEnv *env, jclass clss, jlong file_id, jint low, jint high) +{ + herr_t retVal = -1; + + retVal = H5Fset_libver_bounds((hid_t)file_id, (H5F_libver_t)low, (H5F_libver_t)high); + if(retVal < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds */ #ifdef __cplusplus diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index af0fa1d..fe253f9 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -255,6 +255,33 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status (JNIEnv *, jclass, jlong, jbooleanArray); +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fset_dset_no_attrs_hint + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint + (JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fget_dset_no_attrs_hint + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Fset_libver_bounds + * Signature: (JII)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds +(JNIEnv *, jclass, jlong, jint, jint); + #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index 52008ce..19f9640 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -5946,6 +5946,51 @@ Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts return (jint)opts; } /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_dset_no_attrs_hint + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint +(JNIEnv *env, jclass clss, jlong dcpl_id, jboolean minimize) +{ + herr_t retVal = -1; + hbool_t minimize_val; + + if (minimize == JNI_TRUE) + minimize_val = TRUE; + else + minimize_val = FALSE; + + retVal = H5Pset_dset_no_attrs_hint((hid_t)dcpl_id, (hbool_t)minimize_val); + if (retVal < 0) + h5libraryError(env); +} + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_dset_no_attrs_hint + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint +(JNIEnv *env, jclass clss, jlong dcpl_id) +{ + hbool_t minimize = FALSE; + jboolean bval = JNI_FALSE; + + if (H5Pget_dset_no_attrs_hint((hid_t)dcpl_id, (hbool_t *)&minimize) < 0) { + h5libraryError(env); + } + else { + if (minimize == TRUE) + bval = JNI_TRUE; + } /* end else */ + + return bval; +} + #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5pImp.h b/java/src/jni/h5pImp.h index 1d12e3d..0a603f7 100644 --- a/java/src/jni/h5pImp.h +++ b/java/src/jni/h5pImp.h @@ -1614,6 +1614,24 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts (JNIEnv *, jclass, jlong); +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_dset_no_attrs_hint + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint + (JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_dset_no_attrs_hint + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint + (JNIEnv *, jclass, jlong); + #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/test/TestH5Dplist.java b/java/test/TestH5Dplist.java index 406a1d3..1b5acfa 100644 --- a/java/test/TestH5Dplist.java +++ b/java/test/TestH5Dplist.java @@ -13,6 +13,7 @@ package test; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -211,4 +212,23 @@ public class TestH5Dplist { assertTrue("testH5Dset_extent - H5.H5Dread: ", extend_dset_data[4][8] == 99); } + @Test + public void testH5P_dset_no_attrs_hint() { + boolean ret_val_id = true; + + _createPDataset(H5fid, H5dsid, "dset", HDF5Constants.H5P_DATASET_CREATE); + + try { + ret_val_id = H5.H5Pget_dset_no_attrs_hint(H5dcpl_id); + assertFalse("H5P_dset_no_attrs_hint", ret_val_id); + H5.H5Pset_dset_no_attrs_hint(H5dcpl_id, true); + ret_val_id = H5.H5Pget_dset_no_attrs_hint(H5dcpl_id); + assertTrue("H5P_dset_no_attrs_hint", ret_val_id); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5P_dset_no_attrs_hint: " + err); + } + } + } diff --git a/java/test/TestH5Fbasic.java b/java/test/TestH5Fbasic.java index a5afb6e..72a3c23 100644 --- a/java/test/TestH5Fbasic.java +++ b/java/test/TestH5Fbasic.java @@ -14,6 +14,7 @@ package test; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -69,19 +70,6 @@ public class TestH5Fbasic { } @Test - public void testH5Fis_hdf5() { - boolean isH5 = false; - - try { - isH5 = H5.H5Fis_hdf5(H5_FILE); - } - catch (Throwable err) { - fail("H5.H5Fis_hdf5 failed on " + H5_FILE + ": " + err); - } - assertTrue(isH5 == true); - } - - @Test public void testH5Fis_accessible() { boolean isH5 = false; @@ -328,4 +316,20 @@ public class TestH5Fbasic { fail("H5.H5Freset_mdc_hit_rate_stats: " + err); } } + + @Test + public void testH5F_dset_no_attrs_hint() { + boolean ret_val_id = true; + try { + ret_val_id = H5.H5Fget_dset_no_attrs_hint(H5fid); + assertFalse("H5F_dset_no_attrs_hint", ret_val_id); + H5.H5Fset_dset_no_attrs_hint(H5fid, true); + ret_val_id = H5.H5Fget_dset_no_attrs_hint(H5fid); + assertTrue("H5F_dset_no_attrs_hint", ret_val_id); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5F_dset_no_attrs_hint: " + err); + } + } } diff --git a/java/test/TestH5Fparams.java b/java/test/TestH5Fparams.java index 3d64aa9..40cbe4b 100644 --- a/java/test/TestH5Fparams.java +++ b/java/test/TestH5Fparams.java @@ -22,10 +22,12 @@ import java.io.File; import hdf.hdf5lib.H5; import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.exceptions.HDF5FunctionArgumentException; import hdf.hdf5lib.structs.H5F_info2_t; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TestName; @@ -55,11 +57,6 @@ public class TestH5Fparams { } @Test(expected = NullPointerException.class) - public void testH5Fis_hdf5_null() throws Throwable { - H5.H5Fis_hdf5(null); - } - - @Test(expected = NullPointerException.class) public void testH5Fis_accessible_null() throws Throwable { H5.H5Fis_accessible(null, -1); } @@ -74,7 +71,7 @@ public class TestH5Fparams { H5.H5Funmount(-1, null); } - @Test + @Ignore public void testH5Fis_hdf5_text() { File txtFile = null; boolean isH5 = false; @@ -195,7 +192,7 @@ public class TestH5Fparams { HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); } catch (Throwable err) { - fail("H5.H5Fopen: " + err); + fail("H5.H5Fcreate: " + err); } try { @@ -215,4 +212,42 @@ public class TestH5Fparams { try {H5.H5Fclose(fid);} catch (Exception ex) {} } } + + @Ignore//(expected = HDF5FunctionArgumentException.class) + public void testH5Fset_libver_bounds_invalidlow() throws Throwable { + long fid = -1; + + try { + try { + fid = H5.H5Fcreate("test.h5", HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fcreate: " + err); + } + H5.H5Fset_libver_bounds(fid, 5, HDF5Constants.H5F_LIBVER_LATEST); + } + finally { + try {H5.H5Fclose(fid);} catch (Exception ex) {} + } + } + + @Ignore//(expected = HDF5FunctionArgumentException.class) + public void testH5Fset_libver_bounds_invalidhigh() throws Throwable { + long fid = -1; + + try { + try { + fid = H5.H5Fcreate("test.h5", HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fcreate: " + err); + } + H5.H5Fset_libver_bounds(fid, HDF5Constants.H5F_LIBVER_V110, HDF5Constants.H5F_LIBVER_V110+1); + } + finally { + try {H5.H5Fclose(fid);} catch (Exception ex) {} + } + } } diff --git a/java/test/testfiles/JUnit-TestH5Dplist.txt b/java/test/testfiles/JUnit-TestH5Dplist.txt index 1dfbed1..64e924a 100644 --- a/java/test/testfiles/JUnit-TestH5Dplist.txt +++ b/java/test/testfiles/JUnit-TestH5Dplist.txt @@ -1,7 +1,8 @@ JUnit version 4.11 +.testH5P_dset_no_attrs_hint .testH5Dset_extent Time: XXXX -OK (1 test) +OK (2 tests) diff --git a/java/test/testfiles/JUnit-TestH5Fbasic.txt b/java/test/testfiles/JUnit-TestH5Fbasic.txt index 2654624..cd4e282 100644 --- a/java/test/testfiles/JUnit-TestH5Fbasic.txt +++ b/java/test/testfiles/JUnit-TestH5Fbasic.txt @@ -1,7 +1,7 @@ JUnit version 4.11 .testH5Fget_mdc_size .testH5Fget_mdc_hit_rate -.testH5Fis_hdf5 +.testH5F_dset_no_attrs_hint .testH5Fget_freespace .testH5Fclose .testH5Fget_filesize diff --git a/java/test/testfiles/JUnit-TestH5Fparams.txt b/java/test/testfiles/JUnit-TestH5Fparams.txt index e91cbdc..91a8435 100644 --- a/java/test/testfiles/JUnit-TestH5Fparams.txt +++ b/java/test/testfiles/JUnit-TestH5Fparams.txt @@ -9,10 +9,8 @@ JUnit version 4.11 .testH5Funmount_null .testH5Fclose_negative .testH5Fopen_null -.testH5Fis_hdf5_null -.testH5Fis_hdf5_text Time: XXXX -OK (12 tests) +OK (10 tests) diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index 8acd35f..26cf3ce 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -641,7 +641,6 @@ HDF5_GENERATE_HEADERS "Rebuild Generated Files" HDF5_BUILD_GENERATORS "Build Test Generators" OFF HDF5_JAVA_PACK_JRE "Package a JRE installer directory" OFF HDF5_MEMORY_ALLOC_SANITY_CHECK "Indicate that internal memory allocation sanity checks are enabled" OFF -HDF5_METADATA_TRACE_FILE "Enable metadata trace file collection" OFF HDF5_NO_PACKAGES "Do not include CPack Packaging" OFF HDF5_PACK_EXAMPLES "Package the HDF5 Library Examples Compressed File" OFF HDF5_PACK_MACOSX_FRAMEWORK "Package the HDF5 Library in a Frameworks" OFF diff --git a/release_docs/INSTALL_parallel b/release_docs/INSTALL_parallel index f32fffc..d3d7830 100644 --- a/release_docs/INSTALL_parallel +++ b/release_docs/INSTALL_parallel @@ -102,7 +102,7 @@ qsub -I -q debug -l mppwidth=8 - configure HDF5: RUNSERIAL="aprun -q -n 1" RUNPARALLEL="aprun -q -n 6" FC=ftn CC=cc /path/to/source/configure --enable-fortran --enable-parallel --disable-shared - RUNSERIAL and RUNPARALLEL tells the library how it should launch programs that are part of the build procedure. + RUNSERIAL and RUNPARALLEL tell the library how it should launch programs that are part of the build procedure. - Compile HDF5: gmake @@ -155,12 +155,16 @@ to run a parallel application on one processor and on many processors. If the compiler is `mpicc' and the user hasn't specified values for RUNSERIAL and RUNPARALLEL then configure chooses `mpiexec' from the same directory as `mpicc': - RUNSERIAL: /usr/local/mpi/bin/mpiexec -np 1 - RUNPARALLEL: /usr/local/mpi/bin/mpiexec -np $${NPROCS:=6} + RUNSERIAL: mpiexec -n 1 + RUNPARALLEL: mpiexec -n $${NPROCS:=6} The `$${NPROCS:=6}' will be substituted with the value of the NPROCS environment variable at the time `make check' is run (or the value 6). +Note that some MPI implementations (e.g. OpenMPI 4.0) disallow oversubscribing +nodes by default so you'll have to either set NPROCS equal to the number of +processors available (or fewer) or redefine RUNPARALLEL with appropriate +flag(s) (--oversubscribe in OpenMPI). 4. Parallel test suite ---------------------- diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 024db9a..ff18e71 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -1,4 +1,4 @@ -HDF5 version 1.11.4 currently under development + version 1.11.4 currently under development ================================================================================ @@ -243,6 +243,19 @@ Bug Fixes since HDF5-1.10.3 release Library ------- + - Deleting attributes in dense storage + + The library aborts with "infinite loop closing library" after + attributes in dense storage are created and then deleted. + + When deleting the attribute nodes from the name index v2 B-tree, + if an attribute is found in the intermediate B-tree nodes, + which may be merged/redistributed in the process, we need to + free the dynamically allocated spaces for the intermediate + decoded attribute. + + (VC - 2018/12/26, HDFFV-10659) + - Allow H5detect and H5make_libsettings to take a file as an argument. Rather than only writing to stdout, add a command argument to name @@ -314,6 +327,15 @@ Bug Fixes since HDF5-1.10.3 release Fortran -------- + - Added symbolic links libhdf5_hl_fortran.so to libhdf5hl_fortran.so and + libhdf5_hl_fortran.a to libhdf5hl_fortran.a in hdf5/lib directory for + autotools installs. These were added to match the name of the files + installed by cmake and the general pattern of hl lib files. We will + change the names of the installed lib files to the matching name in + the next major release. + + (LRK - 2019/01/04, HDFFV-10596) + - Made Fortran specific subroutines PRIVATE in generic procedures. Effected generic procedures were functions in H5A, H5D, H5P, H5R and H5T. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c9a2fda..40b64f5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -39,7 +39,6 @@ IDE_GENERATED_PROPERTIES ("H5A" "${H5A_HDRS}" "${H5A_SOURCES}" ) set (H5AC_SOURCES ${HDF5_SRC_DIR}/H5AC.c ${HDF5_SRC_DIR}/H5ACdbg.c - ${HDF5_SRC_DIR}/H5AClog.c ${HDF5_SRC_DIR}/H5ACmpio.c ${HDF5_SRC_DIR}/H5ACproxy_entry.c ) @@ -81,6 +80,8 @@ set (H5C_SOURCES ${HDF5_SRC_DIR}/H5Cepoch.c ${HDF5_SRC_DIR}/H5Cimage.c ${HDF5_SRC_DIR}/H5Clog.c + ${HDF5_SRC_DIR}/H5Clog_json.c + ${HDF5_SRC_DIR}/H5Clog_trace.c ${HDF5_SRC_DIR}/H5Cmpio.c ${HDF5_SRC_DIR}/H5Cprefetched.c ${HDF5_SRC_DIR}/H5Cquery.c @@ -779,6 +780,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5B2pkg.h ${HDF5_SRC_DIR}/H5B2private.h + ${HDF5_SRC_DIR}/H5Clog.h ${HDF5_SRC_DIR}/H5Cpkg.h ${HDF5_SRC_DIR}/H5Cprivate.h @@ -1201,10 +1201,16 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) H5TRACE3("e", "i*s*s", loc_id, old_name, new_name); /* check arguments */ - if(!old_name || !new_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "name is nil") if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + if(!old_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be NULL") + if(!*old_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "old attribute name cannot be an empty string") + if(!new_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be NULL") + if(!*new_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "new attribute name cannot be an empty string") /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_name, new_name)) { @@ -30,22 +30,24 @@ /****************/ #include "H5ACmodule.h" /* This source code file is part of the H5AC module */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#define H5C_FRIEND /* Suppress error about including H5Cpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SLprivate.h" /* Skip Lists */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Cpkg.h" /* Cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SLprivate.h" /* Skip Lists */ /****************/ @@ -128,7 +130,7 @@ static const H5AC_class_t *const H5AC_class_s[] = { H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ - H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ + H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ }; @@ -178,13 +180,16 @@ H5AC__init_package(void) #ifdef H5_HAVE_PARALLEL /* check whether to enable strict collective function calling - sanity checks using MPI barriers */ + * sanity checks using MPI barriers + */ { const char *s; /* String for environment variables */ s = HDgetenv("H5_COLL_API_SANITY_CHECK"); - if(s && HDisdigit(*s)) - H5_coll_api_sanity_check_g = (hbool_t)HDstrtol(s, NULL, 0); + if(s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); + H5_coll_api_sanity_check_g = (0 == env_val) ? FALSE : TRUE; + } } #endif /* H5_HAVE_PARALLEL */ @@ -403,15 +408,13 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "H5C_set_prefix() failed") #endif /* H5_HAVE_PARALLEL */ - /* Turn on metadata cache logging, if being used */ - if(H5F_USE_MDC_LOGGING(f)) { - if(H5C_set_up_logging(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTINIT, FAIL, "mdc logging setup failed") - - /* Write the log header regardless of current logging status */ - if(H5AC__write_create_cache_log_msg(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - } /* end if */ + /* Turn on metadata cache logging, if being used + * This will be JSON until we create a special API call. Trace output + * is generated when logging is controlled by the struct. + */ + if(H5F_USE_MDC_LOGGING(f)) + if(H5C_log_set_up(f->shared->cache, H5F_MDC_LOG_LOCATION(f), H5C_LOG_STYLE_JSON, H5F_START_MDC_LOG_ON_ACCESS(f)) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") /* Set the cache parameters */ if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) @@ -431,6 +434,11 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_co HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "auto resize configuration failed") done: + /* If currently logging, generate a message */ + if(f->shared->cache->log_info->logging) + if(H5C_log_write_create_cache_msg(f->shared->cache, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + #ifdef H5_HAVE_PARALLEL /* if there is a failure, try to tidy up the auxiliary structure */ if(ret_value < 0) { @@ -469,6 +477,8 @@ done: herr_t H5AC_dest(H5F_t *f) { + hbool_t log_enabled; /* TRUE if logging was set up */ + hbool_t curr_logging; /* TRUE if currently logging */ #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ @@ -486,18 +496,16 @@ H5AC_dest(H5F_t *f) H5AC_stats(f); #endif /* H5AC_DUMP_STATS_ON_CLOSE */ -#if H5AC__TRACE_FILE_ENABLED - if(H5AC__close_trace_file(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__close_trace_file() failed") -#endif /* H5AC__TRACE_FILE_ENABLED */ - - if(H5F_USE_MDC_LOGGING(f)) { - /* Write the log footer regardless of current logging status */ - if(H5AC__write_destroy_cache_log_msg(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - if(H5C_tear_down_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "mdc logging tear-down failed") - } /* end if */ + /* Check if log messages are being emitted */ + if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to get logging status") + if(log_enabled && curr_logging) + if(H5C_log_write_destroy_cache_msg(f->shared->cache) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + /* Tear down logging */ + if(log_enabled) + if(H5C_log_tear_down(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") #ifdef H5_HAVE_PARALLEL /* destroying the cache, so clear all collective entries */ @@ -565,8 +573,6 @@ done: herr_t H5AC_evict(H5F_t *f) { - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -576,10 +582,6 @@ H5AC_evict(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Evict all entries in the cache except the pinned superblock entry */ if(H5C_evict(f) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFREE, FAIL, "can't evict cache") @@ -587,9 +589,9 @@ H5AC_evict(H5F_t *f) done: /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_evict_cache_log_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_evict_cache_msg(f->shared->cache, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_evict() */ @@ -613,12 +615,6 @@ herr_t H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, unsigned flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -631,36 +627,14 @@ H5AC_expunge_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, HDassert(type->serialize); HDassert(H5F_addr_defined(addr)); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED -{ - H5AC_t * cache_ptr = f->shared->cache; - - /* For the expunge entry call, only the addr, and type id are really - * necessary in the trace file. Write the return value to catch occult - * errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d", FUNC, (unsigned long)addr, (int)(type->id)); -} -#endif /* H5AC__TRACE_FILE_ENABLED */ - if(H5C_expunge_entry(f, type, addr, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTEXPUNGE, FAIL, "H5C_expunge_entry() failed") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_expunge_entry_log_msg(f->shared->cache, addr, type->id, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_expunge_entry_msg(f->shared->cache, addr, type->id, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_expunge_entry() */ @@ -689,12 +663,6 @@ done: herr_t H5AC_flush(H5F_t *f) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -704,18 +672,6 @@ H5AC_flush(H5F_t *f) HDassert(f->shared); HDassert(f->shared->cache); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* For the flush, only the flags are really necessary in the trace file. - * Write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s", FUNC); -#endif /* H5AC__TRACE_FILE_ENABLED */ - #ifdef H5_HAVE_PARALLEL /* flushing the cache, so clear all collective entries */ if(H5C_clear_coll_entries(f->shared->cache, FALSE) < 0) @@ -732,15 +688,10 @@ H5AC_flush(H5F_t *f) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush cache") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_flush_cache_log_msg(f->shared->cache, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_flush_cache_msg(f->shared->cache, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_flush() */ @@ -873,13 +824,6 @@ herr_t H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned int flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - size_t trace_entry_size = 0; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -893,26 +837,9 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert(H5F_addr_defined(addr)); HDassert(thing); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Check for invalid access request */ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") - -#if H5AC__TRACE_FILE_ENABLED - /* For the insert, only the addr, size, type id and flags are really - * necessary in the trace file. Write the result to catch occult - * errors. - * - * Note that some data is not available right now -- put what we can - * in the trace buffer now, and fill in the rest at the end. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d 0x%x", FUNC, (unsigned long)addr, type->id, - flags); -#endif /* H5AC__TRACE_FILE_ENABLED */ + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "no write intent on file") #if H5AC_DO_TAGGING_SANITY_CHECKS if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) @@ -923,12 +850,6 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, if(H5C_insert_entry(f, type, addr, thing, flags) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5C_insert_entry() failed") -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - /* make note of the entry size */ - trace_entry_size = ((H5C_cache_entry_t *)thing)->size; -#endif /* H5AC__TRACE_FILE_ENABLED */ - #ifdef H5_HAVE_PARALLEL { H5AC_aux_t *aux_ptr; @@ -947,14 +868,10 @@ H5AC_insert_entry(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d %d\n", trace, (int)trace_entry_size, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_insert_entry_log_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_insert_entry_msg(f->shared->cache, addr, type->id, flags, ((H5C_cache_entry_t *)thing)->size, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_insert_entry() */ @@ -1011,12 +928,6 @@ done: herr_t H5AC_mark_entry_dirty(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1030,19 +941,6 @@ H5AC_mark_entry_dirty(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; -#if H5AC__TRACE_FILE_ENABLED - /* For the mark pinned or protected entry dirty call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(entry_ptr->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - #ifdef H5_HAVE_PARALLEL { H5AC_aux_t *aux_ptr; @@ -1059,15 +957,10 @@ H5AC_mark_entry_dirty(void *thing) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't mark pinned or protected entry dirty") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_dirty_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_entry_dirty_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_dirty() */ @@ -1076,7 +969,7 @@ done: /*------------------------------------------------------------------------- * Function: H5AC_mark_entry_clean * - * Purpose: Mark a pinned entry as dirty. The target + * Purpose: Mark a pinned entry as clean. The target * entry MUST be pinned. * * Return: Non-negative on success/Negative on failure @@ -1089,12 +982,6 @@ done: herr_t H5AC_mark_entry_clean(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1104,23 +991,9 @@ H5AC_mark_entry_clean(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the mark pinned or protected entry clean call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - #ifdef H5_HAVE_PARALLEL { H5AC_aux_t *aux_ptr; @@ -1137,15 +1010,10 @@ H5AC_mark_entry_clean(void *thing) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKCLEAN, FAIL, "can't mark pinned or protected entry clean") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_clean_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_entry_clean_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_clean() */ @@ -1167,12 +1035,6 @@ done: herr_t H5AC_mark_entry_unserialized(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1186,32 +1048,14 @@ H5AC_mark_entry_unserialized(void *thing) entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; -#if H5AC__TRACE_FILE_ENABLED - /* For the mark entry unserialized call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(entry_ptr->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get logging status") - if(H5C_mark_entry_unserialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKUNSERIALIZED, FAIL, "can't mark entry unserialized") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_unserialized_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_unserialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_unserialized() */ @@ -1233,12 +1077,6 @@ done: herr_t H5AC_mark_entry_serialized(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1248,36 +1086,17 @@ H5AC_mark_entry_serialized(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the mark entry serializedn call, only the addr - * is really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get logging status") - if(H5C_mark_entry_serialized(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKSERIALIZED, FAIL, "can't mark entry serialized") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_mark_serialized_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_mark_serialized_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_mark_entry_serialized() */ @@ -1300,15 +1119,9 @@ done: herr_t H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ #ifdef H5_HAVE_PARALLEL H5AC_aux_t *aux_ptr; #endif /* H5_HAVE_PARALLEL */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1321,20 +1134,6 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne HDassert(H5F_addr_defined(new_addr)); HDassert(H5F_addr_ne(old_addr, new_addr)); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* For the move call, only the old addr and new addr are really - * necessary in the trace file. Include the type id so we don't have to - * look it up. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx 0x%lx %d", FUNC, (unsigned long)old_addr, - (unsigned long)new_addr, (int)(type->id)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - #ifdef H5_HAVE_PARALLEL /* Log moving the entry */ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) @@ -1353,15 +1152,10 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_move_entry_log_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_move_entry_msg(f->shared->cache, old_addr, new_addr, type->id, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_move_entry() */ @@ -1383,12 +1177,6 @@ done: herr_t H5AC_pin_protected_entry(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1398,37 +1186,19 @@ H5AC_pin_protected_entry(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the pin protected entry call, only the addr is really necessary - * in the trace file. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Pin entry */ if(H5C_pin_protected_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTPIN, FAIL, "can't pin entry") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_pin_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_pin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_pin_protected_entry() */ @@ -1488,12 +1258,6 @@ done: herr_t H5AC_create_flush_dependency(void * parent_thing, void * child_thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1504,35 +1268,19 @@ H5AC_create_flush_dependency(void * parent_thing, void * child_thing) HDassert(parent_thing); HDassert(child_thing); -#if H5AC__TRACE_FILE_ENABLED - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(parent_thing))) - sprintf(trace, "%s %lx %lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)parent_thing)->addr), - (unsigned long)(((H5C_cache_entry_t *)child_thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)parent_thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Create the flush dependency */ if(H5C_create_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTDEPEND, FAIL, "H5C_create_flush_dependency() failed") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_create_fd_log_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_create_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_create_flush_dependency() */ @@ -1566,14 +1314,7 @@ void * H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, unsigned flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - size_t trace_entry_size = 0; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ void * thing = NULL; /* Pointer to native data structure for entry */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ void * ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) @@ -1586,10 +1327,6 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, HDassert(type->serialize); HDassert(H5F_addr_defined(addr)); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, NULL, "unable to get logging status") - /* Check for unexpected flags -- H5C__FLUSH_COLLECTIVELY_FLAG * only permitted in the parallel case. */ @@ -1606,16 +1343,6 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, if((0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) && (0 == (flags & H5C__READ_ONLY_FLAG))) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, NULL, "no write intent on file") -#if H5AC__TRACE_FILE_ENABLED - /* For the protect call, only the addr, size, type id, and flags are - * necessary in the trace file. Also indicate whether the call was - * successful to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d 0x%x", FUNC, (unsigned long)addr, - (int)(type->id), flags); -#endif /* H5AC__TRACE_FILE_ENABLED */ - #if H5AC_DO_TAGGING_SANITY_CHECKS if(!H5C_get_ignore_tags(f->shared->cache) && H5AC__verify_tag(type) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTTAG, NULL, "Bad tag value") @@ -1624,28 +1351,18 @@ H5AC_protect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata, if(NULL == (thing = H5C_protect(f, type, addr, udata, flags))) HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, NULL, "H5C_protect() failed") -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - /* Make note of the entry size */ - trace_entry_size = ((H5C_cache_entry_t *)thing)->size; -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* Set return value */ ret_value = thing; done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d %d\n", trace, (int)trace_entry_size, (int)(ret_value != NULL)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) { + { herr_t fake_ret_value = (NULL == ret_value) ? FAIL : SUCCEED; - if(H5AC__write_protect_entry_log_msg(f->shared->cache, (H5AC_info_t *)thing, flags, fake_ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, NULL, "unable to emit log message") - } /* end if */ + if(f->shared->cache->log_info->logging) + if(H5C_log_write_protect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, fake_ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, NULL, "unable to emit log message") + } FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_protect() */ @@ -1666,12 +1383,6 @@ done: herr_t H5AC_resize_entry(void *thing, size_t new_size) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1681,25 +1392,10 @@ H5AC_resize_entry(void *thing, size_t new_size) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the resize pinned entry call, only the addr, and new_size are - * really necessary in the trace file. Write the result to catch - * occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx %d", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr), - (int)new_size); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Resize the entry */ if(H5C_resize_entry(thing, new_size) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTRESIZE, FAIL, "can't resize entry") @@ -1716,15 +1412,10 @@ H5AC_resize_entry(void *thing, size_t new_size) #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_resize_entry_log_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_resize_entry_msg(cache_ptr, entry_ptr, new_size, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_resize_entry() */ @@ -1746,12 +1437,6 @@ done: herr_t H5AC_unpin_entry(void *thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1761,37 +1446,19 @@ H5AC_unpin_entry(void *thing) /* Sanity check */ HDassert(thing); -#if H5AC__TRACE_FILE_ENABLED - /* For the unpin entry call, only the addr is really necessary - * in the trace file. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(thing))) - sprintf(trace, "%s 0x%lx", FUNC, - (unsigned long)(((H5C_cache_entry_t *)thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Unpin the entry */ if(H5C_unpin_entry(thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPIN, FAIL, "can't unpin entry") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_unpin_entry_log_msg(cache_ptr, entry_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_unpin_entry_msg(cache_ptr, entry_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unpin_entry() */ @@ -1812,12 +1479,6 @@ done: herr_t H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5AC_info_t *entry_ptr = NULL; /* Pointer to the cache entry */ H5C_t *cache_ptr = NULL; /* Pointer to the entry's associated metadata cache */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1828,35 +1489,19 @@ H5AC_destroy_flush_dependency(void * parent_thing, void * child_thing) HDassert(parent_thing); HDassert(child_thing); -#if H5AC__TRACE_FILE_ENABLED - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(parent_thing))) - sprintf(trace, "%s %llx %llx", FUNC, - (unsigned long long)(((H5C_cache_entry_t *)parent_thing)->addr), - (unsigned long long)(((H5C_cache_entry_t *)child_thing)->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - entry_ptr = (H5AC_info_t *)parent_thing; cache_ptr = entry_ptr->cache_ptr; HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - /* Destroy the flush dependency */ if(H5C_destroy_flush_dependency(parent_thing, child_thing) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTUNDEPEND, FAIL, "H5C_destroy_flush_dependency() failed") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_destroy_fd_log_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_destroy_fd_msg(cache_ptr, (H5AC_info_t *)parent_thing, (H5AC_info_t *)child_thing, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_destroy_flush_dependency() */ @@ -1904,17 +1549,11 @@ herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, unsigned flags) { -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ hbool_t dirtied; hbool_t deleted; #ifdef H5_HAVE_PARALLEL H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1931,19 +1570,6 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, HDassert( ((H5AC_info_t *)thing)->addr == addr ); HDassert( ((H5AC_info_t *)thing)->type == type ); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(f->shared->cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* For the unprotect call, only the addr, type id, flags, and possible - * new size are really necessary in the trace file. Write the return - * value to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - sprintf(trace, "%s 0x%lx %d", FUNC, (unsigned long)addr, (int)(type->id)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - dirtied = (hbool_t)(((flags & H5AC__DIRTIED_FLAG) == H5AC__DIRTIED_FLAG) || (((H5AC_info_t *)thing)->dirtied)); deleted = (hbool_t)((flags & H5C__DELETED_FLAG) == H5C__DELETED_FLAG); @@ -1984,15 +1610,10 @@ H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing, #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr != NULL) - HDfprintf(trace_file_ptr, "%s 0x%x %d\n", trace, (unsigned)flags, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_unprotect_entry_log_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(f->shared->cache->log_info->logging) + if(H5C_log_write_unprotect_entry_msg(f->shared->cache, (H5AC_info_t *)thing, type->id, flags, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_unprotect() */ @@ -2191,12 +1812,6 @@ done: herr_t H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config_ptr) { -#if H5AC__TRACE_FILE_ENABLED - H5AC_cache_config_t trace_config = H5AC__DEFAULT_CACHE_CONFIG; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ H5C_auto_size_ctl_t internal_config; herr_t ret_value = SUCCEED; /* Return value */ @@ -2205,18 +1820,6 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config /* Sanity checks */ HDassert(cache_ptr); - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache_ptr, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - -#if H5AC__TRACE_FILE_ENABLED - /* Make note of the new configuration. Don't look up the trace file - * pointer, as that may change before we use it. - */ - if(config_ptr != NULL) - trace_config = *config_ptr; -#endif /* H5AC__TRACE_FILE_ENABLED */ - if(cache_ptr == NULL) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad cache_ptr on entry") #ifdef H5_HAVE_PARALLEL @@ -2233,23 +1836,25 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config if(H5AC_validate_config(config_ptr) != SUCCEED) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") - if(config_ptr->open_trace_file) { - FILE * file_ptr; - - if(NULL == (file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_trace_file_ptr() failed") - - if((!(config_ptr->close_trace_file)) && (file_ptr != NULL)) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Trace file already open") - } /* end if */ - - /* Close & reopen trace file, if requested */ + /* If the cache config struct is being used to control logging, perform + * the open/close operations. Note that this is the only place where the + * struct-based control opens and closes the log files so we also have + * to write start/stop messages. + */ + /* close */ if(config_ptr->close_trace_file) - if(H5AC__close_trace_file(cache_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC__close_trace_file() failed") - if(config_ptr->open_trace_file) - if(H5AC__open_trace_file(cache_ptr, config_ptr->trace_file_name) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "H5AC__open_trace_file() failed") + if(H5C_log_tear_down((H5C_t *)cache_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging tear-down failed") + + /* open */ + if(config_ptr->open_trace_file) { + /* Turn on metadata cache logging. + * This will be trace output until we create a special API call. JSON + * output is generated when logging is controlled by the H5P calls. + */ + if(H5C_log_set_up((H5C_t *)cache_ptr, config_ptr->trace_file_name, H5C_LOG_STYLE_TRACE, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "mdc logging setup failed") + } /* Convert external configuration to internal representation */ if(H5AC__ext_config_2_int_config(config_ptr, &internal_config) < 0) @@ -2275,52 +1880,10 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config #endif /* H5_HAVE_PARALLEL */ done: -#if H5AC__TRACE_FILE_ENABLED - /* For the set cache auto resize config call, only the contents - * of the config is necessary in the trace file. Write the return - * value to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HDfprintf(trace_file_ptr, - "%s %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f %d %d %d %f %f %d %d %d %d %f %zu %d %d\n", - "H5AC_set_cache_auto_resize_config", - trace_config.version, - (int)(trace_config.rpt_fcn_enabled), - (int)(trace_config.open_trace_file), - (int)(trace_config.close_trace_file), - trace_config.trace_file_name, - (int)(trace_config.evictions_enabled), - (int)(trace_config.set_initial_size), - (int)(trace_config.initial_size), - trace_config.min_clean_fraction, - (int)(trace_config.max_size), - (int)(trace_config.min_size), - trace_config.epoch_length, - (int)(trace_config.incr_mode), - trace_config.lower_hr_threshold, - trace_config.increment, - (int)(trace_config.flash_incr_mode), - trace_config.flash_multiple, - trace_config.flash_threshold, - (int)(trace_config.apply_max_increment), - (int)(trace_config.max_increment), - (int)(trace_config.decr_mode), - trace_config.upper_hr_threshold, - trace_config.decrement, - (int)(trace_config.apply_max_decrement), - (int)(trace_config.max_decrement), - trace_config.epochs_before_eviction, - (int)(trace_config.apply_empty_reserve), - trace_config.empty_reserve, - trace_config.dirty_bytes_threshold, - trace_config.metadata_write_strategy, - (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_set_cache_config_log_msg(cache_ptr, config_ptr, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache_ptr->log_info->logging) + if(H5C_log_write_set_cache_config_msg(cache_ptr, config_ptr, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_set_cache_auto_resize_config() */ @@ -2366,12 +1929,12 @@ H5AC_validate_config(H5AC_cache_config_t *config_ptr) if(config_ptr->open_trace_file) { size_t name_len; - /* Can't really test the trace_file_name field without trying to - * open the file, so we will content ourselves with a couple of - * sanity checks on the length of the file name. - */ - name_len = HDstrlen(config_ptr->trace_file_name); - if(name_len == 0) + /* Can't really test the trace_file_name field without trying to + * open the file, so we will content ourselves with a couple of + * sanity checks on the length of the file name. + */ + name_len = HDstrlen(config_ptr->trace_file_name); + if(name_len == 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name is empty") else if(name_len > H5AC__MAX_TRACE_FILE_NAME_LEN) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "config_ptr->trace_file_name too long") @@ -3062,12 +2625,6 @@ H5AC_remove_entry(void *_entry) { H5AC_info_t *entry = (H5AC_info_t *)_entry; /* Entry to remove */ H5C_t *cache = NULL; /* Pointer to the entry's associated metadata cache */ -#if H5AC__TRACE_FILE_ENABLED - char trace[128] = ""; - FILE * trace_file_ptr = NULL; -#endif /* H5AC__TRACE_FILE_ENABLED */ - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -3077,32 +2634,15 @@ H5AC_remove_entry(void *_entry) cache = entry->cache_ptr; HDassert(cache); -#if H5AC__TRACE_FILE_ENABLED - /* For the remove entry call, only the addr is really necessary - * in the trace file. Also write the result to catch occult errors. - */ - if(NULL != (trace_file_ptr = H5C_get_trace_file_ptr_from_entry(entry))) - sprintf(trace, "%s 0x%lx", FUNC, (unsigned long)(entry->addr)); -#endif /* H5AC__TRACE_FILE_ENABLED */ - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "unable to get logging status") - /* Remove the entry from the cache*/ if(H5C_remove_entry(entry) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTREMOVE, FAIL, "can't remove entry") done: -#if H5AC__TRACE_FILE_ENABLED - if(trace_file_ptr) - HDfprintf(trace_file_ptr, "%s %d\n", trace, (int)ret_value); -#endif /* H5AC__TRACE_FILE_ENABLED */ - /* If currently logging, generate a message */ - if(curr_logging) - if(H5AC__write_remove_entry_log_msg(cache, entry, ret_value) < 0) - HDONE_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to emit log message") + if(cache->log_info->logging) + if(H5C_log_write_remove_entry_msg(cache, entry, ret_value) < 0) + HDONE_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") FUNC_LEAVE_NOAPI(ret_value) } /* H5AC_remove_entry() */ diff --git a/src/H5ACdbg.c b/src/H5ACdbg.c index c6d71a8..1235206 100644 --- a/src/H5ACdbg.c +++ b/src/H5ACdbg.c @@ -136,121 +136,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5AC__close_trace_file() - * - * Purpose: If a trace file is open, stop logging calls to the cache, - * and close the file. - * - * Note that the function does nothing if there is no trace - * file. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/2/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__close_trace_file(H5AC_t *cache_ptr) -{ - FILE * trace_file_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - if(cache_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL cache_ptr on entry.") - - if(NULL == (trace_file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_get_trace_file_ptr() failed.") - - if(trace_file_ptr != NULL) { - if(H5C_set_trace_file_ptr(cache_ptr, NULL) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_trace_file_ptr() failed.") - - if(HDfclose(trace_file_ptr) != 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close metadata cache trace file") - } /* end if */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__close_trace_file() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__open_trace_file() - * - * Purpose: Open a trace file, and start logging calls to the cache. - * - * This logging is done at the H5C level, and will only take - * place if H5C_TRACE_FILE_ENABLED (defined in H5Cprivate.h) - * is TRUE. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 6/1/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__open_trace_file(H5AC_t *cache_ptr, const char *trace_file_name) -{ - char file_name[H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 2]; - FILE * file_ptr; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - HDassert(cache_ptr); - - /* Check args */ - if(cache_ptr == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "cache_ptr NULL on entry.") - if(trace_file_name == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL trace_file_name on entry.") - if(HDstrlen(trace_file_name) > H5AC__MAX_TRACE_FILE_NAME_LEN) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "trace file name too long.") - if(NULL != (file_ptr = H5C_get_trace_file_ptr(cache_ptr))) - HGOTO_ERROR(H5E_CACHE, H5E_FILEOPEN, FAIL, "trace file already open.") - -#ifdef H5_HAVE_PARALLEL -{ - H5AC_aux_t * aux_ptr; - - aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr); - if(aux_ptr == NULL) - sprintf(file_name, "%s", trace_file_name); - else { - if(aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr->magic.") - - sprintf(file_name, "%s.%d", trace_file_name, aux_ptr->mpi_rank); - } /* end else */ - - if(HDstrlen(file_name) > H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 1) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "cooked trace file name too long.") -} -#else /* H5_HAVE_PARALLEL */ - HDsnprintf(file_name, (size_t)(H5AC__MAX_TRACE_FILE_NAME_LEN + H5C__PREFIX_LEN + 1), - "%s", trace_file_name); -#endif /* H5_HAVE_PARALLEL */ - - if((file_ptr = HDfopen(file_name, "w")) == NULL) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "trace file open failed.") - - HDfprintf(file_ptr, "### HDF5 metadata cache trace file version 1 ###\n"); - - if(H5C_set_trace_file_ptr(cache_ptr, file_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5C_set_trace_file_ptr() failed.") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__open_trace_file() */ - - -/*------------------------------------------------------------------------- * * Function: H5AC_get_entry_ptr_from_addr() * diff --git a/src/H5AClog.c b/src/H5AClog.c deleted file mode 100644 index 51a2050..0000000 --- a/src/H5AClog.c +++ /dev/null @@ -1,1105 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * 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. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/*------------------------------------------------------------------------- - * - * Created: H5AClog.c - * - * Purpose: Functions for metadata cache logging in JSON format - * - *------------------------------------------------------------------------- - */ - -/****************/ -/* Module Setup */ -/****************/ -#include "H5ACmodule.h" /* This source code file is part of the H5AC module */ - -/***********/ -/* Headers */ -/***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5ACpkg.h" /* Metadata cache */ -#include "H5Cprivate.h" /* Cache */ -#include "H5Eprivate.h" /* Error handling */ - - -/****************/ -/* Local Macros */ -/****************/ - -#define MSG_SIZE 128 - - -/******************/ -/* Local Typedefs */ -/******************/ - - -/********************/ -/* Package Typedefs */ -/********************/ - - -/********************/ -/* Local Prototypes */ -/********************/ - - -/*********************/ -/* Package Variables */ -/*********************/ - - -/*****************************/ -/* Library Private Variables */ -/*****************************/ - - -/*******************/ -/* Local Variables */ -/*******************/ - - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_create_cache_log_msg - * - * Purpose: Write a log message for cache creation. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_create_cache_log_msg(H5AC_t *cache) -{ - char msg[MSG_SIZE]; - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - - /* Since we're about to override the current logging flag, - * check the "log enabled" flag to see if we didn't get here - * by mistake. - */ - if(!log_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "attempt to write opening log message when logging is disabled") - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\n\ -\"create_time\":%lld,\n\ -\"messages\":\n\ -[\n\ -" - , (long long)HDtime(NULL)); - - /* Have to temporarily enable logging, if it isn't currently */ - if(!curr_logging) - if(H5C_start_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - - /* Stop logging, if it wasn't started originally */ - if(!curr_logging) - if(H5C_stop_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_create_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_destroy_cache_log_msg - * - * Purpose: Write a log message for cache destruction. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_destroy_cache_log_msg(H5AC_t *cache) -{ - char msg[MSG_SIZE]; - hbool_t log_enabled; /* TRUE if logging was set up */ - hbool_t curr_logging; /* TRUE if currently logging */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Check if log messages are being emitted */ - if(H5C_get_logging_status(cache, &log_enabled, &curr_logging) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to get logging status") - - /* Since we're about to override the current logging flag, - * check the "log enabled" flag to see if we didn't get here - * by mistake. - */ - if(!log_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "attempt to write closing log message when logging is disabled") - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -],\n\ -\"close_time\":%lld,\n\ -}\n\ -" - , (long long)HDtime(NULL)); - - /* Have to temporarily enable logging, if it isn't currently */ - if(!curr_logging) - if(H5C_start_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - - /* Stop logging, if it wasn't started originally */ - if(!curr_logging) - if(H5C_stop_logging(cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_destroy_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_evict_cache_log_msg - * - * Purpose: Write a log message for eviction of cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_evict_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"evict\",\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_evict_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_expunge_entry_log_msg - * - * Purpose: Write a log message for expunge of cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_expunge_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"expunge\",\ -\"address\":0x%lx,\ -\"type_id\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); - - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_expunge_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_flush_cache_log_msg - * - * Purpose: Write a log message for cache flushes. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_flush_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"flush\",\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_flush_cache_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_insert_entry_log_msg - * - * Purpose: Write a log message for insertion of cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_insert_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - unsigned flags, - size_t size, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"insert\",\ -\"address\":0x%lx,\ -\"flags\":0x%x,\ -\"type_id\":%d,\ -\"size\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)address, flags, type_id, - (int)size, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_insert_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_dirty_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as dirty. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_dirty_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"dirty\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_dirty_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_clean_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as clean. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Saturday, July 23, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_clean_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; /* Log message buffer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"clean\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_clean_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_unserialized_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as unserialized. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, December 22, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_unserialized_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"unserialized\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_unserialized_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_mark_serialize_entry_log_msg - * - * Purpose: Write a log message for marking cache entries as serialize. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Thursday, December 22, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_mark_serialized_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; /* Log message buffer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"serialized\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_mark_serialized_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_move_entry_log_msg - * - * Purpose: Write a log message for moving a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_move_entry_log_msg(const H5AC_t *cache, - haddr_t old_addr, - haddr_t new_addr, - int type_id, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"move\",\ -\"old_address\":0x%lx,\ -\"new_address\":0x%lx,\ -\"type_id\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)old_addr, - (unsigned long)new_addr, type_id, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_move_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_pin_entry_log_msg - * - * Purpose: Write a log message for pinning a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_pin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"pin\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_pin_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_create_fd_log_msg - * - * Purpose: Write a log message for creating a flush dependency between - * two cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_create_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(parent); - HDassert(child); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"create_fd\",\ -\"parent_addr\":0x%lx,\ -\"child_addr\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_create_fd_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_protect_entry_log_msg - * - * Purpose: Write a log message for protecting a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_protect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - unsigned flags, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - char rw_s[16]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - if(H5AC__READ_ONLY_FLAG == flags) - HDstrcpy(rw_s, "READ"); - else - HDstrcpy(rw_s, "WRITE"); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"protect\",\ -\"address\":0x%lx,\ -\"readwrite\":\"%s\",\ -\"size\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - rw_s, (int)entry->size, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_protect_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_resize_entry_log_msg - * - * Purpose: Write a log message for resizing a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_resize_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - size_t new_size, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"resize\",\ -\"address\":0x%lx,\ -\"new_size\":%d,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)new_size, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_resize_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_unpin_entry_log_msg - * - * Purpose: Write a log message for unpinning a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_unpin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"unpin\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_unpin_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_destroy_fd_log_msg - * - * Purpose: Write a log message for destroying a flush dependency - * between two cache entries. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_destroy_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(parent); - HDassert(child); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"destroy_fd\",\ -\"parent_addr\":0x%lx,\ -\"child_addr\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)parent->addr, - (unsigned long)child->addr, (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_destroy_fd_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_unprotect_entry_log_msg - * - * Purpose: Write a log message for unprotecting a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_unprotect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - int type_id, - unsigned flags, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"unprotect\",\ -\"address\":0x%lx,\ -\"id\":%d,\ -\"flags\":%x,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - type_id, flags, (int)fxn_ret_value); - - HDsnprintf(msg, MSG_SIZE, " "); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_unprotect_entry_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_set_cache_config_log_msg - * - * Purpose: Write a log message for setting the cache configuration. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_set_cache_config_log_msg(const H5AC_t *cache, - const H5AC_cache_config_t *config, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(config); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"set_config\",\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (int)fxn_ret_value); - - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_set_cache_config_log_msg() */ - - -/*------------------------------------------------------------------------- - * Function: H5AC__write_remove_entry_log_msg - * - * Purpose: Write a log message for removing a cache entry. - * - * Return: Success: SUCCEED - * Failure: FAIL - * - * Programmer: Quincey Koziol - * September 17, 2016 - * - *------------------------------------------------------------------------- - */ -herr_t -H5AC__write_remove_entry_log_msg(const H5AC_t *cache, const H5AC_info_t *entry, - herr_t fxn_ret_value) -{ - char msg[MSG_SIZE]; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Sanity checks */ - HDassert(cache); - HDassert(entry); - - /* Create the log message string */ - HDsnprintf(msg, MSG_SIZE, -"\ -{\ -\"timestamp\":%lld,\ -\"action\":\"remove\",\ -\"address\":0x%lx,\ -\"returned\":%d\ -},\n\ -" - , (long long)HDtime(NULL), (unsigned long)entry->addr, - (int)fxn_ret_value); - - /* Write the log message to the file */ - if(H5C_write_log_message(cache, msg) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "unable to emit log message") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5AC__write_remove_entry_log_msg() */ - diff --git a/src/H5ACpkg.h b/src/H5ACpkg.h index 9bf84bf..8997382 100644 --- a/src/H5ACpkg.h +++ b/src/H5ACpkg.h @@ -433,74 +433,5 @@ H5_DLL herr_t H5AC__set_write_done_callback(H5C_t * cache_ptr, void (* write_done)(void)); #endif /* H5_HAVE_PARALLEL */ -/* Trace file routines */ -H5_DLL herr_t H5AC__close_trace_file(H5AC_t *cache_ptr); -H5_DLL herr_t H5AC__open_trace_file(H5AC_t *cache_ptr, const char *trace_file_name); - -/* Cache logging routines */ -H5_DLL herr_t H5AC__write_create_cache_log_msg(H5AC_t *cache); -H5_DLL herr_t H5AC__write_destroy_cache_log_msg(H5AC_t *cache); -H5_DLL herr_t H5AC__write_evict_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_expunge_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_flush_cache_log_msg(const H5AC_t *cache, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_insert_entry_log_msg(const H5AC_t *cache, - haddr_t address, - int type_id, - unsigned flags, - size_t size, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_dirty_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_clean_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_unserialized_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_mark_serialized_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_move_entry_log_msg(const H5AC_t *cache, - haddr_t old_addr, - haddr_t new_addr, - int type_id, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_pin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_create_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_protect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - unsigned flags, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_resize_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - size_t new_size, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_unpin_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_destroy_fd_log_msg(const H5AC_t *cache, - const H5AC_info_t *parent, - const H5AC_info_t *child, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_unprotect_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - int type_id, - unsigned flags, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_set_cache_config_log_msg(const H5AC_t *cache, - const H5AC_cache_config_t *config, - herr_t fxn_ret_value); -H5_DLL herr_t H5AC__write_remove_entry_log_msg(const H5AC_t *cache, - const H5AC_info_t *entry, - herr_t fxn_ret_value); - #endif /* _H5ACpkg_H */ diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 0e8620d..e1fdedf 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -35,12 +35,6 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SLprivate.h" /* Skip lists */ -#ifdef H5_METADATA_TRACE_FILE -#define H5AC__TRACE_FILE_ENABLED 1 -#else /* H5_METADATA_TRACE_FILE */ -#define H5AC__TRACE_FILE_ENABLED 0 -#endif /* H5_METADATA_TRACE_FILE */ - /* Global metadata tag values */ #define H5AC__INVALID_TAG (haddr_t)0 #define H5AC__IGNORE_TAG (haddr_t)1 diff --git a/src/H5Adense.c b/src/H5Adense.c index 5bed82d..021fa76 100644 --- a/src/H5Adense.c +++ b/src/H5Adense.c @@ -300,18 +300,49 @@ static herr_t H5A__dense_fnd_cb(const H5A_t *attr, hbool_t *took_ownership, void *_user_attr) { H5A_t const **user_attr = (H5A_t const **)_user_attr; /* User data from v2 B-tree attribute lookup */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_NOERR + FUNC_ENTER_STATIC /* Check arguments */ HDassert(attr); HDassert(user_attr); + HDassert(took_ownership); + /* + * If there is an attribute already stored in "user_attr", + * we need to free the dynamially allocated spaces for the + * attribute, otherwise we got infinite loop closing library due to + * outstanding allocation. (HDFFV-10659) + * + * This callback is used by H5A__dense_remove() to close/free the + * attribute stored in "user_attr" (via H5O__msg_free_real()) after + * the attribute node is deleted from the name index v2 B-tree. + * The issue is: + * When deleting the attribute node from the B-tree, + * if the attribute is found in the intermediate B-tree nodes, + * which may be merged/redistributed, we need to free the dynamically + * allocated spaces for the intermediate decoded attribute. + */ + if(*user_attr != NULL) { + H5A_t *old_attr = *user_attr; + if(old_attr->shared) { + /* Free any dynamically allocated items */ + if(H5A__free(old_attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't release attribute info") + + /* Destroy shared attribute struct */ + old_attr->shared = H5FL_FREE(H5A_shared_t, old_attr->shared); + } /* end if */ + + old_attr = H5FL_FREE(H5A_t, old_attr); + } /* end if */ /* Take over attribute ownership */ *user_attr = attr; *took_ownership = TRUE; - FUNC_LEAVE_NOAPI(SUCCEED) +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__dense_fnd_cb() */ @@ -282,13 +282,8 @@ H5C_create(size_t max_cache_size, cache_ptr->flush_in_progress = FALSE; - cache_ptr->logging_enabled = FALSE; - - cache_ptr->currently_logging = FALSE; - - cache_ptr->log_file_ptr = NULL; - - cache_ptr->trace_file_ptr = NULL; + if(NULL == (cache_ptr->log_info = (H5C_log_info_t *)H5MM_calloc(sizeof(H5C_log_info_t)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, NULL, "memory allocation failed") cache_ptr->aux_ptr = aux_ptr; @@ -493,6 +488,9 @@ done: if(cache_ptr->tag_list != NULL) H5SL_close(cache_ptr->tag_list); + if(cache_ptr->log_info != NULL) + H5MM_xfree(cache_ptr->log_info); + cache_ptr->magic = 0; cache_ptr = H5FL_FREE(H5C_t, cache_ptr); } /* end if */ @@ -865,6 +863,9 @@ H5C_dest(H5F_t * f) cache_ptr->tag_list = NULL; } /* end if */ + if(cache_ptr->log_info != NULL) + H5MM_xfree(cache_ptr->log_info); + #ifndef NDEBUG #if H5C_DO_SANITY_CHECKS if(cache_ptr->get_entry_ptr_from_addr_counter > 0) diff --git a/src/H5Cdbg.c b/src/H5Cdbg.c index 08c70d9..1f55e86 100644 --- a/src/H5Cdbg.c +++ b/src/H5Cdbg.c @@ -476,42 +476,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5C_set_trace_file_ptr - * - * Purpose: Set the trace_file_ptr field for the cache. - * - * This field must either be NULL (which turns of trace - * file logging), or be a pointer to an open file to which - * trace file data is to be written. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: John Mainzer - * 1/20/06 - * - *------------------------------------------------------------------------- - */ -herr_t -H5C_set_trace_file_ptr(H5C_t * cache_ptr, FILE * trace_file_ptr) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* This would normally be an assert, but we need to use an HGOTO_ERROR - * call to shut up the compiler. - */ - if((NULL == cache_ptr) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr") - - cache_ptr->trace_file_ptr = trace_file_ptr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_trace_file_ptr() */ - - -/*------------------------------------------------------------------------- * Function: H5C_stats * * Purpose: Prints statistics about the cache. diff --git a/src/H5Clog.c b/src/H5Clog.c index 3353619..0ae7f13 100644 --- a/src/H5Clog.c +++ b/src/H5Clog.c @@ -13,11 +13,9 @@ /*------------------------------------------------------------------------- * - * Created: H5Clog.c - * May 30 2016 - * Quincey Koziol + * Created: H5Clog.c * - * Purpose: Functions for generic cache logging in JSON format + * Purpose: Functions for metadata cache logging * *------------------------------------------------------------------------- */ @@ -30,14 +28,12 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#ifdef H5_HAVE_PARALLEL -#define H5AC_FRIEND /*suppress error about including H5ACpkg */ -#include "H5ACpkg.h" /* Metadata cache */ -#endif /* H5_HAVE_PARALLEL */ -#include "H5Cpkg.h" /* Metadata cache */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#define H5AC_FRIEND /* Suppress error about including H5ACpkg */ +#include "H5ACpkg.h" /* Metadata cache */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ /****************/ @@ -77,133 +73,109 @@ /*------------------------------------------------------------------------- - * Function: H5C_set_up_logging + * Function: H5C_log_set_up * * Purpose: Setup for metadata cache logging. * - * Metadata logging is enabled and disabled at two levels. This - * function and the associated tear_down function open and close - * the log file. the start_ and stop_logging functions are then - * used to switch logging on/off. Optionally, logging can begin - * as soon as the log file is opened (set via the start_immediately - * parameter to this function). - * - * The log functionality is split between the H5C and H5AC - * packages. Log state and direct log manipulation resides in - * H5C. Log messages are generated in H5AC and sent to - * the H5C_write_log_message function. + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_set_up_logging(H5C_t *cache_ptr, const char log_location[], - hbool_t start_immediately) +H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately) { -#ifdef H5_HAVE_PARALLEL - H5AC_aux_t *aux_ptr = NULL; -#endif /*H5_HAVE_PARALLEL*/ - char *file_name = NULL; - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + int mpi_rank = -1; /* -1 indicates serial (no MPI rank) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging already set up") - if(NULL == log_location) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL log location not allowed") - - /* Possibly fix up the log file name. - * The extra 39 characters are for adding the rank to the file name - * under parallel HDF5. 39 characters allows > 2^127 processes which - * should be enough for anybody. - * - * allocation size = <path length> + dot + <rank # length> + \0 - */ - n_chars = HDstrlen(log_location) + 1 + 39 + 1; - if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + HDassert(cache); + HDassert(log_location); + /* Check logging flags */ + if(cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging already set up") + + /* Get the rank when MPI is in use. Logging clients will usually + * use that to create per-process logs. + */ #ifdef H5_HAVE_PARALLEL - /* Add the rank to the log file name when MPI is in use */ - aux_ptr = (H5AC_aux_t *)(cache_ptr->aux_ptr); - - if(NULL == aux_ptr) - HDsnprintf(file_name, n_chars, "%s", log_location); - else { - if(aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr->magic") - HDsnprintf(file_name, n_chars, "%s.%d", log_location, aux_ptr->mpi_rank); - } /* end else */ -#else /* H5_HAVE_PARALLEL */ - HDsnprintf(file_name, n_chars, "%s", log_location); -#endif /* H5_HAVE_PARALLEL */ - - /* Open log file */ - if(NULL == (cache_ptr->log_file_ptr = HDfopen(file_name, "w"))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "can't create mdc log file") + if(NULL != cache->aux_ptr) + mpi_rank = ((H5AC_aux_t *)(cache->aux_ptr))->mpi_rank; +#endif /*H5_HAVE_PARALLEL*/ + + /* Set up logging */ + if(H5C_LOG_STYLE_JSON == style) { + if(H5C_log_json_set_up(cache->log_info, log_location, mpi_rank) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up json logging") + } + else if(H5C_LOG_STYLE_TRACE == style) { + if(H5C_log_trace_set_up(cache->log_info, log_location, mpi_rank) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to set up trace logging") + } + else + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unknown logging style") /* Set logging flags */ - cache_ptr->logging_enabled = TRUE; - cache_ptr->currently_logging = start_immediately; + cache->log_info->enabled = TRUE; + + /* Start logging if requested */ + if(start_immediately) + if(H5C_start_logging(cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to start logging") done: - if(file_name) - file_name = (char *)H5MM_xfree(file_name); FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_set_up_logging() */ +} /* H5C_log_set_up() */ /*------------------------------------------------------------------------- - * Function: H5C_tear_down_logging + * Function: H5C_log_tear_down * * Purpose: Tear-down for metadata cache logging. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_tear_down_logging(H5C_t *cache_ptr) +H5C_log_tear_down(H5C_t *cache) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not enabled") + HDassert(cache); - /* Unset logging flags */ - cache_ptr->logging_enabled = FALSE; - cache_ptr->currently_logging = FALSE; + /* Check logging flags */ + if(FALSE == cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") - /* Close log file */ - if(EOF == HDfclose(cache_ptr->log_file_ptr)) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problem closing mdc log file") - cache_ptr->log_file_ptr = NULL; + /* Stop logging if that's going on */ + if(cache->log_info->logging) + if(H5C_stop_logging(cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to stop logging") + + /* Tear down logging */ + if(cache->log_info->cls->tear_down_logging) + if(cache->log_info->cls->tear_down_logging(cache->log_info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific tear down call failed") + + /* Unset logging flags */ + cache->log_info->enabled = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_tear_down_logging() */ +} /* H5C_log_tear_down() */ /*------------------------------------------------------------------------- @@ -211,37 +183,39 @@ H5C_tear_down_logging(H5C_t *cache_ptr) * * Purpose: Start logging metadata cache operations. * - * TODO: Add a function that dumps the current state of the - * metadata cache. + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_start_logging(H5C_t *cache_ptr) +H5C_start_logging(H5C_t *cache) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not enabled") - if(cache_ptr->currently_logging) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging already in progress") + HDassert(cache); + + /* Check logging flags */ + if(FALSE == cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") + + /* Start logging */ + if(cache->log_info->cls->start_logging) + if(cache->log_info->cls->start_logging(cache->log_info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific start call failed") /* Set logging flags */ - cache_ptr->currently_logging = TRUE; + cache->log_info->logging = TRUE; - /* TODO - Dump cache state */ + /* Write a log message */ + if(cache->log_info->cls->write_start_log_msg) + if(cache->log_info->cls->write_start_log_msg(cache->log_info->udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write start call failed") done: FUNC_LEAVE_NOAPI(ret_value) @@ -253,32 +227,41 @@ H5C_start_logging(H5C_t *cache_ptr) * * Purpose: Stop logging metadata cache operations. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_stop_logging(H5C_t *cache_ptr) +H5C_stop_logging(H5C_t *cache) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->logging_enabled) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not enabled") - if(FALSE == cache_ptr->currently_logging) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "logging not in progress") + HDassert(cache); + + /* Check logging flags */ + if(FALSE == cache->log_info->enabled) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not enabled") + if(FALSE == cache->log_info->logging) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "logging not in progress") + + /* Write a log message */ + if(cache->log_info->cls->write_stop_log_msg) + if(cache->log_info->cls->write_stop_log_msg(cache->log_info->udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write stop call failed") + + /* Stop logging */ + if(cache->log_info->cls->stop_logging) + if(cache->log_info->cls->stop_logging(cache->log_info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific stop call failed") /* Set logging flags */ - cache_ptr->currently_logging = FALSE; + cache->log_info->logging = FALSE; done: FUNC_LEAVE_NOAPI(ret_value) @@ -289,80 +272,706 @@ H5C_stop_logging(H5C_t *cache_ptr) * Function: H5C_get_logging_status * * Purpose: Determines if the cache is actively logging (via the OUT - * parameter). + * parameters). * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_get_logging_status(const H5C_t *cache_ptr, /*OUT*/ hbool_t *is_enabled, +H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging) { - herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_NOAPI_NOERR + + /* Sanity checks */ + HDassert(cache); + HDassert(is_enabled); + HDassert(is_currently_logging); + + /* Get logging flags */ + *is_enabled = cache->log_info->enabled; + *is_currently_logging = cache->log_info->logging; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5C_get_logging_status() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_create_cache_msg + * + * Purpose: Write a log message for cache creation. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(NULL == is_enabled) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(NULL == is_currently_logging) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - - *is_enabled = cache_ptr->logging_enabled; - *is_currently_logging = cache_ptr->currently_logging; + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_create_cache_log_msg) + if(cache->log_info->cls->write_create_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write create cache call failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_get_logging_status() */ +} /* H5C_log_write_create_cache_msg() */ + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_destroy_cache_msg + * + * Purpose: Write a log message for cache destruction. + * + * NOTE: This can't print out the H5AC call return value, since we + * won't know that until the cache is destroyed and at that + * point we no longer have pointers to the logging information. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_destroy_cache_msg(H5C_t *cache) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_destroy_cache_log_msg) + if(cache->log_info->cls->write_destroy_cache_log_msg(cache->log_info->udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write destroy cache call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_destroy_cache_msg() */ /*------------------------------------------------------------------------- - * Function: H5C_write_log_message + * Function: H5C_log_write_evict_cache_msg * - * Purpose: Write a message to the log file and flush the file. - * The message string is neither modified nor freed. + * Purpose: Write a log message for eviction of cache entries. * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * - * Programmer: Dana Robinson - * Sunday, March 16, 2014 + * Programmer: Dana Robinson + * Fall 2018 * *------------------------------------------------------------------------- */ herr_t -H5C_write_log_message(const H5C_t *cache_ptr, const char message[]) +H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value) { - size_t n_chars; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_evict_cache_log_msg) + if(cache->log_info->cls->write_evict_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write evict cache call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_evict_cache_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_expunge_entry_msg + * + * Purpose: Write a log message for expunge of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, + int type_id, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Sanity checks */ - if(NULL == cache_ptr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache_ptr == NULL") - if(H5C__H5C_T_MAGIC != cache_ptr->magic) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cache magic value incorrect") - if(FALSE == cache_ptr->currently_logging) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "not currently logging") - if(NULL == message) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL log message not allowed") - - /* Write the log message and flush */ - n_chars = HDstrlen(message); - if((int)n_chars != HDfprintf(cache_ptr->log_file_ptr, message)) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error writing log message") - if(EOF == HDfflush(cache_ptr->log_file_ptr)) - HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error flushing log message") + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_expunge_entry_log_msg) + if(cache->log_info->cls->write_expunge_entry_log_msg(cache->log_info->udata, address, type_id, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific write expunge entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_expunge_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_flush_cache_msg + * + * Purpose: Write a log message for cache flushes. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_flush_cache_log_msg) + if(cache->log_info->cls->write_flush_cache_log_msg(cache->log_info->udata, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific flush cache call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_flush_cache_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_insert_entry_msg + * + * Purpose: Write a log message for insertion of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, + int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_insert_entry_log_msg) + if(cache->log_info->cls->write_insert_entry_log_msg(cache->log_info->udata, address, type_id, flags, size, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific insert entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_insert_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_entry_dirty_msg + * + * Purpose: Write a log message for marking cache entries as dirty. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_entry_dirty_log_msg) + if(cache->log_info->cls->write_mark_entry_dirty_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark dirty entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_entry_dirty_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_entry_clean_msg + * + * Purpose: Write a log message for marking cache entries as clean. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_entry_clean_log_msg) + if(cache->log_info->cls->write_mark_entry_clean_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark clean entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_entry_clean_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_unserialized_entry_msg + * + * Purpose: Write a log message for marking cache entries as unserialized. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, + const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_unserialized_entry_log_msg) + if(cache->log_info->cls->write_mark_unserialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark unserialized entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_unserialized_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_mark_serialized_entry_msg + * + * Purpose: Write a log message for marking cache entries as serialize. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_mark_serialized_entry_log_msg) + if(cache->log_info->cls->write_mark_serialized_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific mark serialized entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_mark_serialized_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_move_entry_msg + * + * Purpose: Write a log message for moving a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + if(cache->log_info->cls->write_move_entry_log_msg) + if(cache->log_info->cls->write_move_entry_log_msg(cache->log_info->udata, old_addr, new_addr, type_id, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific move entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_move_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_pin_entry_msg + * + * Purpose: Write a log message for pinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_pin_entry_log_msg) + if(cache->log_info->cls->write_pin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific pin entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_pin_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_create_fd_msg + * + * Purpose: Write a log message for creating a flush dependency between + * two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(parent); + HDassert(child); + if(cache->log_info->cls->write_create_fd_log_msg) + if(cache->log_info->cls->write_create_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific create fd call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_create_fd_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_protect_entry_msg + * + * Purpose: Write a log message for protecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_protect_entry_log_msg) + if(cache->log_info->cls->write_protect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific protect entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_protect_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_resize_entry_msg + * + * Purpose: Write a log message for resizing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_resize_entry_log_msg) + if(cache->log_info->cls->write_resize_entry_log_msg(cache->log_info->udata, entry, new_size, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific resize entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_resize_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_unpin_entry_msg + * + * Purpose: Write a log message for unpinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_unpin_entry_log_msg) + if(cache->log_info->cls->write_unpin_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unpin entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_unpin_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_destroy_fd_msg + * + * Purpose: Write a log message for destroying a flush dependency + * between two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(parent); + HDassert(child); + if(cache->log_info->cls->write_destroy_fd_log_msg) + if(cache->log_info->cls->write_destroy_fd_log_msg(cache->log_info->udata, parent, child, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific destroy fd call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_destroy_fd_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_unprotect_entry_msg + * + * Purpose: Write a log message for unprotecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_unprotect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_unprotect_entry_log_msg) + if(cache->log_info->cls->write_unprotect_entry_log_msg(cache->log_info->udata, entry, type_id, flags, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific unprotect entry call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_unprotect_entry_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_set_cache_config_msg + * + * Purpose: Write a log message for setting the cache configuration. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(config); + if(cache->log_info->cls->write_set_cache_config_log_msg) + if(cache->log_info->cls->write_set_cache_config_log_msg(cache->log_info->udata, config, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific set cache config call failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_write_set_cache_config_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_write_remove_entry_msg + * + * Purpose: Write a log message for removing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(cache); + + /* Write a log message */ + HDassert(entry); + if(cache->log_info->cls->write_remove_entry_log_msg) + if(cache->log_info->cls->write_remove_entry_log_msg(cache->log_info->udata, entry, fxn_ret_value) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "log-specific remove entry call failed") done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5C_write_log_message() */ +} /* H5C_log_write_remove_entry_msg() */ diff --git a/src/H5Clog.h b/src/H5Clog.h new file mode 100644 index 0000000..9ba6786 --- /dev/null +++ b/src/H5Clog.h @@ -0,0 +1,114 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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: Cache logging header file + */ + +#ifndef _H5Clog_H +#define _H5Clog_H + +/* Get package's private header */ +#include "H5Cprivate.h" /* Cache */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/* Forward declaration for class struct */ +typedef struct H5C_log_info_t H5C_log_info_t; + +/* Class for generating logging messages */ +typedef struct H5C_log_class_t { + const char *name; /* String for debugging */ + + /* Callbacks for writing log messages */ + herr_t (*tear_down_logging)(H5C_log_info_t *log_info); + herr_t (*start_logging)(H5C_log_info_t *log_info); + herr_t (*stop_logging)(H5C_log_info_t *log_info); + herr_t (*write_start_log_msg)(void *udata); + herr_t (*write_stop_log_msg)(void *udata); + herr_t (*write_create_cache_log_msg)(void *udata, herr_t fxn_ret_value); + herr_t (*write_destroy_cache_log_msg)(void *udata); + herr_t (*write_evict_cache_log_msg)(void *udata, herr_t fxn_ret_value); + herr_t (*write_expunge_entry_log_msg)(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); + herr_t (*write_flush_cache_log_msg)(void *udata, herr_t fxn_ret_value); + herr_t (*write_insert_entry_log_msg)(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); + herr_t (*write_mark_entry_dirty_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_mark_entry_clean_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_mark_unserialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_mark_serialized_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_move_entry_log_msg)(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); + herr_t (*write_pin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_create_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_protect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); + herr_t (*write_resize_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); + herr_t (*write_unpin_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + herr_t (*write_destroy_fd_log_msg)(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); + herr_t (*write_unprotect_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); + herr_t (*write_set_cache_config_log_msg)(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); + herr_t (*write_remove_entry_log_msg)(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + +} H5C_log_class_t; + +/* Logging information */ +struct H5C_log_info_t { + hbool_t enabled; /* Was the logging set up? */ + hbool_t logging; /* Are we currently logging? */ + H5C_log_class_t *cls; /* Callbacks for writing log messages */ + void *udata; /* Log-specific data */ +}; + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ +H5_DLL herr_t H5C_log_set_up(H5C_t *cache, const char log_location[], H5C_log_style_t style, hbool_t start_immediately); +H5_DLL herr_t H5C_log_tear_down(H5C_t *cache); + +H5_DLL herr_t H5C_log_write_create_cache_msg(H5C_t *cache, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_destroy_cache_msg(H5C_t *cache); +H5_DLL herr_t H5C_log_write_evict_cache_msg(H5C_t *cache, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_expunge_entry_msg(H5C_t *cache, haddr_t address, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_flush_cache_msg(H5C_t *cache, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_insert_entry_msg(H5C_t *cache, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_dirty_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_entry_clean_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_unserialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_mark_serialized_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_move_entry_msg(H5C_t *cache, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_pin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_create_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_protect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_resize_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unpin_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_destroy_fd_msg(H5C_t *cache, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_unprotect_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_set_cache_config_msg(H5C_t *cache, const H5AC_cache_config_t *config, herr_t fxn_ret_value); +H5_DLL herr_t H5C_log_write_remove_entry_msg(H5C_t *cache, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + +/* Logging-specific setup functions */ +H5_DLL herr_t H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); +H5_DLL herr_t H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank); + +#endif /* _H5Clog_H */ + diff --git a/src/H5Clog_json.c b/src/H5Clog_json.c new file mode 100644 index 0000000..ccfa222 --- /dev/null +++ b/src/H5Clog_json.c @@ -0,0 +1,1365 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Clog_json.c + * + * Purpose: Cache log implementation that emits JSON-formatted log + * entries for consumption by new-fangled data analysis tools. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* Max log message size */ +#define H5C_MAX_JSON_LOG_MSG_SIZE 128 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + +typedef struct H5C_log_json_udata_t { + FILE *outfile; + char *message; +} H5C_log_json_udata_t; + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Internal message handling calls */ +static herr_t H5C__json_write_log_message(H5C_log_json_udata_t *json_udata); + +/* Log message callbacks */ +static herr_t H5C__json_tear_down_logging(H5C_log_info_t *log_info); +static herr_t H5C__json_write_start_log_msg(void *udata); +static herr_t H5C__json_write_stop_log_msg(void *udata); +static herr_t H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__json_write_destroy_cache_log_msg(void *udata); +static herr_t H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +static herr_t H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__json_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); +static herr_t H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Note that there's no cache set up call since that's the + * place where this struct is wired into the cache. + */ +static H5C_log_class_t H5C_json_log_class_g = { + "json", + H5C__json_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + H5C__json_write_start_log_msg, + H5C__json_write_stop_log_msg, + H5C__json_write_create_cache_log_msg, + H5C__json_write_destroy_cache_log_msg, + H5C__json_write_evict_cache_log_msg, + H5C__json_write_expunge_entry_log_msg, + H5C__json_write_flush_cache_log_msg, + H5C__json_write_insert_entry_log_msg, + H5C__json_write_mark_entry_dirty_log_msg, + H5C__json_write_mark_entry_clean_log_msg, + H5C__json_write_mark_unserialized_entry_log_msg, + H5C__json_write_mark_serialized_entry_log_msg, + H5C__json_write_move_entry_log_msg, + H5C__json_write_pin_entry_log_msg, + H5C__json_write_create_fd_log_msg, + H5C__json_write_protect_entry_log_msg, + H5C__json_write_resize_entry_log_msg, + H5C__json_write_unpin_entry_log_msg, + H5C__json_write_destroy_fd_log_msg, + H5C__json_write_unprotect_entry_log_msg, + H5C__json_write_set_cache_config_log_msg, + H5C__json_write_remove_entry_log_msg +}; + + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_log_message + * + * Purpose: Write a message to the log file and flush the file. + * The message string is neither modified nor freed. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_log_message(H5C_log_json_udata_t *json_udata) +{ + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->outfile); + HDassert(json_udata->message); + + /* Write the log message and flush */ + n_chars = HDstrlen(json_udata->message); + if((int)n_chars != HDfprintf(json_udata->outfile, json_udata->message)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") + HDmemset((void *)(json_udata->message), 0, (size_t)(n_chars * sizeof(char))); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_log_message() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_json_set_up + * + * Purpose: Setup for metadata cache logging. + * + * Metadata logging is enabled and disabled at two levels. This + * function and the associated tear_down function open and close + * the log file. the start_ and stop_logging functions are then + * used to switch logging on/off. Optionally, logging can begin + * as soon as the log file is opened (set via the start_immediately + * parameter to this function). + * + * The log functionality is split between the H5C and H5AC + * packages. Log state and direct log manipulation resides in + * H5C. Log messages are generated in H5AC and sent to + * the H5C__json_write_log_message function. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_json_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) +{ + H5C_log_json_udata_t *json_udata = NULL; + char *file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(log_info); + HDassert(log_location); + + /* Set up the class struct */ + log_info->cls = &H5C_json_log_class_g; + + /* Allocate memory for the JSON-specific data */ + if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_json_udata_t)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + json_udata = (H5C_log_json_udata_t *)(log_info->udata); + + /* Allocate memory for the message buffer */ + if(NULL == (json_udata->message = (char *)H5MM_calloc(H5C_MAX_JSON_LOG_MSG_SIZE * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Possibly fix up the log file name. + * The extra 39 characters are for adding the rank to the file name + * under parallel HDF5. 39 characters allows > 2^127 processes which + * should be enough for anybody. + * + * allocation size = "RANK_" + <rank # length> + dot + <path length> + \0 + */ + n_chars = 5 + 39 + 1 + HDstrlen(log_location) + 1; + if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + + /* Add the rank to the log file name when MPI is in use */ + if(-1 == mpi_rank) + HDsnprintf(file_name, n_chars, "%s", log_location); + else + HDsnprintf(file_name, n_chars, "RANK_%d.%s", mpi_rank, log_location); + + /* Open log file and set it to be unbuffered */ + if(NULL == (json_udata->outfile = HDfopen(file_name, "w"))) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") + HDsetbuf(json_udata->outfile, NULL); + + done: + if(file_name) + H5MM_xfree(file_name); + + /* Free and reset the log info struct on errors */ + if(FAIL == ret_value) { + /* Free */ + if(json_udata && json_udata->message) + H5MM_xfree(json_udata->message); + if(json_udata) + H5MM_xfree(json_udata); + + /* Reset */ + log_info->udata = NULL; + log_info->cls = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_json_set_up() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_tear_down_logging + * + * Purpose: Tear-down for metadata cache logging. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_tear_down_logging(H5C_log_info_t *log_info) +{ + H5C_log_json_udata_t *json_udata = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(log_info); + + /* Alias */ + json_udata = (H5C_log_json_udata_t *)(log_info->udata); + + /* Free the message buffer */ + H5MM_xfree(json_udata->message); + + /* Close log file */ + if(EOF == HDfclose(json_udata->outfile)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") + json_udata->outfile = NULL; + + /* Fre the udata */ + H5MM_xfree(json_udata); + + /* Reset the log class info and udata */ + log_info->cls = NULL; + log_info->udata = NULL; + + done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_tear_down_logging() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_start_log_msg + * + * Purpose: Write a log message when logging starts. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_start_log_msg(void *udata) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string (opens the JSON array) */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\n\ +\"HDF5 metadata cache log messages\" : [\n\ +{\ +\"timestamp\":%lld,\ +\"action\":\"logging start\"\ +},\n\ +" + , (long long)HDtime(NULL)); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_start_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_stop_log_msg + * + * Purpose: Write a log message when logging ends. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_stop_log_msg(void *udata) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string (closes the JSON array) */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"logging stop\"\ +}\n\ +]}\n\ +" + , (long long)HDtime(NULL)); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_stop_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_create_cache_log_msg + * + * Purpose: Write a log message for cache creation. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_create_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"create\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_create_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_destroy_cache_log_msg + * + * Purpose: Write a log message for cache destruction. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_destroy_cache_log_msg(void *udata) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"destroy\"\ +},\n\ +" + , (long long)HDtime(NULL)); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_destroy_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_evict_cache_log_msg + * + * Purpose: Write a log message for eviction of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_evict_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"evict\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_evict_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_expunge_entry_log_msg + * + * Purpose: Write a log message for expunge of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_expunge_entry_log_msg(void *udata, haddr_t address, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"expunge\",\ +\"address\":0x%lx,\ +\"type_id\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)address, (int)type_id, (int)fxn_ret_value); + + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_expunge_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_flush_cache_log_msg + * + * Purpose: Write a log message for cache flushes. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"flush\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_flush_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_insert_entry_log_msg + * + * Purpose: Write a log message for insertion of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_insert_entry_log_msg(void *udata, haddr_t address, + int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"insert\",\ +\"address\":0x%lx,\ +\"type_id\":%d,\ +\"flags\":0x%x,\ +\"size\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)address, type_id, flags, + (int)size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_insert_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_entry_dirty_log_msg + * + * Purpose: Write a log message for marking cache entries as dirty. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"dirty\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_entry_dirty_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_entry_clean_log_msg + * + * Purpose: Write a log message for marking cache entries as clean. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"clean\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_entry_clean_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_unserialized_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as unserialized. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_unserialized_entry_log_msg(void *udata, + const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"unserialized\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_unserialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_mark_serialize_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as serialize. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"serialized\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_mark_serialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_move_entry_log_msg + * + * Purpose: Write a log message for moving a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"move\",\ +\"old_address\":0x%lx,\ +\"new_address\":0x%lx,\ +\"type_id\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)old_addr, + (unsigned long)new_addr, type_id, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_move_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_pin_entry_log_msg + * + * Purpose: Write a log message for pinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"pin\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_pin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_create_fd_log_msg + * + * Purpose: Write a log message for creating a flush dependency between + * two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"create_fd\",\ +\"parent_addr\":0x%lx,\ +\"child_addr\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)parent->addr, + (unsigned long)child->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_create_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_protect_entry_log_msg + * + * Purpose: Write a log message for protecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + char rw_s[16]; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + if(H5C__READ_ONLY_FLAG == flags) + HDstrcpy(rw_s, "READ"); + else + HDstrcpy(rw_s, "WRITE"); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"protect\",\ +\"address\":0x%lx,\ +\"type_id\":%d,\ +\"readwrite\":\"%s\",\ +\"size\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + type_id, rw_s, (int)entry->size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_protect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_resize_entry_log_msg + * + * Purpose: Write a log message for resizing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"resize\",\ +\"address\":0x%lx,\ +\"new_size\":%d,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)new_size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_resize_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_unpin_entry_log_msg + * + * Purpose: Write a log message for unpinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"unpin\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_unpin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_destroy_fd_log_msg + * + * Purpose: Write a log message for destroying a flush dependency + * between two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"destroy_fd\",\ +\"parent_addr\":0x%lx,\ +\"child_addr\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)parent->addr, + (unsigned long)child->addr, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_destroy_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_unprotect_entry_log_msg + * + * Purpose: Write a log message for unprotecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"unprotect\",\ +\"address\":0x%lx,\ +\"id\":%d,\ +\"flags\":%x,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + type_id, flags, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_unprotect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_set_cache_config_log_msg + * + * Purpose: Write a log message for setting the cache configuration. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(config); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"set_config\",\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (int)fxn_ret_value); + + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_set_cache_config_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__json_write_remove_entry_log_msg + * + * Purpose: Write a log message for removing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__json_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_json_udata_t *json_udata = (H5C_log_json_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(json_udata); + HDassert(json_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(json_udata->message, H5C_MAX_JSON_LOG_MSG_SIZE, +"\ +{\ +\"timestamp\":%lld,\ +\"action\":\"remove\",\ +\"address\":0x%lx,\ +\"returned\":%d\ +},\n\ +" + , (long long)HDtime(NULL), (unsigned long)entry->addr, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__json_write_log_message(json_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__json_write_remove_entry_log_msg() */ + diff --git a/src/H5Clog_trace.c b/src/H5Clog_trace.c new file mode 100644 index 0000000..f7d6889 --- /dev/null +++ b/src/H5Clog_trace.c @@ -0,0 +1,1008 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Clog_trace.c + * + * Purpose: Cache log implementation that emits trace entries intended + * for consumption by a future 'cache replay' feature. + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#include "H5Cmodule.h" /* This source code file is part of the H5C module */ + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Cpkg.h" /* Cache */ +#include "H5Clog.h" /* Cache logging */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5MMprivate.h" /* Memory management */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* Max log message size */ +#define H5C_MAX_TRACE_LOG_MSG_SIZE 2048 + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + +typedef struct H5C_log_trace_udata_t { + FILE *outfile; + char *message; +} H5C_log_trace_udata_t; + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Internal message handling calls */ +static herr_t H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata); + +/* Log message callbacks */ +static herr_t H5C__trace_tear_down_logging(H5C_log_info_t *log_info); +static herr_t H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value); +static herr_t H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, int type_id, unsigned flags, size_t size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, int type_id, herr_t fxn_ret_value); +static herr_t H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, size_t new_size, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); +static herr_t H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, const H5C_cache_entry_t *child, herr_t fxn_ret_value); +static herr_t H5C__trace_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, int type_id, unsigned flags, herr_t fxn_ret_value); +static herr_t H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, herr_t fxn_ret_value); +static herr_t H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, herr_t fxn_ret_value); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* Note that there's no cache set up call since that's the + * place where this struct is wired into the cache. + */ +static H5C_log_class_t H5C_trace_log_class_g = { + "trace", + H5C__trace_tear_down_logging, + NULL, /* start logging */ + NULL, /* stop logging */ + NULL, /* write start message */ + NULL, /* write stop message */ + NULL, /* write create cache message */ + NULL, /* write destroy cache message */ + NULL, /* write evict cache message */ + H5C__trace_write_expunge_entry_log_msg, + H5C__trace_write_flush_cache_log_msg, + H5C__trace_write_insert_entry_log_msg, + H5C__trace_write_mark_entry_dirty_log_msg, + H5C__trace_write_mark_entry_clean_log_msg, + H5C__trace_write_mark_unserialized_entry_log_msg, + H5C__trace_write_mark_serialized_entry_log_msg, + H5C__trace_write_move_entry_log_msg, + H5C__trace_write_pin_entry_log_msg, + H5C__trace_write_create_fd_log_msg, + H5C__trace_write_protect_entry_log_msg, + H5C__trace_write_resize_entry_log_msg, + H5C__trace_write_unpin_entry_log_msg, + H5C__trace_write_destroy_fd_log_msg, + H5C__trace_write_unprotect_entry_log_msg, + H5C__trace_write_set_cache_config_log_msg, + H5C__trace_write_remove_entry_log_msg +}; + + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_log_message + * + * Purpose: Write a message to the log file and flush the file. + * The message string is neither modified nor freed. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_log_message(H5C_log_trace_udata_t *trace_udata) +{ + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->outfile); + HDassert(trace_udata->message); + + /* Write the log message and flush */ + n_chars = HDstrlen(trace_udata->message); + if((int)n_chars != HDfprintf(trace_udata->outfile, trace_udata->message)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "error writing log message") + HDmemset((void *)(trace_udata->message), 0, (size_t)(n_chars * sizeof(char))); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_log_message() */ + + +/*------------------------------------------------------------------------- + * Function: H5C_log_trace_set_up + * + * Purpose: Setup for metadata cache logging. + * + * Metadata logging is enabled and disabled at two levels. This + * function and the associated tear_down function open and close + * the log file. the start_ and stop_logging functions are then + * used to switch logging on/off. Optionally, logging can begin + * as soon as the log file is opened (set via the start_immediately + * parameter to this function). + * + * The log functionality is split between the H5C and H5AC + * packages. Log state and direct log manipulation resides in + * H5C. Log messages are generated in H5AC and sent to + * the H5C__trace_write_log_message function. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5C_log_trace_set_up(H5C_log_info_t *log_info, const char log_location[], int mpi_rank) +{ + H5C_log_trace_udata_t *trace_udata = NULL; + char *file_name = NULL; + size_t n_chars; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(log_info); + HDassert(log_location); + + /* Set up the class struct */ + log_info->cls = &H5C_trace_log_class_g; + + /* Allocate memory for the JSON-specific data */ + if(NULL == (log_info->udata = H5MM_calloc(sizeof(H5C_log_trace_udata_t)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + trace_udata = (H5C_log_trace_udata_t *)(log_info->udata); + + /* Allocate memory for the message buffer */ + if(NULL == (trace_udata->message = (char *)H5MM_calloc(H5C_MAX_TRACE_LOG_MSG_SIZE * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "memory allocation failed") + + /* Possibly fix up the log file name. + * The extra 39 characters are for adding the rank to the file name + * under parallel HDF5. 39 characters allows > 2^127 processes which + * should be enough for anybody. + * + * allocation size = <path length> + dot + <rank # length> + \0 + */ + n_chars = HDstrlen(log_location) + 1 + 39 + 1; + if(NULL == (file_name = (char *)H5MM_calloc(n_chars * sizeof(char)))) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "can't allocate memory for mdc log file name manipulation") + + /* Add the rank to the log file name when MPI is in use */ + if(-1 == mpi_rank) + HDsnprintf(file_name, n_chars, "%s", log_location); + else + HDsnprintf(file_name, n_chars, "%s.%d", log_location, mpi_rank); + + /* Open log file and set it to be unbuffered */ + if(NULL == (trace_udata->outfile = HDfopen(file_name, "w"))) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "can't create mdc log file") + HDsetbuf(trace_udata->outfile, NULL); + + /* Write the header */ + HDfprintf(trace_udata->outfile, "### HDF5 metadata cache trace file version 1 ###\n"); + + done: + if(file_name) + H5MM_xfree(file_name); + + /* Free and reset the log info struct on errors */ + if(FAIL == ret_value) { + /* Free */ + if(trace_udata && trace_udata->message) + H5MM_xfree(trace_udata->message); + if(trace_udata) + H5MM_xfree(trace_udata); + + /* Reset */ + log_info->udata = NULL; + log_info->cls = NULL; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C_log_trace_set_up() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_tear_down_logging + * + * Purpose: Tear-down for metadata cache logging. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_tear_down_logging(H5C_log_info_t *log_info) +{ + H5C_log_trace_udata_t *trace_udata = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(log_info); + + /* Alias */ + trace_udata = (H5C_log_trace_udata_t *)(log_info->udata); + + /* Free the message buffer */ + H5MM_xfree(trace_udata->message); + + /* Close log file */ + if(EOF == HDfclose(trace_udata->outfile)) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "problem closing mdc log file") + trace_udata->outfile = NULL; + + /* Fre the udata */ + H5MM_xfree(trace_udata); + + /* Reset the log class info and udata */ + log_info->cls = NULL; + log_info->udata = NULL; + + done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_tear_down_logging() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_expunge_entry_log_msg + * + * Purpose: Write a log message for expunge of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_expunge_entry_log_msg(void *udata, haddr_t address, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_expunge_entry 0x%lx %d %d\n", + (unsigned long)address, type_id, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_expunge_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_flush_cache_log_msg + * + * Purpose: Write a log message for cache flushes. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_flush_cache_log_msg(void *udata, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_flush %d\n", + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_flush_cache_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_insert_entry_log_msg + * + * Purpose: Write a log message for insertion of cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_insert_entry_log_msg(void *udata, haddr_t address, + int type_id, unsigned flags, size_t size, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_insert_entry 0x%lx %d 0x%x %d %d\n", + (unsigned long)address, type_id, flags, (int)size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_insert_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_entry_dirty_log_msg + * + * Purpose: Write a log message for marking cache entries as dirty. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_entry_dirty_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_dirty 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_entry_dirty_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_entry_clean_log_msg + * + * Purpose: Write a log message for marking cache entries as clean. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_entry_clean_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_clean 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_entry_clean_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_unserialized_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as unserialized. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_unserialized_entry_log_msg(void *udata, + const H5C_cache_entry_t *entry, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_unserialized 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_unserialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_mark_serialized_entry_log_msg + * + * Purpose: Write a log message for marking cache entries as serialize. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_mark_serialized_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_mark_entry_serialized 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_mark_serialized_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_move_entry_log_msg + * + * Purpose: Write a log message for moving a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_move_entry_log_msg(void *udata, haddr_t old_addr, haddr_t new_addr, + int type_id, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_move_entry 0x%lx 0x%lx %d %d\n", + (unsigned long)old_addr, (unsigned long)new_addr, type_id, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_move_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_pin_entry_log_msg + * + * Purpose: Write a log message for pinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_pin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_pin_protected_entry 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_pin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_create_fd_log_msg + * + * Purpose: Write a log message for creating a flush dependency between + * two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_create_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_create_flush_dependency 0x%lx 0x%lx %d\n", + (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_create_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_protect_entry_log_msg + * + * Purpose: Write a log message for protecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_protect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_protect 0x%lx %d 0x%x %d %d\n", + (unsigned long)(entry->addr), type_id, flags, (int)(entry->size), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_protect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_resize_entry_log_msg + * + * Purpose: Write a log message for resizing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_resize_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + size_t new_size, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_resize_entry 0x%lx %d %d\n", + (unsigned long)(entry->addr), (int)new_size, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_resize_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_unpin_entry_log_msg + * + * Purpose: Write a log message for unpinning a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_unpin_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unpin_entry 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_unpin_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_destroy_fd_log_msg + * + * Purpose: Write a log message for destroying a flush dependency + * between two cache entries. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_destroy_fd_log_msg(void *udata, const H5C_cache_entry_t *parent, + const H5C_cache_entry_t *child, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(parent); + HDassert(child); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_destroy_flush_dependency 0x%lx 0x%lx %d\n", + (unsigned long)(parent->addr), (unsigned long)(child->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_destroy_fd_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_unprotect_entry_log_msg + * + * Purpose: Write a log message for unprotecting a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_unprotect_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + int type_id, unsigned flags, herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_unprotect 0x%lx %d 0x%x %d\n", + (unsigned long)(entry->addr), type_id, flags, (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_unprotect_entry_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_set_cache_config_log_msg + * + * Purpose: Write a log message for setting the cache configuration. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_set_cache_config_log_msg(void *udata, const H5AC_cache_config_t *config, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(config); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, + "H5AC_set_cache_auto_resize_config %d %d %d %d \"%s\" %d %d %d %f %d %d %ld %d %f %f %d %f %f %d %d %d %f %f %d %d %d %d %f %zu %d %d\n", + config->version, + (int)(config->rpt_fcn_enabled), + (int)(config->open_trace_file), + (int)(config->close_trace_file), + config->trace_file_name, + (int)(config->evictions_enabled), + (int)(config->set_initial_size), + (int)(config->initial_size), + config->min_clean_fraction, + (int)(config->max_size), + (int)(config->min_size), + config->epoch_length, + (int)(config->incr_mode), + config->lower_hr_threshold, + config->increment, + (int)(config->flash_incr_mode), + config->flash_multiple, + config->flash_threshold, + (int)(config->apply_max_increment), + (int)(config->max_increment), + (int)(config->decr_mode), + config->upper_hr_threshold, + config->decrement, + (int)(config->apply_max_decrement), + (int)(config->max_decrement), + config->epochs_before_eviction, + (int)(config->apply_empty_reserve), + config->empty_reserve, + config->dirty_bytes_threshold, + config->metadata_write_strategy, + (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_set_cache_config_log_msg() */ + + +/*------------------------------------------------------------------------- + * Function: H5C__trace_write_remove_entry_log_msg + * + * Purpose: Write a log message for removing a cache entry. + * + * Return: SUCCEED/FAIL + * + * Programmer: Dana Robinson + * Fall 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5C__trace_write_remove_entry_log_msg(void *udata, const H5C_cache_entry_t *entry, + herr_t fxn_ret_value) +{ + H5C_log_trace_udata_t *trace_udata = (H5C_log_trace_udata_t *)(udata); + herr_t ret_value = SUCCEED; + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(trace_udata); + HDassert(trace_udata->message); + HDassert(entry); + + /* Create the log message string */ + HDsnprintf(trace_udata->message, H5C_MAX_TRACE_LOG_MSG_SIZE, "H5AC_remove_entry 0x%lx %d\n", + (unsigned long)(entry->addr), (int)fxn_ret_value); + + /* Write the log message to the file */ + if(H5C__trace_write_log_message(trace_udata) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_LOGGING, FAIL, "unable to emit log message") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5C__trace_write_remove_entry_log_msg() */ + diff --git a/src/H5Cpkg.h b/src/H5Cpkg.h index 98d7a01..9201afb 100644 --- a/src/H5Cpkg.h +++ b/src/H5Cpkg.h @@ -37,6 +37,7 @@ #include "H5Cprivate.h" /* Other private headers needed by this file */ +#include "H5Clog.h" /* Cache logging */ #include "H5SLprivate.h" /* Skip lists */ /**************************/ @@ -3497,40 +3498,8 @@ typedef struct H5C_tag_info_t { * flush_in_progress: Boolean flag indicating whether a flush is in * progress. * - * trace_file_ptr: File pointer pointing to the trace file, which is used - * to record cache operations for use in simulations and design - * studies. This field will usually be NULL, indicating that - * no trace file should be recorded. - * - * Since much of the code supporting the parallel metadata - * cache is in H5AC, we don't write the trace file from - * H5C. Instead, H5AC reads the trace_file_ptr as needed. - * - * When we get to using H5C in other places, we may add - * code to write trace file data at the H5C level as well. - * - * logging_enabled: Boolean flag indicating whether cache logging - * which is used to record cache operations for use in - * debugging and performance analysis. When this flag is set - * to TRUE, it means that the log file is open and ready to - * receive log entries. It does NOT mean that cache operations - * are currently being recorded. That is controlled by the - * currently_logging flag (below). - * - * Since much of the code supporting the parallel metadata - * cache is in H5AC, we don't write the trace file from - * H5C. Instead, H5AC reads the trace_file_ptr as needed. - * - * When we get to using H5C in other places, we may add - * code to write trace file data at the H5C level as well. - * - * currently_logging: Boolean flag that indicates if cache operations are - * currently being logged. This flag is flipped by the - * H5Fstart/stop_mdc_logging functions. - * - * log_file_ptr: File pointer pointing to the log file. The I/O functions - * in stdio.h are used to write to the log file regardless of - * the VFD selected. + * log_info: Information used by the MDC logging functionality. + * Described in H5Clog.h. * * aux_ptr: Pointer to void used to allow wrapper code to associate * its data with an instance of H5C_t. The H5C cache code @@ -4676,10 +4645,7 @@ typedef struct H5C_tag_info_t { struct H5C_t { uint32_t magic; hbool_t flush_in_progress; - FILE * trace_file_ptr; - hbool_t logging_enabled; - hbool_t currently_logging; - FILE * log_file_ptr; + H5C_log_info_t *log_info; void * aux_ptr; int32_t max_type_id; const H5C_class_t * const *class_table_ptr; diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h index 38a86ee..c39c1df 100644 --- a/src/H5Cprivate.h +++ b/src/H5Cprivate.h @@ -2219,6 +2219,12 @@ typedef struct H5C_cache_image_ctl_t { unsigned flags; } H5C_cache_image_ctl_t; +/* The cache logging output style */ +typedef enum H5C_log_style_t { + H5C_LOG_STYLE_JSON, + H5C_LOG_STYLE_TRACE +} H5C_log_style_t; + /***************************************/ /* Library-private Function Prototypes */ /***************************************/ @@ -2227,13 +2233,6 @@ H5_DLL H5C_t *H5C_create(size_t max_cache_size, size_t min_clean_size, int max_type_id, const H5C_class_t * const *class_table_ptr, H5C_write_permitted_func_t check_write_permitted, hbool_t write_permitted, H5C_log_flush_func_t log_flush, void *aux_ptr); -H5_DLL herr_t H5C_set_up_logging(H5C_t *cache_ptr, const char log_location[], hbool_t start_immediately); -H5_DLL herr_t H5C_tear_down_logging(H5C_t *cache_ptr); -H5_DLL herr_t H5C_start_logging(H5C_t *cache_ptr); -H5_DLL herr_t H5C_stop_logging(H5C_t *cache_ptr); -H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache_ptr, /*OUT*/ hbool_t *is_enabled, - /*OUT*/ hbool_t *is_currently_logging); -H5_DLL herr_t H5C_write_log_message(const H5C_t *cache_ptr, const char message[]); H5_DLL void H5C_def_auto_resize_rpt_fcn(H5C_t *cache_ptr, int32_t version, double hit_rate, enum H5C_resize_status status, size_t old_max_cache_size, size_t new_max_cache_size, @@ -2267,8 +2266,6 @@ H5_DLL herr_t H5C_get_entry_status(const H5F_t *f, haddr_t addr, hbool_t *image_up_to_date_ptr); H5_DLL herr_t H5C_get_evictions_enabled(const H5C_t *cache_ptr, hbool_t *evictions_enabled_ptr); H5_DLL void * H5C_get_aux_ptr(const H5C_t *cache_ptr); -H5_DLL FILE *H5C_get_trace_file_ptr(const H5C_t *cache_ptr); -H5_DLL FILE *H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr); H5_DLL herr_t H5C_image_stats(H5C_t * cache_ptr, hbool_t print_header); H5_DLL herr_t H5C_insert_entry(H5F_t *f, const H5C_class_t *type, haddr_t addr, void *thing, unsigned int flags); @@ -2292,7 +2289,6 @@ H5_DLL herr_t H5C_set_cache_image_config(const H5F_t *f, H5C_t *cache_ptr, H5C_cache_image_ctl_t *config_ptr); H5_DLL herr_t H5C_set_evictions_enabled(H5C_t *cache_ptr, hbool_t evictions_enabled); H5_DLL herr_t H5C_set_prefix(H5C_t *cache_ptr, char *prefix); -H5_DLL herr_t H5C_set_trace_file_ptr(H5C_t *cache_ptr, FILE *trace_file_ptr); H5_DLL herr_t H5C_stats(H5C_t *cache_ptr, const char *cache_name, hbool_t display_detailed_stats); H5_DLL void H5C_stats__reset(H5C_t *cache_ptr); @@ -2316,6 +2312,11 @@ H5_DLL herr_t H5C_cache_image_status(H5F_t * f, hbool_t *load_ci_ptr, H5_DLL hbool_t H5C_cache_image_pending(const H5C_t *cache_ptr); H5_DLL herr_t H5C_get_mdc_image_info(H5C_t *cache_ptr, haddr_t *image_addr, hsize_t *image_len); +/* Logging functions */ +H5_DLL herr_t H5C_start_logging(H5C_t *cache); +H5_DLL herr_t H5C_stop_logging(H5C_t *cache); +H5_DLL herr_t H5C_get_logging_status(const H5C_t *cache, /*OUT*/ hbool_t *is_enabled, /*OUT*/ hbool_t *is_currently_logging); + #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5C_apply_candidate_list(H5F_t *f, H5C_t *cache_ptr, unsigned num_candidates, haddr_t *candidates_list_ptr, int mpi_rank, diff --git a/src/H5Cquery.c b/src/H5Cquery.c index e4f3133..51ce1c2 100644 --- a/src/H5Cquery.c +++ b/src/H5Cquery.c @@ -351,64 +351,6 @@ H5C_get_aux_ptr(const H5C_t *cache_ptr) /*------------------------------------------------------------------------- - * Function: H5C_get_trace_file_ptr - * - * Purpose: Get the trace_file_ptr field from the cache. - * - * This field will either be NULL (which indicates that trace - * file logging is turned off), or contain a pointer to the - * open file to which trace file data is to be written. - * - * Return: Non-NULL trace file pointer (can't fail) - * - * Programmer: John Mainzer - * 1/20/06 - * - *------------------------------------------------------------------------- - */ -FILE * -H5C_get_trace_file_ptr(const H5C_t *cache_ptr) -{ - FUNC_ENTER_NOAPI_NOERR - - /* Check arguments */ - HDassert(cache_ptr); - HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC); - - FUNC_LEAVE_NOAPI(cache_ptr->trace_file_ptr) -} /* H5C_get_trace_file_ptr() */ - - -/*------------------------------------------------------------------------- - * Function: H5C_get_trace_file_ptr_from_entry - * - * Purpose: Get the trace_file_ptr field from the cache, via an entry. - * - * This field will either be NULL (which indicates that trace - * file logging is turned off), or contain a pointer to the - * open file to which trace file data is to be written. - * - * Return: Non-NULL trace file pointer (can't fail) - * - * Programmer: Quincey Koziol - * 6/9/08 - * - *------------------------------------------------------------------------- - */ -FILE * -H5C_get_trace_file_ptr_from_entry(const H5C_cache_entry_t *entry_ptr) -{ - FUNC_ENTER_NOAPI_NOERR - - /* Sanity checks */ - HDassert(entry_ptr); - HDassert(entry_ptr->cache_ptr); - - FUNC_LEAVE_NOAPI(H5C_get_trace_file_ptr(entry_ptr->cache_ptr)) -} /* H5C_get_trace_file_ptr_from_entry() */ - - -/*------------------------------------------------------------------------- * Function: H5C_get_entry_ring * * Purpose: Given a file address, retrieve the ring for an entry at that diff --git a/src/H5Dint.c b/src/H5Dint.c index 6bb3343..7eb1aaf 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -25,6 +25,7 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ #include "H5FLprivate.h" /* Free Lists */ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ @@ -59,6 +60,9 @@ static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overw hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj); +static herr_t H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize); +static herr_t H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc); +static size_t H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr); /*********************/ @@ -658,6 +662,211 @@ done: /*------------------------------------------------------------------------- + * Function: H5D__use_minimized_dset_headers + * + * Purpose: Compartmentalize check for file- or dcpl-set values indicating + * to create a "minimized" dataset object header. + * Upon success, write resulting value to out pointer `minimize`. + * + * Return: Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: Jacob Smith + * 16 August 2018 + *------------------------------------------------------------------------- + */ +static herr_t +H5D__use_minimized_dset_headers(H5F_t *file, H5D_t *dset, hbool_t *minimize) +{ + H5P_genplist_t *plist = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + HDassert(file); + HDassert(dset); + HDassert(minimize); + + plist = H5P_object_verify(dset->shared->dcpl_id, H5P_DATASET_CREATE); + if(NULL == plist) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "problem getting dcpl") + if(H5P_get(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, minimize) == FAIL) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get minimize value from dcpl") + + if(FALSE == *minimize) + *minimize = H5F_get_min_dset_ohdr(file); + +done: + if(FAIL == ret_value) + *minimize = FALSE; + FUNC_LEAVE_NOAPI(ret_value); +} /* H5D__use_minimized_dset_headers */ + + +/*------------------------------------------------------------------------- + * Function: H5D__calculate_minimium_header_size + * + * Purpose: Calculate the size required for the minimized object header. + * + * Return: Success: Positive value > 0 + * Failure: 0 + * + * Programmer: Jacob Smith + * 16 August 2018 + *------------------------------------------------------------------------- + */ +static size_t +H5D__calculate_minimum_header_size(H5F_t *file, H5D_t *dset, H5O_t *ohdr) +{ + H5T_t *type = NULL; + H5O_fill_t *fill_prop = NULL; + hbool_t use_at_least_v18 = FALSE; + const char continuation[1] = ""; /* requred for work-around */ + size_t get_value = 0; + size_t ret_value = 0; + + FUNC_ENTER_NOAPI_NOINIT; + + HDassert(file); + HDassert(dset); + HDassert(ohdr); + + type = dset->shared->type; + fill_prop = &(dset->shared->dcpl_cache.fill); + use_at_least_v18 = (H5F_LOW_BOUND(file) >= H5F_LIBVER_V18); + + /* Datatype message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_DTYPE_ID, type, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "Can't get size of datatype message") + ret_value += get_value; + + /* Shared Dataspace message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_SDSPACE_ID, dset->shared->space, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of dataspace message") + ret_value += get_value; + + /* "Layout" message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_LAYOUT_ID, &dset->shared->layout, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of layout message") + ret_value += get_value; + + /* Fill Value message size */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_FILL_NEW_ID, fill_prop, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of fill value message") + ret_value += get_value; + + /* "Continuation" message size */ + /* message pointer "continuation" is unused by raw get function, however, + * a null pointer would be intercepted by an assert in H5O_msg_size_oh(). + */ + get_value = H5O_msg_size_oh(file, ohdr, H5O_CONT_ID, continuation, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of continuation message") + ret_value += get_value; + + /* Fill Value (backwards compatability) message size */ + if(fill_prop->buf && !use_at_least_v18) { + H5O_fill_t old_fill_prop; /* Copy for writing "old" fill value */ + + /* Shallow copy the fill value property */ + /* guards against shared component modification */ + HDmemcpy(&old_fill_prop, fill_prop, sizeof(old_fill_prop)); + + if (H5O_msg_reset_share(H5O_FILL_ID, &old_fill_prop) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't reset the copied fill property") + + get_value = H5O_msg_size_oh(file, ohdr, H5O_FILL_ID, &old_fill_prop, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of fill value (backwards compat) message") + ret_value += get_value; + } + + /* Filter/Pipeline message size */ + if(H5D_CHUNKED == dset->shared->layout.type) { + H5O_pline_t *pline = &dset->shared->dcpl_cache.pline; + if(pline->nused > 0) { + get_value = H5O_msg_size_oh(file, ohdr, H5O_PLINE_ID, pline, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of filter message") + ret_value += get_value; + } + } + + /* External File Link message size */ + if(dset->shared->dcpl_cache.efl.nused > 0) { + get_value = H5O_msg_size_oh(file, ohdr, H5O_EFL_ID, &dset->shared->dcpl_cache.efl, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of external file link message") + ret_value += get_value; + } + + /* Modification Time message size */ + if(H5O_HDR_STORE_TIMES & H5O_OH_GET_FLAGS(ohdr)) { + HDassert(H5O_OH_GET_VERSION(ohdr) >= 1); /* 1 :: H5O_VERSION_1 (H5Opkg.h) */ + + if(H5O_OH_GET_VERSION(ohdr) == 1) { + /* v1 object headers store modification time as a message */ + time_t mtime; + get_value = H5O_msg_size_oh(file, ohdr, H5O_MTIME_NEW_ID, &mtime, 0); + if (get_value == 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of modification time message") + ret_value += get_value; + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5D__calculate_minimum_header_size */ + + +/*------------------------------------------------------------------------- + * Function: H5D__prepare_minimized_oh + * + * Purpose: Create an object header (H5O_t) allocated with the smallest + * possible size. + * + * Return: Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: Jacob Smith + * 16 August 2018 + *------------------------------------------------------------------------- + */ +static herr_t +H5D__prepare_minimized_oh(H5F_t *file, H5D_t *dset, H5O_loc_t *oloc) +{ + H5O_t *oh = NULL; + size_t ohdr_size = 0; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT; + + HDassert(file); + HDassert(dset); + HDassert(oloc); + + oh = H5O__create_ohdr(file, dset->shared->dcpl_id); + if(NULL == oh) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't instantiate object header") + + ohdr_size = H5D__calculate_minimum_header_size(file, dset, oh); + if (ohdr_size == 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "computed header size is invalid") + + /* Special allocation of space for compact datsets is handled by the call here. */ + if(H5O__apply_ohdr(file, oh, dset->shared->dcpl_id, ohdr_size, (size_t)1, oloc) == FAIL) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "can't apply object header to file") + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* H5D__prepare_minimized_oh */ + + +/*------------------------------------------------------------------------- * Function: H5D__update_oh_info * * Purpose: Create and fill object header for dataset @@ -669,17 +878,18 @@ done: static herr_t H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) { - H5O_t *oh = NULL; /* Pointer to dataset's object header */ - size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ - H5O_loc_t *oloc = NULL; /* Dataset's object location */ - H5O_layout_t *layout; /* Dataset's layout information */ - H5T_t *type; /* Dataset's datatype */ - H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ - H5D_fill_value_t fill_status; /* Fill value status */ - hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ - hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ - hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ - herr_t ret_value = SUCCEED; /* Return value */ + H5O_t *oh = NULL; /* Pointer to dataset's object header */ + size_t ohdr_size = H5D_MINHDR_SIZE; /* Size of dataset's object header */ + H5O_loc_t *oloc = NULL; /* Dataset's object location */ + H5O_layout_t *layout; /* Dataset's layout information */ + H5T_t *type; /* Dataset's datatype */ + H5O_fill_t *fill_prop; /* Pointer to dataset's fill value information */ + H5D_fill_value_t fill_status; /* Fill value status */ + hbool_t fill_changed = FALSE; /* Flag indicating the fill value was changed */ + hbool_t layout_init = FALSE; /* Flag to indicate that chunk information was initialized */ + hbool_t use_at_least_v18; /* Flag indicating to use at least v18 format versions */ + hbool_t minimize_header = FALSE; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -747,13 +957,24 @@ H5D__update_oh_info(H5F_t *file, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set fill value info") } /* end if */ - /* Add the dataset's raw data size to the size of the header, if the raw data will be stored as compact */ - if(layout->type == H5D_COMPACT) - ohdr_size += layout->storage.u.compact.size; + if(H5D__use_minimized_dset_headers(file, dset, &minimize_header) == FAIL) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get minimize settings") + + if(TRUE == minimize_header) { + if(H5D__prepare_minimized_oh(file, dset, oloc) == FAIL) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create minimized dataset object header") + } else { + /* Add the dataset's raw data size to the size of the header, if the + * raw data will be stored as compact + */ + if(H5D_COMPACT == layout->type) + ohdr_size += layout->storage.u.compact.size; + + /* Create an object header for the dataset */ + if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") + } /* If use minimum/standard object header space */ - /* Create an object header for the dataset */ - if(H5O_create(file, ohdr_size, (size_t)1, dset->shared->dcpl_id, oloc/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset object header") HDassert(file == dset->oloc.file); /* Pin the object header */ @@ -910,7 +1131,7 @@ H5D__build_file_prefix(const H5D_t *dset, hid_t dapl_id, const char *prefix_type HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") } /* end if */ else { - if (HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { + if(HDstrncmp(prefix, "${ORIGIN}", HDstrlen("${ORIGIN}")) == 0) { /* Replace ${ORIGIN} at beginning of prefix by directory of HDF5 file */ filepath_len = HDstrlen(filepath); prefix_len = HDstrlen(prefix); diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 4e9cda8..aaa3db2 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -45,6 +45,7 @@ #define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ +#define H5D_CRT_MIN_DSET_HDR_SIZE_NAME "dset_oh_minimize"/* Minimize object header */ /* ======== Dataset access property names ======== */ #define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ @@ -1335,7 +1335,7 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) H5TRACE2("e", "i*x", file_id, info); /* Check args */ - if (!info) + if(!info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Get the file pointer */ @@ -1508,7 +1508,7 @@ H5Fstart_mdc_logging(hid_t file_id) /* Call mdc logging function */ if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_START_MDC_LOGGING) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") done: FUNC_LEAVE_API(ret_value) @@ -1541,7 +1541,7 @@ H5Fstop_mdc_logging(hid_t file_id) /* Call mdc logging function */ if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_STOP_MDC_LOGGING) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") done: FUNC_LEAVE_API(ret_value) @@ -1575,7 +1575,7 @@ H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, /* Call mdc logging function */ if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") done: FUNC_LEAVE_API(ret_value) @@ -1822,3 +1822,89 @@ done: FUNC_LEAVE_API(ret_value) } /* H5Fincrement_filesize() */ + +/*------------------------------------------------------------------------- + * Function: H5Fget_dset_no_attrs_hint + * + * Purpose: + * + * Get the file-level setting to create minimized dataset object headers. + * Result is stored at pointer `minimize`. + * + * Return: + * + * Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: + * + * Jacob Smith + * 15 August 2018 + * + * Changes: None. + *------------------------------------------------------------------------- + */ +herr_t +H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*b", file_id, minimize); + + if(NULL == minimize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "out pointer 'minimize' cannot be NULL") + + vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); + if(NULL == vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG, minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Fget_dset_no_attrs_hint */ + + +/*------------------------------------------------------------------------- + * Function: H5Fset_dset_no_attrs_hint + * + * Purpose: + * + * Set the file-level setting to create minimized dataset object headers. + * + * Return: + * + * Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: + * + * Jacob Smith + * 15 August 2018 + * + * Changes: None. + *------------------------------------------------------------------------- + */ +herr_t +H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ib", file_id, minimize); + + vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE); + if(NULL == vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG, minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set file's dataset header minimization flag") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Fset_dset_no_attrs_hint */ + diff --git a/src/H5FDcore.c b/src/H5FDcore.c index ec6b2a7..ed05e95 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -420,8 +420,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the core driver. - * Failure: Negative. + * Return: Success: The driver ID for the core driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -433,7 +433,7 @@ H5FD_core_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_CORE_g)) H5FD_CORE_g = H5FD_register(&H5FD_core_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index d1a8fc8..10c368a 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -206,30 +206,27 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_direct_init + * Function: H5FD_direct_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the direct driver. - * - * Failure: Negative. + * Return: Success: The driver ID for the direct driver + * Failure: H5I_INVALID_HID * * Programmer: Raymond Lu * Wednesday, 20 September 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t H5FD_direct_init(void) { - hid_t ret_value; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) - if (H5I_VFL!=H5I_get_type(H5FD_DIRECT_g)) + if (H5I_VFL != H5I_get_type(H5FD_DIRECT_g)) H5FD_DIRECT_g = H5FD_register(&H5FD_direct_g,sizeof(H5FD_class_t),FALSE); /* Set return value */ @@ -237,7 +234,7 @@ H5FD_direct_init(void) done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5FD_direct_init() */ /*--------------------------------------------------------------------------- diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index e52a71a..4d40cf3 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -171,28 +171,25 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_family_init + * Function: H5FD_family_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the family driver. + * Return: Success: The driver ID for the family driver + * Failure: H5I_INVALID_HID * - * Failure: Negative - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t H5FD_family_init(void) { - hid_t ret_value = H5FD_FAMILY_g; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_FAMILY_g)) H5FD_FAMILY_g = H5FD_register(&H5FD_family_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDlog.c b/src/H5FDlog.c index cd9ab0e..97d1b41 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -252,8 +252,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the log driver. - * Failure: Negative. + * Return: Success: The driver ID for the log driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -265,7 +265,7 @@ H5FD_log_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_LOG_g)) H5FD_LOG_g = H5FD_register(&H5FD_log_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index c04906e..a5180d0 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -187,15 +187,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5FD_mpio_init + * Function: H5FD_mpio_init * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Return: Success: The driver ID for the mpio driver. - * Failure: Negative. + * Return: Success: The driver ID for the mpio driver + * Failure: H5I_INVALID_HID * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Thursday, August 5, 1999 * *------------------------------------------------------------------------- @@ -206,10 +206,10 @@ H5FD_mpio_init(void) #ifdef H5FDmpio_DEBUG static int H5FD_mpio_Debug_inited = 0; #endif /* H5FDmpio_DEBUG */ - const char *s; /* String for environment variables */ - hid_t ret_value; /* Return value */ + const char *s; /* String for environment variables */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Register the MPI-IO VFD, if it isn't already */ if(H5I_VFL != H5I_get_type(H5FD_MPIO_g)) @@ -217,8 +217,10 @@ H5FD_mpio_init(void) /* Allow MPI buf-and-file-type optimizations? */ s = HDgetenv("HDF5_MPI_OPT_TYPES"); - if(s && HDisdigit(*s)) - H5FD_mpi_opt_types_g = (hbool_t)HDstrtol(s, NULL, 0); + if(s && HDisdigit(*s)) { + long env_val = HDstrtol(s, NULL, 0); + H5FD_mpi_opt_types_g = (0 == env_val) ? FALSE : TRUE; + } #ifdef H5FDmpio_DEBUG if(!H5FD_mpio_Debug_inited) { @@ -226,12 +228,12 @@ H5FD_mpio_init(void) s = HDgetenv("H5FD_mpio_Debug"); if(s) { /* Set debug mask */ - while(*s) { - H5FD_mpio_Debug[(int)*s]++; - s++; - } /* end while */ + while(*s) { + H5FD_mpio_Debug[(int)*s]++; + s++; + } /* end while */ } /* end if */ - H5FD_mpio_Debug_inited++; + H5FD_mpio_Debug_inited++; } /* end if */ #endif /* H5FDmpio_DEBUG */ diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index e8dde50..fac0909 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -26,11 +26,6 @@ #include <stdlib.h> #include <string.h> -/* Disable certain warnings in PC-Lint: */ -/*lint --emacro( {534, 830}, H5P_DEFAULT, H5P_FILE_ACCESS, H5P_DATASET_XFER) */ -/*lint --emacro( {534, 830}, H5FD_MULTI) */ -/*lint -esym( 534, H5Eclear2, H5Epush2) */ - #include "hdf5.h" @@ -211,16 +206,15 @@ my_strdup(const char *s) /*------------------------------------------------------------------------- - * Function: H5FD_multi_init - * - * Purpose: Initialize this driver by registering the driver with the - * library. + * Function: H5FD_multi_init * - * Return: Success: The driver ID for the multi driver. + * Purpose: Initialize this driver by registering the driver with the + * library. * - * Failure: Negative + * Return: Success: The driver ID for the multi driver + * Failure: H5I_INVALID_HID * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Wednesday, August 4, 1999 * *------------------------------------------------------------------------- @@ -231,11 +225,11 @@ H5FD_multi_init(void) /* Clear the error stack */ H5Eclear2(H5E_DEFAULT); - if(H5I_VFL!=H5Iget_type(H5FD_MULTI_g)) + if(H5I_VFL != H5Iget_type(H5FD_MULTI_g)) H5FD_MULTI_g = H5FDregister(&H5FD_multi_g); return H5FD_MULTI_g; -} +} /* end H5FD_multi_init() */ /*--------------------------------------------------------------------------- diff --git a/src/H5FDsec2.c b/src/H5FDsec2.c index 06c008d..c507387 100644 --- a/src/H5FDsec2.c +++ b/src/H5FDsec2.c @@ -208,8 +208,8 @@ done: * Purpose: Initialize this driver by registering the driver with the * library. * - * Return: Success: The driver ID for the sec2 driver. - * Failure: Negative + * Return: Success: The driver ID for the sec2 driver + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, July 29, 1999 @@ -221,7 +221,7 @@ H5FD_sec2_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI(H5I_INVALID_HID) if(H5I_VFL != H5I_get_type(H5FD_SEC2_g)) H5FD_SEC2_g = H5FD_register(&H5FD_sec2_g, sizeof(H5FD_class_t), FALSE); diff --git a/src/H5Fint.c b/src/H5Fint.c index 8de1769..cca46d0 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -3715,3 +3715,27 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_file_id() */ + +/*------------------------------------------------------------------------- + * Function: H5F_set_min_dset_ohdr + * + * Purpose: Set the crt_dset_ohdr_flag field with a new value. + * + * Return: SUCCEED/FAIL + *------------------------------------------------------------------------- + */ +herr_t +H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize) +{ + /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(f); + HDassert(f->shared); + + f->shared->crt_dset_min_ohdr_flag = minimize; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5F_set_min_dset_ohdr() */ + diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 4ad2c55..335d0a7 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -358,6 +358,7 @@ struct H5F_file_t { /* Object flush info */ H5F_object_flush_t object_flush; /* Information for object flush callback */ + hbool_t crt_dset_min_ohdr_flag; /* flag to minimize created dataset object header */ }; /* @@ -382,7 +383,6 @@ struct H5F_t { #endif /* H5_HAVE_PARALLEL */ }; - /*****************************/ /* Package Private Variables */ /*****************************/ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 85f0d15..5f7a1b2 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -331,6 +331,8 @@ typedef struct H5F_t H5F_t; #define H5F_POINT_OF_NO_RETURN(F) ((F)->shared->fs.point_of_no_return) #define H5F_FIRST_ALLOC_DEALLOC(F) ((F)->shared->first_alloc_dealloc) #define H5F_EOA_PRE_FSM_FSALLOC(F) ((F)->shared->eoa_pre_fsm_fsalloc) +#define H5F_GET_MIN_DSET_OHDR(F) ((F)->shared->crt_dset_min_ohdr_flag) +#define H5F_SET_MIN_DSET_OHDR(F, V) ((F)->shared->crt_dset_min_ohdr_flag = (V)) #else /* H5F_MODULE */ #define H5F_LOW_BOUND(F) (H5F_get_low_bound(F)) #define H5F_HIGH_BOUND(F) (H5F_get_high_bound(F)) @@ -388,6 +390,8 @@ typedef struct H5F_t H5F_t; #define H5F_POINT_OF_NO_RETURN(F) (H5F_get_point_of_no_return(F)) #define H5F_FIRST_ALLOC_DEALLOC(F) (H5F_get_first_alloc_dealloc(F)) #define H5F_EOA_PRE_FSM_FSALLOC(F) (H5F_get_eoa_pre_fsm_fsalloc(F)) +#define H5F_GET_MIN_DSET_OHDR(F) (H5F_get_min_dset_ohdr(F)) +#define H5F_SET_MIN_DSET_OHDR(F, V) (H5F_set_min_dset_ohdr((F), (V))) #endif /* H5F_MODULE */ @@ -740,6 +744,8 @@ H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); H5_DLL hbool_t H5F_get_point_of_no_return(const H5F_t *f); H5_DLL hbool_t H5F_get_first_alloc_dealloc(const H5F_t *f); H5_DLL haddr_t H5F_get_eoa_pre_fsm_fsalloc(const H5F_t *f); +H5_DLL hbool_t H5F_get_min_dset_ohdr(const H5F_t *f); +H5_DLL herr_t H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize); /* Functions than retrieve values set/cached from the superblock/FCPL */ H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index e1b6dc3..c4bf0b4 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -217,7 +217,6 @@ typedef struct H5F_retry_info_t { /* Callback for H5Pset_object_flush_cb() in a file access property list */ typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); - /*********************/ /* Public Prototypes */ /*********************/ @@ -275,6 +274,8 @@ H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); +H5_DLL herr_t H5Fget_dset_no_attrs_hint(hid_t file_id, hbool_t *minimize); +H5_DLL herr_t H5Fset_dset_no_attrs_hint(hid_t file_id, hbool_t minimize); #ifdef H5_HAVE_PARALLEL H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 3147e95..103ad3b 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -514,6 +514,25 @@ H5F_sym_leaf_k(const H5F_t *f) /*------------------------------------------------------------------------- + * Function: H5F_get_min_dset_ohdr + * + * Purpose: Get the setting flag for minimized dataset object headers + * + * Return: TRUE/FALSE as set in file + *------------------------------------------------------------------------- + */ +hbool_t +H5F_get_min_dset_ohdr(const H5F_t *f) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + HDassert(f); + + FUNC_LEAVE_NOAPI(f->shared->crt_dset_min_ohdr_flag) +} /* end H5F_get_min_dset_ohdr */ + + +/*------------------------------------------------------------------------- * Function: H5F_Kvalue * * Purpose: Replaced a macro to retrieve a B-tree key value for a certain @@ -648,6 +648,8 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") + if(!udata && udata_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "udata cannot be NULL if udata_size is non-zero") /* Check the group access property list */ if(H5P_DEFAULT == lcpl_id) diff --git a/src/H5Oint.c b/src/H5Oint.c index a97a2fd..2503eb7 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -83,7 +83,6 @@ static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *lin void *_udata); static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh); - /*********************/ /* Package Variables */ /*********************/ @@ -277,99 +276,183 @@ done: * matzke@llnl.gov * Aug 5 1997 * + * Changes: 2018 August 17 + * Jacob Smith + * Refactor out the operations into two separate steps -- + * preparation and application -- to facilitate overriding the + * library-default size allocated for the object header. This + * function is retained as a wrapper, to minimize changes to + * unaffected calling functions. + * *------------------------------------------------------------------------- */ herr_t -H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, - H5O_loc_t *loc/*out*/) +H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc /*out*/) { - H5P_genplist_t *oc_plist; /* Object creation property list */ - H5O_t *oh = NULL; /* Object header created */ - haddr_t oh_addr; /* Address of initial object header */ - size_t oh_size; /* Size of initial object header */ - uint8_t oh_flags; /* Object header's initial status flags */ - unsigned insert_flags = H5AC__NO_FLAGS_SET; /* Flags for inserting object header into cache */ - hbool_t store_msg_crt_idx; /* Whether to always store message creation indices for this file */ - herr_t ret_value = SUCCEED; /* return value */ + H5O_t *oh = NULL; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) - /* check args */ HDassert(f); HDassert(loc); HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + /* create object header in freelist + * header version is set internally + */ + oh = H5O__create_ohdr(f, ocpl_id); + if(NULL == oh) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't instantiate object header") + + /* apply object header information to file + */ + if(H5O__apply_ohdr(f, oh, ocpl_id, size_hint, initial_rc, loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "Can't apply object header to file") + +done: + if((FAIL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "can't delete object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_create() */ + + +/*----------------------------------------------------------------------------- + * Function: H5O__create_ohdr + * + * Purpose: Create the object header, set version and flags. + * + * Return: Success: Pointer to the newly-crated header object. + * Failure: NULL + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *----------------------------------------------------------------------------- + */ +H5O_t * +H5O__create_ohdr(H5F_t *f, hid_t ocpl_id) +{ + H5P_genplist_t *oc_plist; + H5O_t *oh = NULL; /* Object header in Freelist */ + uint8_t oh_flags; /* Initial status flags */ + H5O_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + HDassert(f); + HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + /* Check for invalid access request */ if(0 == (H5F_INTENT(f) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "no write intent on file") + HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, NULL, "no write intent on file") - /* Make certain we allocate at least a reasonable size for the object header */ - size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); + oh = H5FL_CALLOC(H5O_t); + if(NULL == oh) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") - /* Get the property list */ - if(NULL == (oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") + oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); + if(NULL == oc_plist) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, NULL, "not a property list") /* Get any object header status flags set by properties */ if(H5P_get(oc_plist, H5O_CRT_OHDR_FLAGS_NAME, &oh_flags) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get object header flags") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get object header flags") - /* Allocate the object header and zero out header fields */ - if(NULL == (oh = H5FL_CALLOC(H5O_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + if(H5O_set_version(f, oh, oh_flags, H5F_STORE_MSG_CRT_IDX(f)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, NULL, "can't set version of object header") + + oh->flags = oh_flags; + + ret_value = oh; + +done: + if((NULL == ret_value) && (NULL != oh) && (H5O__free(oh) < 0)) + HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, NULL, "can't delete object header") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5O__create_ohdr() */ - /* Initialize file-specific information for object header */ - store_msg_crt_idx = H5F_STORE_MSG_CRT_IDX(f); + +/*----------------------------------------------------------------------------- + * Function: H5O__apply_ohdr + * + * Purpose: Initialize and set the object header in the file. + * Record some information at `loc_out`. + * + * Return: Success: SUCCEED (0) (non-negative value) + * Failure: FAIL (-1) (negative value) + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *----------------------------------------------------------------------------- + */ +herr_t +H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, size_t size_hint, size_t initial_rc, H5O_loc_t *loc_out) +{ + haddr_t oh_addr; + size_t oh_size; + H5P_genplist_t *oc_plist = NULL; + unsigned insert_flags = H5AC__NO_FLAGS_SET; + herr_t ret_value = SUCCEED; - if(H5O_set_version(f, oh, oh_flags, store_msg_crt_idx) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set version of objecdt header") + FUNC_ENTER_NOAPI(FAIL) + + HDassert(f); + HDassert(loc_out); + HDassert(oh); + HDassert(TRUE == H5P_isa_class(ocpl_id, H5P_OBJECT_CREATE)); + + /* Allocate at least a reasonable size for the object header */ + size_hint = H5O_ALIGN_F(f, MAX(H5O_MIN_SIZE, size_hint)); oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); - oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); + oh->swmr_write = !!(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE); /* funky cast */ + #ifdef H5O_ENABLE_BAD_MESG_COUNT /* Check whether the "bad message count" property is set */ - if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { - /* Retrieve bad message count flag */ + if(0 < H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME)) + /* Get bad message count flag -- from property list */ if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") - } #endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Create object header proxy if doing SWMR writes */ if(oh->swmr_write) { - /* Create virtual entry, for use as proxy */ - if(NULL == (oh->proxy = H5AC_proxy_entry_create())) + oh->proxy = H5AC_proxy_entry_create(); + if(NULL == oh->proxy) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "can't create object header proxy") - } - else + } else { oh->proxy = NULL; + } - /* Set initial status flags */ - oh->flags = oh_flags; + oc_plist = (H5P_genplist_t *)H5I_object(ocpl_id); + if(NULL == oc_plist) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a property list") /* Initialize version-specific fields */ if(oh->version > H5O_VERSION_1) { - /* Initialize all time fields with current time, if we are storing them */ + /* Initialize all time fields */ if(oh->flags & H5O_HDR_STORE_TIMES) oh->atime = oh->mtime = oh->ctime = oh->btime = H5_now(); else oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - /* Make certain attribute creation order tracking is enabled if - * attributes can be shared in this file. - */ - if(store_msg_crt_idx) + if(H5F_STORE_MSG_CRT_IDX(f)) + /* flag to record message creation indices */ oh->flags |= H5O_HDR_ATTR_CRT_ORDER_TRACKED; - /* Retrieve attribute storage phase change values from property list */ + /* Get attribute storage phase change values -- from property list */ if(H5P_get(oc_plist, H5O_CRT_ATTR_MAX_COMPACT_NAME, &oh->max_compact) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get max. # of compact attributes") if(H5P_get(oc_plist, H5O_CRT_ATTR_MIN_DENSE_NAME, &oh->min_dense) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get min. # of dense attributes") /* Check for non-default attribute storage phase change values */ - if(oh->max_compact != H5O_CRT_ATTR_MAX_COMPACT_DEF || oh->min_dense != H5O_CRT_ATTR_MIN_DENSE_DEF) + if(H5O_CRT_ATTR_MAX_COMPACT_DEF != oh->max_compact || H5O_CRT_ATTR_MIN_DENSE_DEF != oh->min_dense ) oh->flags |= H5O_HDR_ATTR_STORE_PHASE_CHANGE; /* Determine correct value for chunk #0 size bits */ @@ -383,23 +466,25 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, oh->flags |= H5O_HDR_CHUNK0_4; else if(size_hint > 255) oh->flags |= H5O_HDR_CHUNK0_2; - } /* end if */ - else { + } else { /* Reset unused time fields */ oh->atime = oh->mtime = oh->ctime = oh->btime = 0; - } /* end else */ + } /* end if/else header version >1 */ /* Compute total size of initial object header */ /* (i.e. object header prefix and first chunk) */ oh_size = (size_t)H5O_SIZEOF_HDR(oh) + size_hint; /* Allocate disk space for header and first chunk */ - if(HADDR_UNDEF == (oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size))) + oh_addr = H5MF_alloc(f, H5FD_MEM_OHDR, (hsize_t)oh_size); + if(HADDR_UNDEF == oh_addr) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "file allocation failed for object header") /* Create the chunk list */ - oh->nchunks = oh->alloc_nchunks = 1; - if(NULL == (oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks))) + oh->nchunks = 1; + oh->alloc_nchunks = 1; + oh->chunk = H5FL_SEQ_MALLOC(H5O_chunk_t, (size_t)oh->alloc_nchunks); + if(NULL == oh->chunk) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Initialize the first chunk */ @@ -409,25 +494,27 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, /* Allocate enough space for the first chunk */ /* (including space for serializing the object header prefix */ - if(NULL == (oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size))) + oh->chunk[0].image = H5FL_BLK_CALLOC(chunk_image, oh_size); + if(NULL == oh->chunk[0].image) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") oh->chunk[0].chunk_proxy = NULL; /* Put magic # for object header in first chunk */ - if(oh->version > H5O_VERSION_1) + if(H5O_VERSION_1 < oh->version) HDmemcpy(oh->chunk[0].image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC); /* Create the message list */ oh->nmesgs = 1; oh->alloc_nmesgs = H5O_NMESGS; - if(NULL == (oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs))) + oh->mesg = H5FL_SEQ_CALLOC(H5O_mesg_t, oh->alloc_nmesgs); + if(NULL == oh->mesg) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - /* Initialize the initial "null" message, covering the entire first chunk */ + /* Initialize the initial "null" message; covers the entire first chunk */ oh->mesg[0].type = H5O_MSG_NULL; oh->mesg[0].dirty = TRUE; oh->mesg[0].native = NULL; - oh->mesg[0].raw = oh->chunk[0].image + (H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)) + H5O_SIZEOF_MSGHDR_OH(oh); + oh->mesg[0].raw = oh->chunk[0].image + H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh) + H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[0].raw_size = size_hint - (size_t)H5O_SIZEOF_MSGHDR_OH(oh); oh->mesg[0].chunkno = 0; @@ -452,20 +539,15 @@ H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5_END_TAG /* Set up object location */ - loc->file = f; - loc->addr = oh_addr; + loc_out->file = f; + loc_out->addr = oh_addr; - /* Open it */ - if(H5O_open(loc) < 0) + if(H5O_open(loc_out) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object header") done: - if(ret_value < 0 && oh) - if(H5O__free(oh) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTFREE, FAIL, "unable to destroy object header data") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_create() */ + FUNC_LEAVE_NOAPI(ret_value); +} /* H5O__apply_ohdr() */ /*------------------------------------------------------------------------- @@ -2420,6 +2502,63 @@ H5O_get_oh_addr(const H5O_t *oh) /*------------------------------------------------------------------------- + * Function: H5O_get_oh_flags + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *------------------------------------------------------------------------- + */ +uint8_t +H5O_get_oh_flags(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(oh); + FUNC_LEAVE_NOAPI(oh->flags); /* flags can be 0 */ +} /* H5O_get_oh_flags() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_oh_mtime + * + * Purpose: Retrieve an object's modification time. Assumes that the + * caller has verified that accessing this variable is appropriate + * to the header in question. + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *------------------------------------------------------------------------- + */ +time_t +H5O_get_oh_mtime(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(oh); + HDassert(oh->mtime); + FUNC_LEAVE_NOAPI(oh->mtime); +} /* H5O_get_oh_mtime() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_get_oh_version + * + * Programmer: Jacob Smith + * 2018 August 17 + * + *------------------------------------------------------------------------- + */ +uint8_t +H5O_get_oh_version(const H5O_t *oh) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + HDassert(oh); + HDassert(oh->version); + FUNC_LEAVE_NOAPI(oh->version); +} /* H5O_get_oh_version() */ + + +/*------------------------------------------------------------------------- * Function: H5O_get_rc_and_type * * Purpose: Retrieve an object's reference count and type diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 7ed9e26..e0926e2 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -121,8 +121,14 @@ typedef struct H5O_mesg_t H5O_mesg_t; /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5O_MODULE #define H5O_OH_GET_ADDR(O) ((O)->chunk[0].addr) +#define H5O_OH_GET_VERSION(O) ((O)->version) +#define H5O_OH_GET_FLAGS(O) ((O)->flags) +#define H5O_OH_GET_MTIME(O) ((O)->mtime) #else /* H5O_MODULE */ #define H5O_OH_GET_ADDR(O) (H5O_get_oh_addr(O)) +#define H5O_OH_GET_VERSION(O) (H5O_get_oh_version(O)) +#define H5O_OH_GET_FLAGS(O) (H5O_get_oh_flags(O)) +#define H5O_OH_GET_MTIME(O) (H5O_get_oh_mtime(O)) #endif /* H5O_MODULE */ /* Set the fields in a shared message structure */ @@ -865,6 +871,9 @@ struct H5P_genplist_t; H5_DLL herr_t H5O_init(void); H5_DLL herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc/*out*/); +H5_DLL H5O_t *H5O__create_ohdr(H5F_t *f, hid_t ocpl_id); +H5_DLL herr_t H5O__apply_ohdr(H5F_t *f, H5O_t *oh, hid_t ocpl_id, + size_t size_hint, size_t initial_rc, H5O_loc_t *loc_out); H5_DLL herr_t H5O_open(H5O_loc_t *loc); H5_DLL void *H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type/*out*/); @@ -891,6 +900,9 @@ H5_DLL void *H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *o H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks); H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); +H5_DLL uint8_t H5O_get_oh_flags(const H5O_t *oh); +H5_DLL time_t H5O_get_oh_mtime(const H5O_t *oh); +H5_DLL uint8_t H5O_get_oh_version(const H5O_t *oh); H5_DLL herr_t H5O_get_rc_and_type(const H5O_loc_t *oloc, unsigned *rc, H5O_type_t *otype); H5_DLL H5AC_proxy_entry_t *H5O_get_proxy(const H5O_t *oh); diff --git a/src/H5PLint.c b/src/H5PLint.c index ded315a..8dec14b 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -311,6 +311,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, hbool_t *success, const void **plugin_info) { H5PL_HANDLE handle = NULL; + H5PL_get_plugin_type_t get_plugin_type = NULL; H5PL_get_plugin_info_t get_plugin_info = NULL; herr_t ret_value = SUCCEED; @@ -333,12 +334,22 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, HGOTO_DONE(SUCCEED) } + /* Return a handle for the function H5PLget_plugin_type in the dynamic library. + * The plugin library is supposed to define this function. + */ + if (NULL == (get_plugin_type = (H5PL_get_plugin_type_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_type"))) + HGOTO_DONE(SUCCEED) + /* Return a handle for the function H5PLget_plugin_info in the dynamic library. - * The plugin library is suppose to define this function. + * The plugin library is supposed to define this function. */ if (NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC(handle, "H5PLget_plugin_info"))) HGOTO_DONE(SUCCEED) + /* Check the plugin type and return if it doesn't match the one passed in */ + if(type != (H5PL_type_t)(*get_plugin_type)()) + HGOTO_DONE(SUCCEED) + /* Get the plugin information */ switch (type) { case H5PL_TYPE_FILTER: @@ -364,7 +375,7 @@ H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, /* Get the plugin info */ if(NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL driver info from plugin") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL connector info from plugin") /* Which kind of key are we looking for? */ if(key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h index c3ad8f5..8c2367f 100644 --- a/src/H5PLpkg.h +++ b/src/H5PLpkg.h @@ -79,6 +79,7 @@ /* maximum size for expanding env vars */ # define H5PL_EXPAND_BUFFER_SIZE 32767 + typedef H5PL_type_t(__cdecl *H5PL_get_plugin_type_t)(void); typedef const void *(__cdecl *H5PL_get_plugin_info_t)(void); #else /* H5_HAVE_WIN32_API */ @@ -105,6 +106,7 @@ /* Clear error */ # define H5PL_CLR_ERROR HERROR(H5E_PLUGIN, H5E_CANTGET, "can't dlopen:%s", dlerror()) + typedef H5PL_type_t(*H5PL_get_plugin_type_t)(void); typedef const void *(*H5PL_get_plugin_info_t)(void); #endif /* H5_HAVE_WIN32_API */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index a5a16bb..b85f105 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -117,6 +117,11 @@ #define H5D_CRT_EXT_FILE_LIST_COPY H5P__dcrt_ext_file_list_copy #define H5D_CRT_EXT_FILE_LIST_CMP H5P__dcrt_ext_file_list_cmp #define H5D_CRT_EXT_FILE_LIST_CLOSE H5P__dcrt_ext_file_list_close +/* Definitions for dataset object header minimization */ +#define H5D_CRT_MIN_DSET_HDR_SIZE_SIZE sizeof(hbool_t) +#define H5D_CRT_MIN_DSET_HDR_SIZE_DEF FALSE +#define H5D_CRT_MIN_DSET_HDR_SIZE_ENC H5P__encode_hbool_t +#define H5D_CRT_MIN_DSET_HDR_SIZE_DEC H5P__decode_hbool_t /******************/ @@ -209,6 +214,7 @@ static const H5O_layout_t H5D_def_layout_g = H5D_CRT_LAYOUT_DEF; /* Defau static const H5O_fill_t H5D_def_fill_g = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ static const unsigned H5D_def_alloc_time_state_g = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ static const H5O_efl_t H5D_def_efl_g = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ +static const unsigned H5O_ohdr_min_g = H5D_CRT_MIN_DSET_HDR_SIZE_DEF; /* Default object header minimization */ /* Defaults for each type of layout */ #ifdef H5_HAVE_C99_DESIGNATED_INITIALIZER @@ -271,6 +277,12 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) H5D_CRT_EXT_FILE_LIST_DEL, H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the object header minimization property */ + if(H5P__register_real(pclass, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, H5D_CRT_MIN_DSET_HDR_SIZE_SIZE, &H5O_ohdr_min_g, + NULL, NULL, NULL, H5D_CRT_MIN_DSET_HDR_SIZE_ENC, H5D_CRT_MIN_DSET_HDR_SIZE_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the type ID property*/ if(H5P__register_real(pclass, H5VL_PROP_DSET_TYPE_ID, sizeof(hid_t), &type_id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, NULL) < 0) @@ -3749,3 +3761,95 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_fill_time() */ + +/*----------------------------------------------------------------------------- + * Function: H5Pget_dset_no_attrs_hint + * + * Purpose: + * + * Access the flag for whether or not datasets created by the given dcpl + * will be created with a "minimized" object header. + * + * Return: + * + * Failure: Negative value (FAIL) + * Success: Non-negative value (SUCCEED) + * + * Programmer: Jacob Smith + * 2018 August 14 + * + * Modifications: None. + * + *----------------------------------------------------------------------------- + */ +herr_t +H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize) +{ + hbool_t setting = FALSE; + H5P_genplist_t *plist = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*b", dcpl_id, minimize); + + if(NULL == minimize) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "receiving pointer cannot be NULL") + + plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); + if(NULL == plist) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &setting) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get dset oh minimize flag value") + + *minimize = setting; + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pget_dset_no_attrs_hint() */ + + +/*----------------------------------------------------------------------------- + * Function: H5Pset_dset_no_attrs_hint + * + * Purpose: + * + * Set the dcpl to minimize (or explicitly to not minimized) dataset object + * headers upon creation. + * + * Return: + * + * Failure: Negative value (FAIL) + * Success: Non-negative value (SUCCEED) + * + * Programmer: Jacob Smith + * 2018 August 14 + * + * Modifications: None. + * + *----------------------------------------------------------------------------- + */ +herr_t +H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize) +{ + H5P_genplist_t *plist = NULL; + hbool_t prev_set = FALSE; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ib", dcpl_id, minimize); + + plist = H5P_object_verify(dcpl_id, H5P_DATASET_CREATE); + if(NULL == plist) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_peek(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &prev_set) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get extant dset oh minimize flag value") + + if(H5P_poke(plist, H5D_CRT_MIN_DSET_HDR_SIZE_NAME, &minimize) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't get dset oh minimize flag value") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Pset_dset_no_attrs_hint() */ + diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 86c6687..2f094ea 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -412,6 +412,8 @@ H5_DLL herr_t H5Pget_alloc_time(hid_t plist_id, H5D_alloc_time_t H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/); +H5_DLL herr_t H5Pget_dset_no_attrs_hint(hid_t dcpl_id, hbool_t *minimize); +H5_DLL herr_t H5Pset_dset_no_attrs_hint(hid_t dcpl_id, hbool_t minimize); /* Dataset access property list (DAPL) routines */ H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The Virtual Object Layer as described in documentation. + * Purpose: The Virtual Object Layer as described in documentation. * The pupose is to provide an abstraction on how to access the * underlying HDF5 container, whether in a local file with * a specific file format, or remotely on other machines, etc... @@ -295,7 +295,7 @@ H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; key.vol.u.value = value; if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") @@ -486,14 +486,11 @@ done: /*--------------------------------------------------------------------------- * Function: H5VLcmp_connector_cls * - * Purpose: Compares two connector classes + * Purpose: Compares two connector classes (based on their value field) * - * Return: Success: Non-negative, with *cmp set to positive if - * connector_id1 is greater than connector_id2, negative if connector_id2 - * is greater than connector_id1 and zero if connector_id1 and connector_id2 - * are equal. + * Return: Success: Non-negative, *cmp set to a value like strcmp * - * Failure: Negative + * Failure: Negative, *cmp unset * *--------------------------------------------------------------------------- */ diff --git a/src/H5VLint.c b/src/H5VLint.c index d51be0c..8695a80 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -881,7 +881,7 @@ done: * * Return: Positive if VALUE1 is greater than VALUE2, negative if * VALUE2 is greater than VALUE1 and zero if VALUE1 and - * VALUE2 are equal. + * VALUE2 are equal (like strcmp). * *------------------------------------------------------------------------- */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 916151b..1a3007a 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -66,6 +66,8 @@ typedef int H5VL_native_file_optional_t; #define H5VL_NATIVE_FILE_GET_EOA 22 /* H5Fget_eoa */ #define H5VL_NATIVE_FILE_INCR_FILESIZE 23 /* H5Fincrement_filesize */ #define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 24 /* H5Fset_latest_format/libver_bounds */ +#define H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG 25 /* H5Fget_dset_no_attrs_hint */ +#define H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG 26 /* H5Fset_dset_no_attrs_hint */ /* Typedef and values for native VOL connector group optional VOL operations */ typedef int H5VL_native_group_optional_t; diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 994af16..e7f27e1 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -377,6 +377,8 @@ H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, break; } + + default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") } /* end switch */ @@ -605,7 +607,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR { /* Call mdc logging function */ if(H5C_start_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to start mdc logging") break; } @@ -615,7 +617,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR { /* Call mdc logging function */ if(H5C_stop_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to stop mdc logging") break; } @@ -628,7 +630,7 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR /* Call mdc logging function */ if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") + HGOTO_ERROR(H5E_FILE, H5E_LOGGING, FAIL, "unable to get logging status") break; } @@ -750,6 +752,23 @@ H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR break; } + /* H5Fget_dset_no_attrs_hint */ + case H5VL_NATIVE_FILE_GET_MIN_DSET_OHDR_FLAG: + { + hbool_t *minimize = va_arg(arguments, hbool_t *); + *minimize = H5F_GET_MIN_DSET_OHDR(f); + break; + } + + /* H5Fset_dset_no_attrs_hint */ + case H5VL_NATIVE_FILE_SET_MIN_DSET_OHDR_FLAG: + { + int minimize = va_arg(arguments, int); + if(H5F_set_min_dset_ohdr(f, (hbool_t)minimize) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set file's dataset object header minimization flag") + break; + } + default: HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") } /* end switch */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 22cf12b..5de36c8 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -115,7 +115,7 @@ typedef enum H5VL_file_get_t { H5VL_FILE_GET_INTENT, /* file intent */ H5VL_FILE_GET_NAME, /* file name */ H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ - H5VL_FILE_GET_OBJ_IDS /* object ids in file */ + H5VL_FILE_GET_OBJ_IDS /* object ids in file */ } H5VL_file_get_t; /* types for file SPECIFIC callback */ diff --git a/src/H5err.txt b/src/H5err.txt index 3965242..93a3abd 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -181,7 +181,7 @@ MINOR, CACHE, H5E_CANTRESIZE, Unable to resize a metadata cache entry MINOR, CACHE, H5E_CANTDEPEND, Unable to create a flush dependency MINOR, CACHE, H5E_CANTUNDEPEND, Unable to destroy a flush dependency MINOR, CACHE, H5E_CANTNOTIFY, Unable to notify object about action -MINOR, CACHE, H5E_LOGFAIL, Failure in the cache logging framework +MINOR, CACHE, H5E_LOGGING, Failure in the cache logging framework MINOR, CACHE, H5E_CANTCORK, Unable to cork an object MINOR, CACHE, H5E_CANTUNCORK, Unable to uncork an object diff --git a/src/Makefile.am b/src/Makefile.am index c0be29c..5532655 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,12 +40,12 @@ DISTCLEANFILES=H5pubconf.h # library sources libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5A.c H5Abtree2.c H5Adense.c H5Adeprec.c H5Aint.c H5Atest.c \ - H5AC.c H5ACdbg.c H5AClog.c H5ACproxy_entry.c \ + H5AC.c H5ACdbg.c H5ACproxy_entry.c \ H5B.c H5Bcache.c H5Bdbg.c \ H5B2.c H5B2cache.c H5B2dbg.c H5B2hdr.c H5B2int.c H5B2internal.c \ H5B2leaf.c H5B2stat.c H5B2test.c \ - H5C.c H5Cdbg.c H5Cepoch.c H5Cimage.c H5Clog.c H5Cprefetched.c \ - H5Cquery.c H5Ctag.c H5Ctest.c \ + H5C.c H5Cdbg.c H5Cepoch.c H5Cimage.c H5Clog.c H5Clog_json.c H5Clog_trace.c \ + H5Cprefetched.c H5Cquery.c H5Ctag.c H5Ctest.c \ H5CS.c \ H5CX.c \ H5D.c H5Dbtree.c H5Dbtree2.c H5Dchunk.c H5Dcompact.c H5Dcontig.c H5Ddbg.c \ diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index 531cd00..9d0e29f 100644 --- a/src/libhdf5.settings.in +++ b/src/libhdf5.settings.in @@ -82,7 +82,6 @@ Parallel Filtered Dataset Writes: @PARALLEL_FILTERED_WRITES@ API tracing: @TRACE_API@ Using memory checker: @USINGMEMCHECKER@ Memory allocation sanity checks: @MEMORYALLOCSANITYCHECK@ - Metadata trace file: @METADATATRACEFILE@ Function stack tracing: @CODESTACK@ Strict file format checks: @STRICT_FORMAT_CHECKS@ Optimization instrumentation: @INSTRUMENT_LIBRARY@ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ed6bacc..0d67485 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -133,7 +133,7 @@ if (BUILD_SHARED_LIBS) # Define VOL Plugin Test Sources #----------------------------------------------------------------------------- set (VOL_PLUGIN_LIBS - echo_vol + null_vol_connector ) foreach (vol_lib ${VOL_PLUGIN_LIBS}) @@ -374,6 +374,7 @@ set (H5_CHECK_TESTS atomic_reader links_env filenotclosed + del_many_dense_attrs flushrefresh ) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 26faba6..c0d4813 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -359,6 +359,9 @@ set (test_CLEANFILES lheap.h5 fheap.h5 ohdr.h5 + ohdr_min_a.h5 + ohdr_min_b.h5 + min_dset_ohdr_testfile.h5 stab.h5 extern_*.h5 extern_*.raw @@ -517,6 +520,7 @@ set (test_CLEANFILES flushrefresh_VERIFICATION_CHECKPOINT2 flushrefresh_VERIFICATION_DONE filenotclosed.h5 + del_many_dense_attrs.h5 atomic_data accum_swmr_big.h5 ohdr_swmr.h5 @@ -793,6 +797,7 @@ set_tests_properties (H5TEST-tcheck_version-release PROPERTIES # atomic_reader # links_env # filenotclosed +# del_many_dense_attrs # flushrefresh ############################################################################## # autotools script tests @@ -800,7 +805,7 @@ set_tests_properties (H5TEST-tcheck_version-release PROPERTIES # NOT CONVERTED accum_swmr_reader is used by accum.c. # NOT CONVERTED atomic_writer and atomic_reader are standalone programs. # links_env is used by testlinks_env.sh -# filenotclosed is used by test_filenotclosed.sh +# filenotclosed and del_many_dense_attrs are used by testabort_fail.sh # NOT CONVERTED flushrefresh is used by testflushrefresh.sh. # NOT CONVERTED use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh # NOT CONVERTED swmr_* files (besides swmr.c) are used by testswmr.sh. @@ -827,6 +832,23 @@ set_tests_properties (H5TEST-filenotclosed PROPERTIES WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) +#-- Adding test for del_many_dense_attrs +add_test ( + NAME H5TEST-clear-del_many_dense_attrs-objects + COMMAND ${CMAKE_COMMAND} + -E remove + del_many_dense_attrs.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +set_tests_properties (H5TEST-clear-del_many_dense_attrs-objects PROPERTIES FIXTURES_SETUP del_many_dense_attrs_clear_objects) +add_test (NAME H5TEST-del_many_dense_attrs COMMAND $<TARGET_FILE:del_many_dense_attrs>) +set_tests_properties (H5TEST-del_many_dense_attrs PROPERTIES + FIXTURES_REQUIRED del_many_dense_attrs_clear_objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) + #-- Adding test for err_compat if (HDF5_ENABLE_DEPRECATED_SYMBOLS) add_test (NAME H5TEST-clear-err_compat-objects diff --git a/test/Makefile.am b/test/Makefile.am index 1526eca..88dc542 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -29,20 +29,21 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_builddir)/src # testflushrefresh.sh: flushrefresh # testswmr.sh: swmr* # testvdsswmr.sh: vds_swmr* -# test_filenotclosed.sh: filenotclosed.c +# 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 test_filenotclosed.sh\ - testswmr.sh testvdsswmr.sh testflushrefresh.sh test_usecases.sh -SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) filenotclosed$(EXEEXT) \ +TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh \ + testswmr.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) \ 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) if HAVE_SHARED_CONDITIONAL - TEST_SCRIPT += test_filter_plugin.sh - SCRIPT_DEPEND += filter_plugin$(EXEEXT) + TEST_SCRIPT += test_filter_plugin.sh test_vol_plugin.sh + SCRIPT_DEPEND += filter_plugin$(EXEEXT) vol_plugin$(EXEEXT) endif check_SCRIPTS = $(TEST_SCRIPT) @@ -52,8 +53,8 @@ check_SCRIPTS = $(TEST_SCRIPT) # As an exception, long-running tests should occur earlier in the list. # This gives them more time to run when tests are executing in parallel. TEST_PROG= testhdf5 \ - cache cache_api cache_image cache_tagging lheap ohdr stab gheap \ - evict_on_close farray earray btree2 fheap \ + cache cache_api cache_image cache_tagging lheap ohdr \ + stab gheap evict_on_close farray earray btree2 fheap \ pool accum hyperslab istore bittests dt_arith page_buffer \ dtypes dsets cmpd_dset filter_fail extend direct_chunk external efc \ objcopy links unlink twriteorder big mtime fillval mount \ @@ -68,7 +69,7 @@ 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 -# filenotclosed is used by test_filenotclosed.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. @@ -78,12 +79,13 @@ TEST_PROG= testhdf5 \ # 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 \ - links_env filenotclosed flushrefresh use_append_chunk use_append_mchunks use_disable_mdc_flushes \ + 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 if HAVE_SHARED_CONDITIONAL - check_PROGRAMS+= filter_plugin + check_PROGRAMS+= filter_plugin vol_plugin endif # These programs generate test files for the tests. They don't need to be @@ -106,9 +108,7 @@ if HAVE_SHARED_CONDITIONAL # The libh5test library provides common support code for the tests. # The filter_plugin* libraries are for use in filter_plugin.c. # Build them as shared libraries if that option was enabled in configure. - # - # echo_vol is used for testing VOL plugin functionality. - noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la echo_vol.la + noinst_LTLIBRARIES=libh5test.la libfilter_plugin1_dsets.la libfilter_plugin2_dsets.la libfilter_plugin3_dsets.la libfilter_plugin4_groups.la libnull_vol_connector.la libfilter_plugin1_dsets_la_SOURCES=filter_plugin1_dsets.c libfilter_plugin2_dsets_la_SOURCES=filter_plugin2_dsets.c libfilter_plugin3_dsets_la_SOURCES=filter_plugin3_dsets.c @@ -121,8 +121,10 @@ if HAVE_SHARED_CONDITIONAL libfilter_plugin4_groups_la_LIBADD=$(LIBHDF5) # VOL plugin test libraries - echo_vol_la_SOURCES=echo_vol.c - echo_vol_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere + # + # null_vol_connector is used for testing basic VOL plugin functionality. + libnull_vol_connector_la_SOURCES=null_vol_connector.c + libnull_vol_connector_la_LDFLAGS=$(AM_LDFLAGS) -avoid-version -module -shared -export-dynamic -rpath /nowhere else # The libh5test library provides common support code for the tests. @@ -177,6 +179,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse extend.h5 istore.h5 extlinks*.h5 frspace.h5 links*.h5 \ sys_file1 tfile[1-7].h5 th5s[1-4].h5 lheap.h5 fheap.h5 ohdr.h5 \ stab.h5 extern_[1-5].h5 extern_[1-4][rw].raw gheap[0-4].h5 \ + ohdr_min_a.h5 ohdr_min_b.h5 min_dset_ohdr_testfile.h5\ dt_arith[1-2] links.h5 links[0-6]*.h5 extlinks[0-15].h5 tmp \ big.data big[0-9][0-9][0-9][0-9][0-9].h5 \ stdio.h5 sec2.h5 dtypes[0-9].h5 dtypes1[0].h5 dt_arith[1-2].h5 tattr.h5 \ @@ -220,6 +223,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 test_filenotclosed.sh + testswmr.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/ShellTests.cmake b/test/ShellTests.cmake index 58dc85d..98f3daf 100644 --- a/test/ShellTests.cmake +++ b/test/ShellTests.cmake @@ -171,6 +171,7 @@ if (UNIX) # atomic_writer # atomic_reader # filenotclosed + # del_many_dense_attrs # flushrefresh ############################################################################## # autotools script tests @@ -178,7 +179,7 @@ if (UNIX) # NOT CONVERTED accum_swmr_reader is used by accum.c. # NOT CONVERTED atomic_writer and atomic_reader are standalone programs. # links_env is used by testlinks_env.sh - # filenotclosed is used by test_filenotclosed.sh + # filenotclosed and del_many_dense_attrs are used by testabort_fail.sh # NOT CONVERTED flushrefresh is used by testflushrefresh.sh. # NOT CONVERTED use_append_chunk, use_append_mchunks and use_disable_mdc_flushes are used by test_usecases.sh # NOT CONVERTED swmr_* files (besides swmr.c) are used by testswmr.sh. diff --git a/test/del_many_dense_attrs.c b/test/del_many_dense_attrs.c new file mode 100644 index 0000000..bbae48d --- /dev/null +++ b/test/del_many_dense_attrs.c @@ -0,0 +1,203 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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: Test to verify that the infinite loop closing library/abort failure + * is fixed when the application creates and removes dense attributes + * (See HDFFV-10659). + */ + + +#include "h5test.h" + +/* The test file name */ +const char *FILENAME[] = { + "del_many_dense_attrs", + NULL +}; + +#define ATTR_COUNT 64 /* The number of attributes */ + +/*------------------------------------------------------------------------- + * Function: catch_signal + * + * Purpose: The signal handler to catch the SIGABRT signal. + * + * Return: No return + * + * Programmer: Vailin Choi + * + *------------------------------------------------------------------------- + */ +static void catch_signal(int H5_ATTR_UNUSED signo) +{ + HDexit(1); +} /* catch_signal() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Test to verify that the infinite loop closing library/abort failure + * is fixed when the application creates and removes dense attributes + * (See HDFFV-10659). + * + * Return: Success: exit(EXIT_SUCCESS) + * Failure: exit(EXIT_FAILURE) + * + * Programmer: Vailin Choi; Dec 2018 + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + hid_t fid = -1; /* HDF5 File ID */ + hid_t gid = -1; /* Group ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t aid = -1; /* Attribute ID */ + hid_t tid = -1; /* Datatype ID */ + hid_t fapl = -1; /* File access property lists */ + hid_t gcpl = -1; /* Group creation property list */ + char aname[50]; /* Name of attribute */ + char *basename="attr"; /* Name prefix for attribute */ + char filename[100]; /* File name */ + int i; /* Local index variable */ + + /* Testing setup */ + h5_reset(); + + /* To exit from the file for SIGABRT signal */ + if(HDsignal(SIGABRT, catch_signal) == SIG_ERR) + TEST_ERROR + + fapl = h5_fileaccess(); + h5_fixname(FILENAME[0], fapl, filename, sizeof(filename)); + + /* Set to latest format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + TEST_ERROR + + /* Create the file */ + if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) + TEST_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + TEST_ERROR + + /* Re-open the file */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + + /* Create the group creation property list */ + if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) + TEST_ERROR + + /* Set to use dense storage for all attributes on the group */ + if(H5Pset_attr_phase_change(gcpl, 0, 0) < 0) + TEST_ERROR + + /* Create the group in the file */ + if((gid = H5Gcreate2(fid, "group", H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Create dataspace */ + if((sid = H5Screate(H5S_SCALAR)) < 0) + TEST_ERROR + + /* Get a copy of the datatype */ + if((tid = H5Tcopy(H5T_NATIVE_FLOAT)) < 0) + TEST_ERROR + + /* Create attributes in the group */ + for(i = ATTR_COUNT; i >= 0; i--) { + /* Set up the attribute name */ + HDsprintf(aname, "%s%d", basename, i); + + /* Create the attribute */ + if((aid = H5Acreate2(gid, aname, tid, sid, H5P_DEFAULT, H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Write to the attribute */ + if(H5Awrite(aid, tid, &i) < 0) + TEST_ERROR + + /* Close the attribute */ + if(H5Aclose(aid) < 0) + TEST_ERROR + } + + /* Close the datatype */ + if(H5Tclose(tid) < 0) + TEST_ERROR + + /* Close the dataspace */ + if(H5Sclose(sid) < 0) + TEST_ERROR + + /* Close the group */ + if(H5Gclose(gid) < 0) + TEST_ERROR + + /* Close the group creation property list */ + if(H5Pclose(gcpl) < 0) + TEST_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + TEST_ERROR + + /* Re-open the file */ + if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) + TEST_ERROR + + /* Open the group */ + if((gid = H5Gopen(fid, "group", H5P_DEFAULT)) < 0) + TEST_ERROR + + /* Delete the attributes */ + for (i = 0; i <= ATTR_COUNT; i++) { + /* Set up the attribute name */ + HDsprintf(aname, "%s%d", basename, i); + + /* Delete the attribute */ + if(H5Adelete(gid, aname) < 0) + TEST_ERROR + } /* end for */ + + /* Close the group */ + if(H5Gclose(gid) < 0) + TEST_ERROR + + /* Close the file */ + if(H5Fclose(fid) < 0) + TEST_ERROR + + h5_cleanup(FILENAME, fapl); + + return(EXIT_SUCCESS); + +error: + H5E_BEGIN_TRY { + H5Gclose(gid); + H5Sclose(sid); + H5Tclose(tid); + H5Aclose(aid); + H5Fclose(fid); + H5Pclose(gcpl); + H5Pclose(fapl); + } H5E_END_TRY + + return EXIT_FAILURE; +} diff --git a/test/dsets.c b/test/dsets.c index 5cd376a..5de9cfa 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -86,6 +86,9 @@ const char *FILENAME[] = { NULL }; +#define OHMIN_FILENAME_A "ohdr_min_a" + + #define FILENAME_BUF_SIZE 1024 #define KB 1024 @@ -338,7 +341,7 @@ filter_count(unsigned int flags, size_t H5_ATTR_UNUSED cd_nelmts, count_nbytes_written += nbytes; return nbytes; -} +} /* end filter_count() */ /*------------------------------------------------------------------------- @@ -481,11 +484,11 @@ test_create(hid_t file) if(H5Dclose(dataset) < 0) goto error; PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_create() */ /*------------------------------------------------------------------------- @@ -605,7 +608,7 @@ test_simple_io(const char *env_h5_drvr, hid_t fapl) puts(" Current VFD doesn't support continuous address space"); } /* end else */ - return 0; + return SUCCEED; error: if(space > 0) @@ -620,8 +623,8 @@ error: HDclose(f); if(tconv_buf) HDfree(tconv_buf); - return -1; -} + return FAIL; +} /* end test_simple_io() */ /*------------------------------------------------------------------------- @@ -713,7 +716,7 @@ test_userblock_offset(const char *env_h5_drvr, hid_t fapl, hbool_t new_format) puts(" Current VFD doesn't support continuous address space"); } /* end else */ - return 0; + return SUCCEED; error: if(space > 0) @@ -726,8 +729,8 @@ error: if(H5Fclose(file) < 0) TEST_ERROR if(f > 0) HDclose(f); - return -1; -} + return FAIL; +} /* end test_userblock_offset() */ /*------------------------------------------------------------------------- @@ -826,7 +829,7 @@ test_compact_io(hid_t fapl) **************************************/ /* Create a copy of file access property list */ - if((new_fapl = new_fapl = h5_fileaccess()) < 0) TEST_ERROR + if((new_fapl = h5_fileaccess()) < 0) TEST_ERROR /* Loop through all the combinations of low/high library format bounds, skipping invalid combinations. @@ -907,7 +910,7 @@ test_compact_io(hid_t fapl) if(H5Pclose(plist) < 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -919,8 +922,8 @@ test_compact_io(hid_t fapl) H5Fclose(verfile); } H5E_END_TRY; - return -1; -} + return FAIL; +} /* end test_compact_io() */ /*------------------------------------------------------------------------- @@ -1056,7 +1059,7 @@ test_max_compact(hid_t fapl) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: if(wbuf) @@ -1072,7 +1075,7 @@ error: H5Fclose(file); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_max_compact() */ @@ -1181,7 +1184,7 @@ test_layout_extend(hid_t fapl) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1195,7 +1198,7 @@ error: H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_layout_extend() */ @@ -1331,7 +1334,7 @@ test_conv_buffer(hid_t fid) HDfree(cf); HDfree(cfrR); puts(" PASSED"); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -1347,8 +1350,8 @@ error: H5Dclose(dataset); } H5E_END_TRY; - return -1; -} + return FAIL; +} /* end test_conv_buffer() */ /*------------------------------------------------------------------------- @@ -1418,7 +1421,7 @@ test_tconv(hid_t file) HDfree(in); puts(" PASSED"); - return 0; + return SUCCEED; error: if(out) @@ -1431,8 +1434,8 @@ error: H5Sclose(space); } H5E_END_TRY; - return -1; -} + return FAIL; +} /* end test_tconv() */ /* This message derives from H5Z */ const H5Z_class2_t H5Z_BOGUS[1] = {{ @@ -1465,7 +1468,7 @@ can_apply_bogus(hid_t H5_ATTR_UNUSED dcpl_id, hid_t type_id, hid_t H5_ATTR_UNUSE return 1; else return -1; -} +} /* end can_apply_bogus() */ /*------------------------------------------------------------------------- @@ -1483,7 +1486,7 @@ filter_bogus(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts, size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) { return nbytes; -} +} /* end filter_bogus() */ /*------------------------------------------------------------------------- @@ -1583,7 +1586,7 @@ filter_bogus2(unsigned int flags, size_t cd_nelmts, /* Filter is "no op" */ else return(nbytes); -} +} /* end filter_bogus2() */ /*------------------------------------------------------------------------- @@ -1601,7 +1604,7 @@ filter_bogus3(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf) { return 0; -} +} /* end filter_bogus3() */ /* This message derives from H5Z */ const H5Z_class2_t H5Z_CORRUPT[1] = {{ @@ -1690,7 +1693,7 @@ filter_cb_cont(H5Z_filter_t filter, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNU return H5Z_CB_CONT; else return H5Z_CB_FAIL; -} +} /* end filter_cb_cont() */ /*------------------------------------------------------------------------- @@ -1709,7 +1712,7 @@ filter_cb_fail(H5Z_filter_t filter, void H5_ATTR_UNUSED *buf, size_t H5_ATTR_UNU return H5Z_CB_FAIL; else return H5Z_CB_CONT; -} +} /* end filter_cb_fail() */ /*------------------------------------------------------------------------- @@ -2052,13 +2055,13 @@ test_filter_internal(hid_t fid, const char *name, hid_t dcpl, int if_fletcher32, if(H5Pclose (write_dxpl) < 0) goto error; HDfree (tconv_buf); - return(0); + return SUCCEED; error: if(tconv_buf) HDfree (tconv_buf); - return -1; -} + return FAIL; +} /* end test_filter_internal() */ /*------------------------------------------------------------------------- * Function: test_filter_noencoder @@ -2160,7 +2163,7 @@ test_filter_noencoder(const char *dset_name) PASSED(); - return 0; + return SUCCEED; error: H5_FAILED(); @@ -2175,8 +2178,8 @@ error: if(file_id != -1) H5Fclose(file_id); - return -1; -} + return FAIL; +} /* end test_filter_noencoder() */ #endif /* H5_HAVE_FILTER_SZIP */ /*------------------------------------------------------------------------- @@ -2242,11 +2245,11 @@ test_get_filter_info(void) if(err >= 0) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_get_filter_info() */ /*------------------------------------------------------------------------- * Function: test_filters @@ -2517,11 +2520,11 @@ H5_ATTR_UNUSED SKIPPED(); puts(" szip filter not enabled"); #endif /* H5_HAVE_FILTER_SZIP */ - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_filters() */ /*------------------------------------------------------------------------- @@ -2856,11 +2859,11 @@ test_onebyte_shuffle(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_onebyte_shuffle() */ /*------------------------------------------------------------------------- @@ -2974,11 +2977,11 @@ test_nbit_int(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_int() */ /*------------------------------------------------------------------------- @@ -3092,11 +3095,11 @@ test_nbit_float(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_float() */ /*------------------------------------------------------------------------- @@ -3224,11 +3227,11 @@ test_nbit_double(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_double() */ /*------------------------------------------------------------------------- @@ -3351,11 +3354,11 @@ test_nbit_array(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_array() */ /*------------------------------------------------------------------------- @@ -3568,11 +3571,11 @@ test_nbit_compound(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_compound() */ /*------------------------------------------------------------------------- @@ -3913,11 +3916,11 @@ out: PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_compound_2() */ /*------------------------------------------------------------------------- @@ -4093,11 +4096,11 @@ test_nbit_compound_3(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_compound_3() */ /*------------------------------------------------------------------------- @@ -4261,10 +4264,10 @@ test_nbit_int_size(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_int_size() */ /*------------------------------------------------------------------------- @@ -4458,10 +4461,10 @@ test_nbit_flt_size(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_nbit_flt_size() */ /*------------------------------------------------------------------------- * Function: test_scaleoffset_int @@ -4569,10 +4572,10 @@ test_scaleoffset_int(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_scaleoffset_int() */ /*------------------------------------------------------------------------- @@ -4697,10 +4700,10 @@ test_scaleoffset_int_2(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_scaleoffset_int_2() */ /*------------------------------------------------------------------------- @@ -4810,10 +4813,10 @@ test_scaleoffset_float(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_scaleoffset_float() */ /*------------------------------------------------------------------------- @@ -4939,10 +4942,10 @@ test_scaleoffset_float_2(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_scaleoffset_float_2() */ /*------------------------------------------------------------------------- @@ -5052,10 +5055,10 @@ test_scaleoffset_double(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_scaleoffset_double() */ /*------------------------------------------------------------------------- @@ -5182,10 +5185,10 @@ test_scaleoffset_double_2(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; -} + return FAIL; +} /* end test_scaleoffset_double_2() */ /*------------------------------------------------------------------------- @@ -5242,17 +5245,17 @@ test_multiopen (hid_t file) if(H5Pclose(dcpl) < 0) goto error; PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { - H5Dclose(dset1); - H5Dclose(dset2); - H5Sclose(space); - H5Pclose(dcpl); + H5Dclose(dset1); + H5Dclose(dset2); + H5Sclose(space); + H5Pclose(dcpl); } H5E_END_TRY; - return -1; -} + return FAIL; +} /* end test_multiopen() */ /*------------------------------------------------------------------------- @@ -5338,7 +5341,7 @@ test_types(hid_t file) /* Cleanup */ if(H5Gclose(grp) < 0) goto error; PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -5347,8 +5350,8 @@ test_types(hid_t file) H5Sclose(space); H5Dclose(dset); } H5E_END_TRY; - return -1; -} + return FAIL; +} /* end test_types() */ /* This message derives from H5Z */ const H5Z_class2_t H5Z_CAN_APPLY_TEST[1] = {{ @@ -5525,10 +5528,10 @@ test_can_apply(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end test_can_apply() */ /* This message derives from H5Z */ @@ -5684,10 +5687,10 @@ test_can_apply2(hid_t file) PASSED(); - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end test_can_apply2() */ @@ -5876,11 +5879,11 @@ file) SKIPPED(); puts(" Szip filter is not enabled."); #endif /* H5_HAVE_FILTER_SZIP */ - return 0; + return SUCCEED; #ifdef H5_HAVE_FILTER_SZIP error: - return -1; + return FAIL; #endif /* H5_HAVE_FILTER_SZIP */ } /* end test_can_apply_szip() */ @@ -6155,10 +6158,10 @@ test_set_local(hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end test_set_local() */ @@ -6233,7 +6236,7 @@ test_compare_dcpl(hid_t file) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6243,7 +6246,7 @@ error: H5Pclose(dcpl1); H5Pclose(dcpl2); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_compare_dcpl() */ @@ -6360,7 +6363,7 @@ test_copy_dcpl(hid_t file, hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6375,7 +6378,7 @@ error: H5Pclose(dcpl1_copy); H5Pclose(dcpl2_copy); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_copy_dcpl() */ @@ -6492,7 +6495,7 @@ test_filter_delete(hid_t file) #else SKIPPED(); #endif - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6501,7 +6504,7 @@ error: H5Dclose(dsid); H5Sclose(sid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_filter_delete() */ @@ -6574,7 +6577,7 @@ auxread_fdata(hid_t fid, const char *name) if(buf) HDfree(buf); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6586,8 +6589,8 @@ error: if(buf) HDfree(buf); } H5E_END_TRY; - return -1; -} + return FAIL; +} /* end auxread_fdata() */ /*------------------------------------------------------------------------- @@ -6647,7 +6650,7 @@ test_filters_endianess(void) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6656,7 +6659,7 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_filters_endianess() */ @@ -6806,7 +6809,7 @@ test_zero_dims(hid_t file) if(H5Sclose(s2) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -6820,7 +6823,7 @@ error: H5Dclose(d2); H5Sclose(s2); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_zero_dims() */ @@ -6999,7 +7002,7 @@ test_missing_chunk(hid_t file) if(H5Dclose(did2) < 0) TEST_ERROR; PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7012,7 +7015,7 @@ error: H5Sclose(s); H5Sclose(sid2); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_missing_chunk() */ @@ -7370,7 +7373,7 @@ test_random_chunks_real(const char *testname, hbool_t early_alloc, hid_t fapl) if(H5Fclose(file) < 0) TEST_ERROR; PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7380,7 +7383,7 @@ error: H5Dclose(d); H5Fclose(file); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_random_chunks_real() */ @@ -7627,10 +7630,10 @@ test_deprec(hid_t file) if(H5Pclose(dcpl) < 0) goto error; - return 0; + return SUCCEED; error: - return -1; + return FAIL; } /* end test_deprec() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -7734,7 +7737,7 @@ test_huge_chunks(hid_t fapl) if(H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7743,7 +7746,7 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_huge_chunks() */ @@ -7938,7 +7941,7 @@ test_chunk_cache(hid_t fapl) if (H5Fclose(fid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -7951,7 +7954,7 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_chunk_cache() */ @@ -8225,7 +8228,7 @@ test_big_chunks_bypass_cache(hid_t fapl) HDfree(rdata2); PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -8244,7 +8247,7 @@ error: HDfree(rdata1); if(rdata2) HDfree(rdata2); - return -1; + return FAIL; } /* end test_big_chunks_bypass_cache() */ @@ -8580,7 +8583,7 @@ test_chunk_fast(const char *env_h5_driver, hid_t fapl) if(H5Pclose(my_fapl) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -8591,7 +8594,7 @@ error: H5Fclose(fid); H5Pclose(my_fapl); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_chunk_fast() */ @@ -8704,7 +8707,7 @@ test_reopen_chunk_fast(hid_t fapl) } /* end for */ PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -8714,7 +8717,7 @@ error: H5Sclose(scalar_sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_reopen_chunk_fast() */ @@ -8813,7 +8816,7 @@ test_chunk_fast_bug1(hid_t fapl) if(H5Sclose(sid) < 0) FAIL_STACK_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -8822,7 +8825,7 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_chunk_fast_bug1() */ /* This message derives from H5Z */ @@ -9268,7 +9271,7 @@ test_chunk_expand(hid_t fapl) PASSED(); } /* end else */ - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -9281,7 +9284,7 @@ error: H5Sclose(scalar_sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_chunk_expand() */ @@ -9686,7 +9689,7 @@ test_fixed_array(hid_t fapl) HDfree(rbuf_big); PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -9700,7 +9703,7 @@ error: HDfree(wbuf_big); if(rbuf_big) HDfree(rbuf_big); - return -1; + return FAIL; } /* end test_fixed_array() */ @@ -9944,7 +9947,7 @@ test_single_chunk(hid_t fapl) HDfree(t_rbuf); PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -9964,7 +9967,7 @@ error: HDfree(t_wbuf); if(t_rbuf) HDfree(t_rbuf); - return -1; + return FAIL; } /* end test_single_chunk() */ @@ -10030,15 +10033,15 @@ test_idx_compatible(void) } PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Dclose(did); H5Fclose(fid); } H5E_END_TRY; - return -1; -} /* test_idx_compatible */ + return FAIL; +} /* end test_idx_compatible() */ /*------------------------------------------------------------------------- * @@ -10168,7 +10171,7 @@ test_unfiltered_edge_chunks(hid_t fapl) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10177,8 +10180,8 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; -} /* test_unfiltered_edge_chunks */ + return FAIL; +} /* end test_unfiltered_edge_chunks() */ /*------------------------------------------------------------------------- @@ -10282,7 +10285,7 @@ test_large_chunk_shrink(hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10292,7 +10295,7 @@ error: H5Sclose(scalar_sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_large_chunk_shrink() */ @@ -10376,7 +10379,7 @@ test_zero_dim_dset(hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10385,7 +10388,7 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_zero_dim_dset() */ @@ -10426,7 +10429,7 @@ test_swmr_non_latest(const char *env_h5_driver, hid_t fapl) if(!H5FD__supports_swmr_test(env_h5_driver)) { SKIPPED(); HDputs(" Test skipped due to VFD not supporting SWMR I/O."); - return 0; + return SUCCEED; } /* Check if we are using the latest version of the format */ @@ -10625,7 +10628,7 @@ test_swmr_non_latest(const char *env_h5_driver, hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10635,7 +10638,7 @@ error: H5Gclose(gid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* test_swmr_non_latest() */ @@ -10676,7 +10679,7 @@ test_earray_hdr_fd(const char *env_h5_driver, hid_t fapl) if(!H5FD__supports_swmr_test(env_h5_driver)) { SKIPPED(); HDputs(" Test skipped due to VFD not supporting SWMR I/O."); - return 0; + return SUCCEED; } if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -10743,7 +10746,7 @@ test_earray_hdr_fd(const char *env_h5_driver, hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10755,7 +10758,7 @@ error: H5Sclose(sid); H5Sclose(msid); } H5E_END_TRY; - return -1; + return FAIL; } /* test_earray_hdr_fd() */ @@ -10796,7 +10799,7 @@ test_farray_hdr_fd(const char *env_h5_driver, hid_t fapl) if(!H5FD__supports_swmr_test(env_h5_driver)) { SKIPPED(); HDputs(" Test skipped due to VFD not supporting SWMR I/O."); - return 0; + return SUCCEED; } if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -10863,7 +10866,7 @@ test_farray_hdr_fd(const char *env_h5_driver, hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10875,8 +10878,8 @@ error: H5Sclose(sid); H5Sclose(msid); } H5E_END_TRY; - return -1; -} /* test_farray_hdr_fd() */ + return FAIL; +} /* end test_farray_hdr_fd() */ /*------------------------------------------------------------------------- @@ -10916,7 +10919,7 @@ test_bt2_hdr_fd(const char *env_h5_driver, hid_t fapl) if(!H5FD__supports_swmr_test(env_h5_driver)) { SKIPPED(); HDputs(" Test skipped due to VFD not supporting SWMR I/O."); - return 0; + return SUCCEED; } if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) @@ -10983,7 +10986,7 @@ test_bt2_hdr_fd(const char *env_h5_driver, hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -10995,8 +10998,8 @@ error: H5Sclose(sid); H5Sclose(msid); } H5E_END_TRY; - return -1; -} /* test_bt2_hdr_fd() */ + return FAIL; +} /* end test_bt2_hdr_fd() */ /*------------------------------------------------------------------------- @@ -11379,7 +11382,7 @@ test_storage_size(hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -11389,7 +11392,7 @@ error: H5Sclose(sid); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_storage_size() */ @@ -11470,7 +11473,7 @@ test_power2up(hid_t fapl) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -11480,7 +11483,7 @@ error: H5Pclose(dcpl); H5Fclose(fid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_power2up() */ @@ -11792,13 +11795,13 @@ test_scatter(void) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Sclose(sid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_scatter() */ @@ -11860,7 +11863,7 @@ gather_cb(const void *dst_buf, size_t dst_buf_bytes_used, error: return FAIL; -} +} /* end gather_cb() */ static herr_t test_gather(void) @@ -12154,13 +12157,13 @@ test_gather(void) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Sclose(sid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_gather() */ @@ -12194,7 +12197,7 @@ scatter_error_cb_fail(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]); return FAIL; -} +} /* end scatter_error_cb_fail() */ static herr_t scatter_error_cb_null(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, @@ -12212,7 +12215,7 @@ scatter_error_cb_null(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, *src_buf_bytes_used = nelmts * sizeof(scatter_info->src_buf[0]); return SUCCEED; -} +} /* end scatter_error_cb_null() */ static herr_t scatter_error_cb_unalign(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out*/, @@ -12223,7 +12226,7 @@ scatter_error_cb_unalign(void **src_buf/*out*/, size_t *src_buf_bytes_used/*out* *src_buf_bytes_used = *(size_t *)_src_buf_bytes_used; return SUCCEED; -} +} /* endscatter_error_cb_unalign() */ static herr_t test_scatter_error(void) @@ -12357,13 +12360,13 @@ test_scatter_error(void) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Sclose(sid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_scatter_error() */ @@ -12386,7 +12389,7 @@ gather_error_cb_fail(const void H5_ATTR_UNUSED *dst_buf, size_t H5_ATTR_UNUSED dst_buf_bytes_used, void H5_ATTR_UNUSED *op_data) { return FAIL; -} +} /* end gather_error_cb_fail() */ static herr_t test_gather_error(void) @@ -12496,13 +12499,13 @@ test_gather_error(void) PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { H5Sclose(sid); } H5E_END_TRY; - return -1; + return FAIL; } /* end test_gather_error() */ /*------------------------------------------------------------------------- @@ -12599,8 +12602,8 @@ static herr_t dls_01_read_stuff( hid_t fid ); static herr_t dls_01_main( void ); static herr_t -dls_01_setup_file( hid_t fid ) { - +dls_01_setup_file( hid_t fid ) +{ int status = 0; hid_t sid = 0, did = 0, tid = 0, dcpl = 0; int ndims = 1; @@ -12638,17 +12641,15 @@ dls_01_setup_file( hid_t fid ) { status = H5Sclose( sid ); if ( status != 0 ) TEST_ERROR - return 0; + return SUCCEED; error: - - return -1; - -} /* dls_01_setup_file */ + return FAIL; +} /* end dls_01_setup_file() */ static herr_t -dls_01_write_data( hid_t fid, char* buffer ) { - +dls_01_write_data( hid_t fid, char* buffer ) +{ int status = 0; hid_t did = 0, tid = 0; hsize_t extent[1] = {4}; @@ -12674,17 +12675,15 @@ dls_01_write_data( hid_t fid, char* buffer ) { status = H5Dclose( did ); if ( status != 0 ) TEST_ERROR - return 0; + return SUCCEED; error: - - return -1; - -} /* dls_01_write_data */ + return FAIL; +} /* end dls_01_write_data() */ static herr_t -dls_01_read_stuff( hid_t fid ) { - +dls_01_read_stuff( hid_t fid ) +{ int status = 0; hid_t did = 0; H5O_info_t info; @@ -12698,17 +12697,15 @@ dls_01_read_stuff( hid_t fid ) { status = H5Dclose( did ); if ( status != 0 ) TEST_ERROR - return 0; + return SUCCEED; error: - - return -1; - -} /* dls_01_read_stuff() */ + return FAIL; +} /* end dls_01_read_stuff() */ static herr_t -dls_01_main( void ) { - +dls_01_main( void ) +{ char filename[512]; int status = 0; hid_t fapl = 0, fid = 0; @@ -12765,15 +12762,12 @@ dls_01_main( void ) { PASSED(); - return 0; + return SUCCEED; error: - if ( buffer ) HDfree(buffer); - - return -1; - -} /* dls_01_main() */ + return FAIL; +} /* end dls_01_main() */ /*------------------------------------------------------------------------- * Function: test_compact_open_close_dirty @@ -12881,7 +12875,7 @@ test_compact_open_close_dirty(hid_t fapl) TEST_ERROR PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -12890,8 +12884,8 @@ error: H5Dclose(did); H5Fclose(fid); } H5E_END_TRY; - return -1; -} /* test_compact_open_close_dirty() */ + return FAIL; +} /* end test_compact_open_close_dirty() */ /*------------------------------------------------------------------------- @@ -13030,7 +13024,7 @@ test_versionbounds(void) TEST_ERROR dcpl = -1; PASSED(); - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { @@ -13043,8 +13037,119 @@ test_versionbounds(void) H5Fclose(srcfile); H5Fclose(vfile); } H5E_END_TRY; - return -1; -} /* test_versionbounds() */ + return FAIL; +} /* end test_versionbounds() */ + + +/*----------------------------------------------------------------------------- + * Function: test_object_header_minimization_dcpl + * + * Purpose: Test the "datset object header minimization" property as part of + * the DCPL. + * + * Return: Success/pass: 0 + * Failure/error: -1 + * + * Programmer: Jacob Smith + * 2018 August 15 + * + * Changes: None. + *----------------------------------------------------------------------------- + */ +static herr_t +test_object_header_minimization_dcpl(void) +{ + hid_t dcpl_id = -1; + hid_t file_id = -1; + char filename[FILENAME_BUF_SIZE] = ""; + hbool_t minimize = FALSE; + herr_t ret; + + TESTING("dcpl flags to minimize dataset object header"); + + /*********/ + /* SETUP */ + /*********/ + + if(NULL == h5_fixname(OHMIN_FILENAME_A, H5P_DEFAULT, filename, sizeof(filename))) + TEST_ERROR + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + if (0 > file_id) TEST_ERROR + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if (0 > dcpl_id) TEST_ERROR + + /*********/ + /* TESTS */ + /*********/ + + /* default value (not set explicitly) + */ + if (H5Pget_dset_no_attrs_hint(dcpl_id, &minimize) == FAIL) TEST_ERROR + if (FALSE != minimize) + TEST_ERROR + + /* FALSE-set value + */ + if (H5Pset_dset_no_attrs_hint(dcpl_id, FALSE) == FAIL) TEST_ERROR + if (H5Pget_dset_no_attrs_hint(dcpl_id, &minimize) == FAIL) TEST_ERROR + if (FALSE != minimize) + TEST_ERROR + + /* TRUE-set value + */ + if (H5Pset_dset_no_attrs_hint(dcpl_id, TRUE) == FAIL) TEST_ERROR + if (H5Pget_dset_no_attrs_hint(dcpl_id, &minimize) == FAIL) TEST_ERROR + if (TRUE != minimize) + TEST_ERROR + + /* error cases + */ + H5E_BEGIN_TRY { + ret = H5Pget_dset_no_attrs_hint(-1, &minimize); + } H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR /* Invalid DCPL ID should fail */ + + H5E_BEGIN_TRY { + ret = H5Pset_dset_no_attrs_hint(-1, FALSE); + } H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR /* Invalid DCPL ID should fail */ + + H5E_BEGIN_TRY { + ret = H5Pset_dset_no_attrs_hint(-1, TRUE); + } H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR /* Invalid DCPL ID should fail */ + + H5E_BEGIN_TRY { + ret = H5Pget_dset_no_attrs_hint(dcpl_id, NULL); + } H5E_END_TRY; + if (ret == SUCCEED) + TEST_ERROR /* NULL out pointer should fail */ + + /************/ + /* TEARDOWN */ + /************/ + + if (H5Fclose(file_id) == FAIL) + TEST_ERROR + + if (H5Pclose(dcpl_id) == FAIL) + TEST_ERROR + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5Pclose(dcpl_id); + H5Fclose(file_id); + } H5E_END_TRY; + return FAIL; +} /* end test_object_header_minimization_dcpl() */ /*------------------------------------------------------------------------- @@ -13068,6 +13173,7 @@ main(void) hid_t fcpl = -1, fcpl2 = -1; unsigned new_format; unsigned paged; + unsigned minimized_ohdr; int mdc_nelmts; size_t rdcc_nelmts; size_t rdcc_nbytes; @@ -13118,10 +13224,12 @@ main(void) /* Test with paged aggregation enabled or not */ for(paged = FALSE; paged <= TRUE; paged++) { - /* Temporary: skip testing for multi/split drivers: - fail file create when persisting free-space or using paged aggregation strategy */ - if(!contig_addr_vfd && paged) - continue; + /* Temporary: skip testing for multi/split drivers: + fail file create when persisting free-space or using paged aggregation strategy */ + if(!contig_addr_vfd && paged) + continue; + + for (minimized_ohdr = FALSE; minimized_ohdr <= TRUE; minimized_ohdr++) { /* Test with old & new format groups */ for(new_format = FALSE; new_format <= TRUE; new_format++) { @@ -13153,6 +13261,12 @@ main(void) if((file = H5Fcreate(filename, H5F_ACC_TRUNC, my_fcpl, my_fapl)) < 0) goto error; + if (TRUE == minimized_ohdr) { + if (0 > H5Fset_dset_no_attrs_hint(file, TRUE)) + goto error; + puts("(minimized dataset object headers with file setting)"); + } + /* Cause the library to emit initial messages */ if((grp = H5Gcreate2(file, "emit diagnostics", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; @@ -13230,6 +13344,7 @@ main(void) if(H5Fclose(file) < 0) goto error; } /* end for new_format */ + } /* for minimized dset object headers */ } /* end for paged */ /* Close property lists */ @@ -13246,6 +13361,8 @@ main(void) /* Tests version bounds using its own file */ nerrors += (test_versionbounds() < 0 ? 1 : 0); + nerrors += (test_object_header_minimization_dcpl() < 0 ? 1 : 0); + /* Run misc tests */ nerrors += dls_01_main(); @@ -13261,12 +13378,12 @@ main(void) #endif /* H5_HAVE_FILTER_SZIP */ h5_cleanup(FILENAME, fapl); - return 0; + return EXIT_SUCCESS; error: nerrors = MAX(1, nerrors); printf("***** %d DATASET TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); - return 1; -} + return EXIT_FAILURE; +} /* end main() */ diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index dc9a62e..33d23dc 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -146,6 +146,9 @@ main(void) 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) diff --git a/test/gen_plist.c b/test/gen_plist.c index af248be..68da6cc 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -125,6 +125,9 @@ main(void) if((ret = H5Pset_fill_value(dcpl1, H5T_STD_I32BE, &fill)) < 0) assert(ret > 0); + if((ret = H5Pset_dset_no_attrs_hint(dcpl1, FALSE)) < 0) + assert(ret > 0); + max_size[0] = 100; if((ret = H5Pset_external(dcpl1, "ext1.data", (off_t)0, (hsize_t)(max_size[0] * sizeof(int)/4))) < 0) diff --git a/test/h5test.c b/test/h5test.c index 0226aa7..32638e6 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -158,47 +158,8 @@ h5_clean_files(const char *base_name[], hid_t fapl) int i; for(i = 0; base_name[i]; i++) { - char filename[1024]; - char temp[2048]; - hid_t driver; - - if(NULL == h5_fixname(base_name[i], fapl, filename, sizeof(filename))) - continue; - - driver = H5Pget_driver(fapl); - - if(driver == H5FD_FAMILY) { - int j; - - for(j = 0; /*void*/; j++) { - HDsnprintf(temp, sizeof temp, filename, j); - - if(HDaccess(temp, F_OK) < 0) - break; - - HDremove(temp); - } /* end for */ - } else if(driver == H5FD_CORE) { - hbool_t backing; /* Whether the core file has backing store */ - - H5Pget_fapl_core(fapl, NULL, &backing); - - /* If the file was stored to disk with bacing store, remove it */ - if(backing) - HDremove(filename); - } else if (driver == H5FD_MULTI) { - H5FD_mem_t mt; - - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { - HDsnprintf(temp, sizeof temp, "%s-%c.h5", filename, multi_letters[mt]); - HDremove(temp); /*don't care if it fails*/ - } /* end for */ - } else { - HDremove(filename); - } - } /* end for */ + h5_delete_test_file(base_name[i], fapl); + } /* Close the FAPL used to access the file */ H5Pclose(fapl); @@ -266,10 +227,10 @@ h5_delete_test_file(const char *base_name, hid_t fapl) for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) { HDsnprintf(sub_filename, sizeof(sub_filename), "%s-%c.h5", filename, multi_letters[mt]); HDremove(sub_filename); - } /* end for */ + } } else { HDremove(filename); - } /* end if */ + } /* end driver selection tree */ return; } /* end h5_delete_test_file() */ @@ -652,7 +613,7 @@ h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, printf("*** Hint ***\n" "You can use environment variable HDF5_PARAPREFIX to " "run parallel test files in a\n" - "different directory or to add file type prefix. E.g.,\n" + "different directory or to add file type prefix. e.g.,\n" " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" " export HDF5_PARAPREFIX\n" "*** End of Hint ***\n"); diff --git a/test/links.c b/test/links.c index b10d0ad..520f784 100644 --- a/test/links.c +++ b/test/links.c @@ -315,6 +315,8 @@ typedef struct { const obj_visit_t *info; /* Pointer to the object visit structure to use */ } ovisit_ud_t; +static hid_t dcpl_g; /* for [un]minimized dataset object headers */ + /*------------------------------------------------------------------------- @@ -377,7 +379,7 @@ mklinks(hid_t fapl, hbool_t new_format) if(H5Gclose(grp) < 0) TEST_ERROR /* Create a dataset */ - if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((d1 = H5Dcreate2(file, "d1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(d1) < 0) TEST_ERROR /* Create a hard link */ @@ -451,8 +453,8 @@ new_links(hid_t fapl, hbool_t new_format) if((grp2_b = H5Gcreate2(file_b, "grp2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR /* Create datasets */ - if((dset1 = H5Dcreate2(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if((dset2 = H5Dcreate2(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset1 = H5Dcreate2(file_a, "dataset1", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset2 = H5Dcreate2(grp1_a, "dataset2", H5T_NATIVE_INT, scalar, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR /* Create links within a file. Both of source and destination use * H5L_SAME_LOC. Both hard and soft links should fail. */ @@ -545,7 +547,7 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Oget_info_by_name2(file, "grp1/hard", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); - printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { @@ -580,7 +582,7 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Oget_info_by_name2(file, "grp1/soft", &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5O_TYPE_DATASET != oinfo2.type) { H5_FAILED(); - printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } /* end if */ if(H5F_addr_ne(oinfo1.addr, oinfo2.addr)) { @@ -609,12 +611,12 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Lget_info(file, "grp1/dangle", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5L_TYPE_SOFT != linfo2.type) { H5_FAILED(); - printf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); + HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/dangle", linkval, sizeof linkval, H5P_DEFAULT) < 0) { H5_FAILED(); - printf(" %d: Can't retrieve link value\n", __LINE__); + HDprintf(" %d: Can't retrieve link value\n", __LINE__); TEST_ERROR } /* end if */ if(HDstrcmp(linkval, "foobar")) { @@ -636,12 +638,12 @@ cklinks(hid_t fapl, hbool_t new_format) if(H5Lget_info(file, "grp1/recursive", &linfo2, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if(H5L_TYPE_SOFT != linfo2.type) { H5_FAILED(); - printf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); + HDprintf(" %d: Unexpected object type should have been a symbolic link\n", __LINE__); TEST_ERROR } /* end if */ if(H5Lget_val(file, "grp1/recursive", linkval, sizeof linkval, H5P_DEFAULT) < 0) { H5_FAILED(); - printf(" %d: Can't retrieve link value\n", __LINE__); + HDprintf(" %d: Can't retrieve link value\n", __LINE__); TEST_ERROR } /* end if */ if(HDstrcmp(linkval, "/grp1/recursive")) { @@ -706,7 +708,7 @@ ck_new_links(hid_t fapl, hbool_t new_format) /* Check hard links */ if(H5O_TYPE_DATASET != oi_hard1.type || H5O_TYPE_DATASET != oi_hard2.type) { H5_FAILED(); - printf(" %d: Unexpected object type should have been a dataset\n", __LINE__); + HDprintf(" %d: Unexpected object type should have been a dataset\n", __LINE__); TEST_ERROR } if(H5F_addr_ne(oi_dset.addr, oi_hard1.addr) || H5F_addr_ne(oi_dset.addr, oi_hard2.addr)) { @@ -1014,7 +1016,7 @@ test_lcpl(hid_t fapl, hbool_t new_format) if((space_id=H5Screate_simple(2 ,dims, NULL)) < 0) TEST_ERROR /* Create a dataset using the default LCPL */ - if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset_id = H5Dcreate2(file_id, "/dataset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(dset_id) < 0) TEST_ERROR /* Check that its character encoding is the default */ @@ -1043,7 +1045,7 @@ test_lcpl(hid_t fapl, hbool_t new_format) if(linfo.cset != H5T_CSET_UTF8) TEST_ERROR /* Create a dataset using the new LCPL */ - if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((dset_id = H5Dcreate2(file_id, "/dataset2", H5T_NATIVE_INT, space_id, lcpl_id, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(dset_id) < 0) TEST_ERROR /* Check that its character encoding is UTF-8 */ @@ -2602,7 +2604,7 @@ external_link_toomany(hid_t fapl, hbool_t new_format) } H5E_END_TRY; if (gid >= 0) { H5_FAILED(); - printf("%d: Should have failed for sequence of too many nested links.", __LINE__); + HDprintf("%d: Should have failed for sequence of too many nested links.", __LINE__); goto error; } @@ -3758,7 +3760,11 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) if((space = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR /* Create dataset creation property list */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) TEST_ERROR; + if (dcpl_g == H5P_DEFAULT) + dcpl = H5Pcreate(H5P_DATASET_CREATE); + else + dcpl = H5Pcopy(dcpl_g); + if (0 > dcpl) TEST_ERROR; if(H5Pset_alloc_time(dcpl, H5D_ALLOC_TIME_LATE) < 0) TEST_ERROR; /* create "Dataset" in group "A" of target file */ @@ -6100,7 +6106,7 @@ external_link_closing(hid_t fapl, hbool_t new_format) /* Test creating each kind of object */ if((gid = H5Gcreate2(fid1, "elink/elink/elink/group1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Tcommit2(fid1, "elink/elink/elink/type1", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR - if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((did = H5Dcreate2(fid1, "elink/elink/elink/dataset1", tid2, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR /* Close objects */ if(H5Gclose(gid) < 0) TEST_ERROR @@ -7298,7 +7304,7 @@ external_open_twice(hid_t fapl, hbool_t new_format) if((space = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR if((oid1 = H5Dcreate2(fid2, "dset", H5T_NATIVE_INT, space, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT)) < 0) + dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(oid1) < 0) TEST_ERROR @@ -7514,8 +7520,11 @@ external_link_with_committed_datatype(hid_t fapl, hbool_t new_format) if((sid2 = H5Screate_simple(2, dims, NULL)) < 0) FAIL_STACK_ERROR - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - FAIL_STACK_ERROR + if (dcpl_g == H5P_DEFAULT) + dcpl = H5Pcreate(H5P_DATASET_CREATE); + else + dcpl = H5Pcopy(dcpl_g); + if (0 > dcpl) FAIL_STACK_ERROR if(H5Pset_chunk(dcpl, 2, chunks) < 0) FAIL_STACK_ERROR @@ -8814,6 +8823,12 @@ ud_link_errors(hid_t fapl, hbool_t new_format) TEST_ERROR } H5E_END_TRY + /* Try to create a link with H5Lcreate_ud that has a NULL udata pointer, but a non-zero udata_size value */ + H5E_BEGIN_TRY { + if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, NULL, 1, H5P_DEFAULT, H5P_DEFAULT) >= 0) + TEST_ERROR + } H5E_END_TRY; + /* Create a user-defined link to the group. */ strcpy(group_name, "/group"); if(H5Lcreate_ud(fid, "/ud_link", (H5L_type_t)UD_CBFAIL_TYPE, &group_name, HDstrlen(group_name) + 1, H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -9058,7 +9073,7 @@ lapl_nlinks(hid_t fapl, hbool_t new_format) dims[0] = 2; dims[1] = 2; if((sid = H5Screate_simple(2, dims, NULL)) < 0) TEST_ERROR - if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((did = H5Dcreate2(gid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR /* Close group */ @@ -9170,7 +9185,7 @@ linkinfo(hid_t fapl, hbool_t new_format) if(H5Lcreate_soft("group", fid, "softlink", H5P_DEFAULT, H5P_DEFAULT) < 0) FAIL_STACK_ERROR if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((did = H5Dcreate2(fid, "dataset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Lcreate_ud(fid, "ud_link", (H5L_type_t)UD_PLIST_TYPE, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR if(H5Lcreate_external("file_name", "obj_path", fid, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR @@ -9335,13 +9350,13 @@ build_visit_file(hid_t fapl) /* Create dataset in each group */ if((sid = H5Screate(H5S_SCALAR)) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, "/Dataset_zero", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((did = H5Dcreate2(fid, "/Dataset_zero", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, "/Group1/Dataset_one", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((did = H5Dcreate2(fid, "/Group1/Dataset_one", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR - if((did = H5Dcreate2(fid, "/Group1/Group2/Dataset_two", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((did = H5Dcreate2(fid, "/Group1/Group2/Dataset_two", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT)) < 0) TEST_ERROR if(H5Dclose(did) < 0) TEST_ERROR if(H5Sclose(sid) < 0) TEST_ERROR @@ -14890,6 +14905,7 @@ main(void) hid_t fapl, fapl2; /* File access property lists */ int nerrors = 0; unsigned new_format; /* Whether to use the new format or not */ + unsigned minimize_dset_oh; unsigned efc; /* Whether to use the external file cache */ const char *env_h5_drvr; /* File Driver value from environment */ @@ -14900,165 +14916,187 @@ main(void) h5_reset(); fapl = h5_fileaccess(); - /* Copy the file access property list */ + /* fapl2 uses "latest version bounds" */ if((fapl2 = H5Pcopy(fapl)) < 0) TEST_ERROR - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ if(H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR - /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t my_fapl; + for (minimize_dset_oh = 0; minimize_dset_oh <= 1; minimize_dset_oh++) { + if (minimize_dset_oh) { + HDprintf("\n-Testing with minimzed dataset object headers-\n"); + dcpl_g = H5Pcreate(H5P_DATASET_CREATE); + if (0 > dcpl_g) TEST_ERROR + } else { + HDprintf("\n-Testing with unminimzed dataset object headers-\n"); + dcpl_g = H5P_DEFAULT; + } - /* Check for FAPL to use */ - if(new_format) - my_fapl = fapl2; - else - my_fapl = fapl; - - /* General tests... (on both old & new format groups */ - nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0; - - /* Test new H5L link creation routine */ - nerrors += test_lcpl(my_fapl, new_format); - nerrors += test_move(my_fapl, new_format); - nerrors += test_copy(my_fapl, new_format); - nerrors += test_move_preserves(my_fapl, new_format); + for(new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl; + + /* Check for FAPL to use */ + if(new_format) { + my_fapl = fapl2; + HDprintf("\n--Testing with 'new format'--\n"); + } else { + my_fapl = fapl; + HDprintf("\n--Testing with 'old format'--\n"); + } + + /* always enter tests without external cache */ + if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) + TEST_ERROR + + /* General tests... (on both old & new format groups */ + nerrors += mklinks(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += cklinks(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += new_links(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += ck_new_links(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += long_links(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += toomany(my_fapl, new_format) < 0 ? 1 : 0; + + /* Test new H5L link creation routine */ + nerrors += test_lcpl(my_fapl, new_format); + nerrors += test_move(my_fapl, new_format); + nerrors += test_copy(my_fapl, new_format); + nerrors += test_move_preserves(my_fapl, new_format); #ifndef H5_NO_DEPRECATED_SYMBOLS - nerrors += test_deprec(my_fapl, new_format); + nerrors += test_deprec(my_fapl, new_format); #endif /* H5_NO_DEPRECATED_SYMBOLS */ - /* tests for external link */ - /* Test external file cache first, so it sees the default efc setting on - * the fapl */ - nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0; - - /* This test cannot run with the EFC because it assumes that an - * intermediate file is not held open */ - nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0; - - /* This test cannot run with the EFC because the EFC cannot currently - * reopen a cached file with a different intent */ - nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; - - /* Try external link tests both with and without the external file cache - */ - for(efc = FALSE; efc <= TRUE; efc++) { - if(efc) { - if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) - TEST_ERROR - printf("\n---Testing with external file cache---\n"); - } /* end if */ - else { - if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) - TEST_ERROR - printf("\n---Testing without external file cache---\n"); - } /* end else */ + /* tests for external link */ + /* Test external file cache first, so it sees the default efc setting on + * the fapl */ + nerrors += external_file_cache(my_fapl, new_format) < 0 ? 1 : 0; + + /* This test cannot run with the EFC because it assumes that an + * intermediate file is not held open */ + nerrors += external_link_mult(my_fapl, new_format) < 0 ? 1 : 0; + + /* This test cannot run with the EFC because the EFC cannot currently + * reopen a cached file with a different intent */ + nerrors += external_set_elink_acc_flags(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; + + /* Try external link tests both with and without the external file cache + */ + for(efc = FALSE; efc <= TRUE; efc++) { + if(efc) { + if(H5Pset_elink_file_cache_size(my_fapl, 8) < 0) + TEST_ERROR + HDprintf("\n---Testing with external file cache---\n"); + } /* end if */ + else { + if(H5Pset_elink_file_cache_size(my_fapl, 0) < 0) + TEST_ERROR + HDprintf("\n---Testing without external file cache---\n"); + } /* end else */ - nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_endian(new_format) < 0 ? 1 : 0; - nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0; - - nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0; - nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_root(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_path(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_self(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_pingpong(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_toomany(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_dangling(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_recursive(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_query(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_unlink_compact(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_unlink_dense(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_move(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_ride(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_closing(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_endian(new_format) < 0 ? 1 : 0; + nerrors += external_link_strong(my_fapl, new_format) < 0 ? 1 : 0; + + nerrors += external_link_prefix(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abs_mainpath(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_rel_mainpath(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_cwd(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abstar(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_abstar_cur(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_reltar(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_chdir(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_set_elink_fapl1(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_set_elink_fapl2(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_set_elink_fapl3(new_format) < 0 ? 1 : 0; + nerrors += external_set_elink_cb(my_fapl, new_format) < 0 ? 1 : 0; #ifdef H5_HAVE_WINDOW_PATH - nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win1(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win2(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win3(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win4(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win5(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win6(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win7(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win8(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_win9(my_fapl, new_format) < 0 ? 1 : 0; #endif - nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; - } /* end for */ - - /* These tests assume that external links are a form of UD links, - * so assume that everything that passed for external links - * above has already been tested for UD links. - */ - if(new_format == TRUE) { - nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */ - nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */ - } /* end if */ - nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += lapl_nlinks(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += linkinfo(my_fapl, new_format) < 0 ? 1 : 0; - - /* Misc. extra tests, useful for both new & old format files */ - nerrors += link_visit(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += obj_visit_stop(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += link_filters(my_fapl, new_format) < 0 ? 1 : 0; - nerrors += obj_exists(my_fapl, new_format) < 0 ? 1 : 0; - - /* Keep this test last, it's testing files that are used above */ - /* do not do this for files used by external link tests */ - nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0; - } /* end for */ + nerrors += external_symlink(env_h5_drvr, my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_copy_invalid_object(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_dont_fail_to_source(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_open_twice(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += external_link_with_committed_datatype(my_fapl, new_format) < 0 ? 1 : 0; + } /* with/without external file cache */ + + /* These tests assume that external links are a form of UD links, + * so assume that everything that passed for external links + * above has already been tested for UD links. + */ + if(new_format == TRUE) { + nerrors += ud_hard_links(fapl2) < 0 ? 1 : 0; /* requires new format groups */ + nerrors += ud_link_reregister(fapl2) < 0 ? 1 : 0; /* requires new format groups */ + } /* end if */ + nerrors += ud_callbacks(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += ud_link_errors(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += lapl_udata(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += lapl_nlinks(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += linkinfo(my_fapl, new_format) < 0 ? 1 : 0; + + /* Misc. extra tests, useful for both new & old format files */ + nerrors += link_visit(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += link_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += obj_visit(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += obj_visit_by_name(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += obj_visit_stop(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += link_filters(my_fapl, new_format) < 0 ? 1 : 0; + nerrors += obj_exists(my_fapl, new_format) < 0 ? 1 : 0; + + /* Keep this test last, it's testing files that are used above */ + /* do not do this for files used by external link tests */ + nerrors += check_all_closed(my_fapl, new_format, EXTSTOP) < 0 ? 1 : 0; + } /* new/old format */ + + /* New group revision feature tests */ + nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0; - /* New group revision feature tests */ - nerrors += corder_create_empty(fapl2) < 0 ? 1 : 0; /* XXX: when creation order indexing is fully working, go back and add checks * to these tests to make certain that the creation order values are * correct. */ - nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0; - nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0; - nerrors += corder_transition(fapl2) < 0 ? 1 : 0; - nerrors += corder_delete(fapl2) < 0 ? 1 : 0; - nerrors += link_info_by_idx(fapl2) < 0 ? 1 : 0; - nerrors += delete_by_idx(fapl2) < 0 ? 1 : 0; - nerrors += link_iterate(fapl2) < 0 ? 1 : 0; - nerrors += open_by_idx(fapl2) < 0 ? 1 : 0; - nerrors += object_info(fapl2) < 0 ? 1 : 0; - nerrors += group_info(fapl2) < 0 ? 1 : 0; - nerrors += timestamps(fapl2) < 0 ? 1 : 0; - - /* Test new API calls on old-style groups */ - nerrors += link_info_by_idx_old(fapl) < 0 ? 1 : 0; - nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0; - nerrors += link_iterate_old(fapl) < 0 ? 1 : 0; - nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0; - nerrors += object_info_old(fapl) < 0 ? 1 : 0; - nerrors += group_info_old(fapl) < 0 ? 1 : 0; + nerrors += corder_create_compact(fapl2) < 0 ? 1 : 0; + nerrors += corder_create_dense(fapl2) < 0 ? 1 : 0; + nerrors += corder_transition(fapl2) < 0 ? 1 : 0; + nerrors += corder_delete(fapl2) < 0 ? 1 : 0; + nerrors += link_info_by_idx(fapl2) < 0 ? 1 : 0; + nerrors += delete_by_idx(fapl2) < 0 ? 1 : 0; + nerrors += link_iterate(fapl2) < 0 ? 1 : 0; + nerrors += open_by_idx(fapl2) < 0 ? 1 : 0; + nerrors += object_info(fapl2) < 0 ? 1 : 0; + nerrors += group_info(fapl2) < 0 ? 1 : 0; + nerrors += timestamps(fapl2) < 0 ? 1 : 0; + + /* Test new API calls on old-style groups */ + nerrors += link_info_by_idx_old(fapl) < 0 ? 1 : 0; + nerrors += delete_by_idx_old(fapl) < 0 ? 1 : 0; + nerrors += link_iterate_old(fapl) < 0 ? 1 : 0; + nerrors += open_by_idx_old(fapl) < 0 ? 1 : 0; + nerrors += object_info_old(fapl) < 0 ? 1 : 0; + nerrors += group_info_old(fapl) < 0 ? 1 : 0; + + if (minimize_dset_oh) { + if (H5Pclose(dcpl_g) < 0) + TEST_ERROR; + dcpl_g = -1; + } + } /* [un]minimized dataset object headers */ /* Close 2nd FAPL */ H5Pclose(fapl2); @@ -15075,11 +15113,11 @@ main(void) /* Results */ if(nerrors) { - printf("***** %d LINK TEST%s FAILED! *****\n", + HDprintf("***** %d LINK TEST%s FAILED! *****\n", nerrors, 1 == nerrors ? "" : "S"); HDexit(EXIT_FAILURE); } - printf("All link tests passed.\n"); + HDprintf("All link tests passed.\n"); /* clean up symlink created by external link tests */ HDremove(SYMLINK1); diff --git a/test/echo_vol.c b/test/null_vol_connector.c index 7f59832..b62b370 100644 --- a/test/echo_vol.c +++ b/test/null_vol_connector.c @@ -10,19 +10,20 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* - * Purpose: A simple virtual object layer (VOL) plugin that just echoes - * the name of the API call. +/* Purpose: A simple virtual object layer (VOL) connector with almost no + * functionality that is used for testing basic plugin handling + * (registration, etc.). */ #include "H5PLextern.h" -/* The VOL class struct. - */ -static const H5VL_class_t echo_vol_g = { +#include "null_vol_connector.h" + +/* The VOL class struct */ +static const H5VL_class_t null_vol_g = { 0, /* version */ - (H5VL_class_value_t)501, /* value */ - "echo", /* name */ + NULL_VOL_CONNECTOR_VALUE, /* value */ + NULL_VOL_CONNECTOR_NAME, /* name */ 0, /* capability flags */ NULL, /* initialize */ NULL, /* terminate */ @@ -106,22 +107,10 @@ static const H5VL_class_t echo_vol_g = { NULL /* optional */ }; - - /* These two functions are necessary to load this plugin using * the HDF5 library. */ -H5PL_type_t -H5PLget_plugin_type(void) -{ - return H5PL_TYPE_VOL; -} - - -const void* -H5PLget_plugin_info(void) -{ - return &echo_vol_g; -} +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;} +const void *H5PLget_plugin_info(void) {return &null_vol_g;} diff --git a/test/null_vol_connector.h b/test/null_vol_connector.h new file mode 100644 index 0000000..11c8826 --- /dev/null +++ b/test/null_vol_connector.h @@ -0,0 +1,25 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* Purpose: A simple virtual object layer (VOL) connector with almost no + * functionality that is used for testing basic plugin handling + * (registration, etc.). + */ + +#ifndef _null_vol_connector_H +#define _null_vol_connector_H + +#define NULL_VOL_CONNECTOR_VALUE ((H5VL_class_value_t)160) +#define NULL_VOL_CONNECTOR_NAME "null_vol_connector" + +#endif /* _null_vol_connector_H */ + diff --git a/test/ohdr.c b/test/ohdr.c index cca7e7e..57edaf5 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -36,9 +36,16 @@ const char *FILENAME[] = { "ohdr", + "ohdr_min_a", + "ohdr_min_b", NULL }; +/* used for object header size comparison */ +#define EQ 1 +#define LT 2 +#define GT 3 + /* The tbogus.h5 is generated from gen_bogus.c in HDF5 'test' directory. * To get this data file, define H5O_ENABLE_BOGUS in src/H5Oprivate, rebuild * the library and simply compile gen_bogus.c with that HDF5 library and run it. @@ -733,6 +740,885 @@ error: return FAIL; } /* test_unknown() */ +/* + * Set an attribute with the given information. + * If the out parameter `attr_id` is negative, a new attribute will be + * created with the given information. Else, it will attempt to update the + * attribute with the new value. + * + * `dataspace_id` ignored if `attribute_id` >= 0 + */ +static herr_t +put_attribute(hid_t loc_id, const char *attrname, const void *attrvalue, hid_t datatype_id, hid_t dataspace_id, hid_t *attribute_id) +{ + if((*attribute_id) < 0) { + hid_t id = -1; + id = H5Acreate2(loc_id, attrname, datatype_id, dataspace_id, H5P_DEFAULT, H5P_DEFAULT); + if(id < 0) + return FAIL; + *attribute_id = id; + } + return H5Awrite(*attribute_id, datatype_id, attrvalue); +} /* put_attribute */ + +/* + * Count the number of attributes attached to an object. + * Returns negative in event of error. + */ +static int +count_attributes(hid_t dset_id) +{ + H5O_info_t info; + + if(H5Oget_info2(dset_id, &info, H5O_INFO_ALL) < 0) + return -1; + else + return (int)info.num_attrs; /* should never exceed int bounds */ +} /* count_attributes */ + +/* + * Get the total space used by the object header. + * Used by oh_compare() + * On success, stores size in `size_out` pointer. + */ +static herr_t +_oh_getsize(hid_t did, hsize_t *size_out) +{ + H5O_info_t info; + if(FAIL == H5Oget_info2(did, &info, H5O_INFO_HDR)) + return FAIL; + *size_out = info.hdr.space.total; + return SUCCEED; +} /* _oh_getsize */ + +/* + * Compare the TOTAL space used by datasets' object headers. + * Returns negative value if an error occurred, + * else positive #defined indicator value EQ, LT, GT. + */ +static int +oh_compare(hid_t did1, hid_t did2) +{ + hsize_t space1 = 0; + hsize_t space2 = 0; + + if(FAIL == _oh_getsize(did1, &space1)) + return -1; + if(FAIL == _oh_getsize(did2, &space2)) + return -2; + + if(space1 < space2) + return LT; + else if(space1 > space2) + return GT; + else + return EQ; +} /* oh_compare() */ + +/* + * Demonstrate attribute addition to datasets. + * Conduct additions side-by-side with a standard datataset and one with + * minimized dataset object headers. + */ +static herr_t +test_minimized_dset_ohdr_attribute_addition(hid_t fapl_id) +{ + hsize_t array_10[1] = {10}; /* dataspace extent */ + char buffer[10] = ""; /* to inspect string attribute */ + int a_out = 0; + char filename[512] = ""; + hid_t int_type_id = -1; + hid_t char_type_id = -1; + hid_t dcpl_id = -1; + hid_t dspace_id = -1; + hid_t dspace_scalar_id = -1; + hid_t dset_id = -1; + hid_t mindset_id = -1; + hid_t attr_1_id = -1; + hid_t attr_1a_id = -1; + hid_t attr_2_id = -1; + hid_t attr_2a_id = -1; + hid_t attr_3_id = -1; + hid_t attr_3a_id = -1; + hid_t file_id = -1; + herr_t ret; + int count = 0; + + TESTING("minimized dset object headers attribute additions") + + /********* + * SETUP * + *********/ + + if(h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dspace_id = H5Screate_simple(1, array_10, NULL); + if(dspace_id < 0) TEST_ERROR + + dspace_scalar_id = H5Screate(H5S_SCALAR); + if(dspace_scalar_id < 0) TEST_ERROR + + char_type_id = H5Tcopy(H5T_NATIVE_CHAR); + if(char_type_id < 0) TEST_ERROR + + int_type_id = H5Tcopy(H5T_NATIVE_INT); + if(int_type_id < 0) TEST_ERROR + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_id < 0) TEST_ERROR + + ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); + if(ret < 0) TEST_ERROR + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + H5E_BEGIN_TRY { + count = count_attributes(dset_id); + } H5E_END_TRY; + if(count != -1) TEST_ERROR + + dset_id = H5Dcreate2(file_id, "dataset", int_type_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_id < 0) TEST_ERROR + + mindset_id = H5Dcreate2(file_id, "mindataset", int_type_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(mindset_id < 0) TEST_ERROR + + /******************** + * TEST/DEMONSTRATE * + ********************/ + + /* ------------------- + * no attributes added + */ + + count = count_attributes(dset_id); + if(count != 0) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 0) TEST_ERROR + + /* ----------------- + * add one attribute + */ + ret = put_attribute(dset_id, "PURPOSE", "DEMO", char_type_id, dspace_id, &attr_1_id); + if(ret < 0) TEST_ERROR + + ret = put_attribute(mindset_id, "PURPOSE", "DEMO", char_type_id, dspace_id, &attr_1a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 1) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 1) TEST_ERROR + + ret = H5Aread(attr_1_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("DEMO", buffer)) TEST_ERROR + + ret = H5Aread(attr_1a_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("DEMO", buffer)) TEST_ERROR + + /* ----------------- + * modify one attribute + */ + + ret = put_attribute(dset_id, "PURPOSE", "REWRITE", char_type_id, -1, &attr_1_id); + if(ret < 0) TEST_ERROR + + ret = put_attribute(mindset_id, "PURPOSE", "REWRITE", char_type_id, -1, &attr_1a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 1) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 1) TEST_ERROR + + ret = H5Aread(attr_1_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("REWRITE", buffer)) TEST_ERROR + + ret = H5Aread(attr_1a_id, char_type_id, buffer); + if(ret < 0) TEST_ERROR + if(HDstrcmp("REWRITE", buffer)) TEST_ERROR + + /* ----------------- + * add second attribute + */ + + a_out = 5; + ret = put_attribute(dset_id, "RANK", &a_out, int_type_id, dspace_scalar_id, &attr_2_id); + if(ret < 0) TEST_ERROR + + a_out = 3; + ret = put_attribute(mindset_id, "RANK", &a_out, int_type_id, dspace_scalar_id, &attr_2a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 2) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 2) TEST_ERROR + + ret = H5Aread(attr_2_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != 5) TEST_ERROR + + ret = H5Aread(attr_2a_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != 3) TEST_ERROR + + /* ----------------- + * add third attribute + */ + + a_out = -86; + ret = put_attribute(dset_id, "FLAVOR", &a_out, int_type_id, dspace_scalar_id, &attr_3_id); + if(ret < 0) TEST_ERROR + + a_out = 2185; + ret = put_attribute(mindset_id, "FLAVOR", &a_out, int_type_id, dspace_scalar_id, &attr_3a_id); + if(ret < 0) TEST_ERROR + + count = count_attributes(dset_id); + if(count != 3) TEST_ERROR + count = count_attributes(mindset_id); + if(count != 3) TEST_ERROR + + ret = H5Aread(attr_3_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != -86) TEST_ERROR + + ret = H5Aread(attr_3a_id, int_type_id, &a_out); + if(ret < 0) TEST_ERROR + if(a_out != 2185) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Tclose(int_type_id) < 0) TEST_ERROR + if(H5Tclose(char_type_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_id) < 0) TEST_ERROR + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Dclose(dset_id) < 0) TEST_ERROR + if(H5Dclose(mindset_id) < 0) TEST_ERROR + if(H5Aclose(attr_1_id) < 0) TEST_ERROR + if(H5Aclose(attr_1a_id) < 0) TEST_ERROR + if(H5Aclose(attr_2_id) < 0) TEST_ERROR + if(H5Aclose(attr_2a_id) < 0) TEST_ERROR + if(H5Aclose(attr_3_id) < 0) TEST_ERROR + if(H5Aclose(attr_3a_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED() + return SUCCEED; + +error : + H5E_BEGIN_TRY { + (void)H5Tclose(int_type_id); + (void)H5Tclose(char_type_id); + (void)H5Pclose(dcpl_id); + (void)H5Sclose(dspace_id); + (void)H5Dclose(dset_id); + (void)H5Dclose(mindset_id); + (void)H5Aclose(attr_1_id); + (void)H5Aclose(attr_1a_id); + (void)H5Aclose(attr_2_id); + (void)H5Aclose(attr_2a_id); + (void)H5Aclose(attr_3_id); + (void)H5Aclose(attr_3a_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_attribute_addition */ + +/* + * Compare header sizes against when headers have been minimized. + * Repeats tests with headers "compact" and normal. + */ +static herr_t +test_minimized_dset_ohdr_size_comparisons(hid_t fapl_id) +{ + hsize_t array_10[1] = {10}; /* dataspace extents */ + unsigned compact = 0; + + /* IDs that are file-agnostic */ + hid_t dspace_id = -1; + hid_t int_type_id = -1; + hid_t dcpl_minimize = -1; + hid_t dcpl_dontmin = -1; + hid_t dcpl_default = -1; + + /* IDs for non-minimized file open */ + hid_t file_f_id = -1; /* lower 'f' for standard file setting */ + hid_t dset_f_x_id = -1; /* 'x' for default */ + hid_t dset_f_N_id = -1; /* 'N' for explcit non-minimized dset */ + hid_t dset_f_Y_id = -1; /* 'Y' for minimized dset */ + + /* IDs for minimized file open */ + hid_t file_F_id = -1; /* upper 'F' for minimized file setting */ + hid_t dset_F_x_id = -1; /* 'x' for default */ + hid_t dset_F_N_id = -1; /* 'N' for explcit non-minimized dset */ + hid_t dset_F_Y_id = -1; /* 'Y' for minimized dset */ + + char filename_a[512] = ""; + char filename_b[512] = ""; + + herr_t ret; + + /* dataset suffixes: + * | default | minimize | don't minimize (dcpl-set) + * ---------------+---------+----------+--------------- + * file-default | f_x | f_Y | f_N + * ---------------+---------+----------+--------------- + * file-minimized | F_x | F_Y | F_N + */ + + TESTING("minimized dset object headers size comparisons"); + + /********* + * SETUP * + *********/ + + if(h5_fixname(FILENAME[1], H5P_DEFAULT, filename_a, sizeof(filename_a)) == NULL) + TEST_ERROR + + if(h5_fixname(FILENAME[2], H5P_DEFAULT, filename_b, sizeof(filename_b)) == NULL) + TEST_ERROR + + for (compact = 0; compact < 2; compact++) { /* 0 or 1 */ + dcpl_default = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_default < 0) TEST_ERROR + + dcpl_minimize = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_minimize < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_minimize, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_dontmin = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_dontmin < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_dontmin, FALSE); + if(ret < 0) TEST_ERROR + + if(compact) { + HDprintf("...compact "); + ret = H5Pset_layout(dcpl_default, H5D_COMPACT); + if(ret < 0) TEST_ERROR + ret = H5Pset_layout(dcpl_minimize, H5D_COMPACT); + if(ret < 0) TEST_ERROR + ret = H5Pset_layout(dcpl_dontmin, H5D_COMPACT); + if(ret < 0) TEST_ERROR + } else + HDprintf("...not compact "); + + dspace_id = H5Screate_simple(1, array_10, NULL); + if(dspace_id < 0) TEST_ERROR + + int_type_id = H5Tcopy(H5T_NATIVE_INT); + if(int_type_id < 0) TEST_ERROR + + file_f_id = H5Fcreate(filename_a, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_f_id < 0) TEST_ERROR + + dset_f_x_id = H5Dcreate2(file_f_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); + if(dset_f_x_id < 0) TEST_ERROR + + dset_f_N_id = H5Dcreate2(file_f_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if(dset_f_N_id < 0) TEST_ERROR + + dset_f_Y_id = H5Dcreate2(file_f_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if(dset_f_x_id < 0) TEST_ERROR + + file_F_id = H5Fcreate(filename_b, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_F_id < 0) TEST_ERROR + ret = H5Fset_dset_no_attrs_hint(file_F_id, TRUE); + if(ret < 0) TEST_ERROR + + dset_F_x_id = H5Dcreate2(file_F_id, "default", int_type_id, dspace_id, H5P_DEFAULT, dcpl_default, H5P_DEFAULT); + if(dset_F_x_id < 0) TEST_ERROR + + dset_F_N_id = H5Dcreate2(file_F_id, "dsetNOT", int_type_id, dspace_id, H5P_DEFAULT, dcpl_dontmin, H5P_DEFAULT); + if(dset_F_N_id < 0) TEST_ERROR + + dset_F_Y_id = H5Dcreate2(file_F_id, "dsetMIN", int_type_id, dspace_id, H5P_DEFAULT, dcpl_minimize, H5P_DEFAULT); + if(dset_F_Y_id < 0) TEST_ERROR + + /********* + * TESTS * + *********/ + + if(oh_compare(dset_f_x_id, dset_f_x_id) != EQ) TEST_ERROR /* identity */ + + if(oh_compare(dset_f_x_id, dset_f_N_id) != EQ) TEST_ERROR + if(oh_compare(dset_f_x_id, dset_f_Y_id) != GT) TEST_ERROR + if(oh_compare(dset_f_N_id, dset_f_Y_id) != GT) TEST_ERROR + + if(oh_compare(dset_F_x_id, dset_F_N_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_x_id, dset_F_Y_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_N_id, dset_F_Y_id) != EQ) TEST_ERROR + + if(oh_compare(dset_F_x_id, dset_f_Y_id) != EQ) TEST_ERROR + if(oh_compare(dset_F_x_id, dset_f_x_id) != LT) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(int_type_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_default) < 0) TEST_ERROR + if(H5Pclose(dcpl_minimize) < 0) TEST_ERROR + if(H5Pclose(dcpl_dontmin) < 0) TEST_ERROR + + if(H5Fclose(file_f_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_x_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_N_id) < 0) TEST_ERROR + if(H5Dclose(dset_f_Y_id) < 0) TEST_ERROR + + if(H5Fclose(file_F_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_x_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_N_id) < 0) TEST_ERROR + if(H5Dclose(dset_F_Y_id) < 0) TEST_ERROR + + } /* compact and non-compact */ + + PASSED() + return SUCCEED; + +error : + H5E_BEGIN_TRY { + (void)H5Pclose(dcpl_default); + (void)H5Pclose(dcpl_minimize); + (void)H5Pclose(dcpl_dontmin); + (void)H5Sclose(dspace_id); + (void)H5Tclose(int_type_id); + + (void)H5Fclose(file_f_id); + (void)H5Dclose(dset_f_x_id); + (void)H5Dclose(dset_f_N_id); + (void)H5Dclose(dset_f_Y_id); + + (void)H5Fclose(file_F_id); + (void)H5Dclose(dset_F_x_id); + (void)H5Dclose(dset_F_N_id); + (void)H5Dclose(dset_F_Y_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_size_comparisons */ + +/* + * Test minimized dataset object header with filter/pipeline message + */ +static herr_t +test_minimized_dset_ohdr_with_filter(hid_t fapl_id) +{ + char filename[512] = ""; + const hsize_t extents[1] = {1024}; /* extents of dataspace */ + const unsigned filter_values[] = {0}; /* TBD */ + const hsize_t chunk_dim[] = {32}; /* needed for filter */ + const int ndims = 1; + hid_t dspace_id = -1; + hid_t dtype_id = -1; + hid_t dcpl_xZ_id = -1; + hid_t dcpl_mx_id = -1; + hid_t dcpl_mZ_id = -1; + hid_t dset_xx_id = -1; + hid_t dset_xZ_id = -1; + hid_t dset_mx_id = -1; + hid_t dset_mZ_id = -1; + hid_t file_id = -1; + herr_t ret; + + /* dcpl suffixes: + * | default | minimize + * ----------+---------+--------- + * no filter | xx | mx + * ----------+---------+--------- + * filter | xZ | mZ + */ + + TESTING("minimized dset object headers with filter message"); + + /********* + * SETUP * + *********/ + + if(h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mx_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_xZ_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_xZ_id < 0) TEST_ERROR + ret = H5Pset_chunk(dcpl_xZ_id, ndims, chunk_dim); + if(ret < 0) TEST_ERROR + ret = H5Pset_filter(dcpl_xZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if(ret < 0) TEST_ERROR + dcpl_mZ_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mZ_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mZ_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_chunk(dcpl_mZ_id, ndims, chunk_dim); + if(ret < 0) TEST_ERROR + ret = H5Pset_filter( dcpl_mZ_id, H5Z_FILTER_DEFLATE, H5Z_FLAG_OPTIONAL, 0, filter_values); + if(ret < 0) TEST_ERROR + + dspace_id = H5Screate_simple(1, extents, extents); + if(dspace_id < 0) TEST_ERROR + + dtype_id = H5Tcopy(H5T_NATIVE_INT); + if(dtype_id < 0) TEST_ERROR + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_xx_id = H5Dcreate2(file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_xx_id < 0) TEST_ERROR + + dset_mx_id = H5Dcreate2(file_id, "Mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); + if(dset_mx_id < 0) TEST_ERROR + + dset_xZ_id = H5Dcreate2(file_id, "xZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xZ_id, H5P_DEFAULT); + if(dset_xZ_id < 0) TEST_ERROR + + dset_mZ_id = H5Dcreate2(file_id, "MZ", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mZ_id, H5P_DEFAULT); + if(dset_mZ_id < 0) TEST_ERROR + + /********* + * TESTS * + *********/ + + if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR + if(oh_compare(dset_mx_id, dset_xZ_id) != LT) TEST_ERROR + if(oh_compare(dset_mZ_id, dset_mx_id) != GT) TEST_ERROR + if(oh_compare(dset_mZ_id, dset_xZ_id) != LT) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_xZ_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mZ_id) < 0) TEST_ERROR + if(H5Dclose(dset_xx_id) < 0) TEST_ERROR + if(H5Dclose(dset_xZ_id) < 0) TEST_ERROR + if(H5Dclose(dset_mx_id) < 0) TEST_ERROR + if(H5Dclose(dset_mZ_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR + + PASSED() + return SUCCEED; + +error: + H5E_BEGIN_TRY { + (void)H5Sclose(dspace_id); + (void)H5Tclose(dtype_id); + (void)H5Pclose(dcpl_xZ_id); + (void)H5Pclose(dcpl_mx_id); + (void)H5Pclose(dcpl_mZ_id); + (void)H5Dclose(dset_xx_id); + (void)H5Dclose(dset_xZ_id); + (void)H5Dclose(dset_mx_id); + (void)H5Dclose(dset_mZ_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_with_filter */ + +/* + * Test minimized dataset object header and recording modification times. + */ +static herr_t +test_minimized_dset_ohdr_modification_times(hid_t _fapl_id) +{ + /* test-local structure for parameterized testing + */ + struct testcase { + unsigned oh_version; + }; + + char filename[512] = ""; + const hsize_t extents[1] = {128}; /* extents of dataspace */ + hid_t dspace_id = -1; + hid_t dtype_id = -1; + hid_t dcpl_xT_id = -1; /* Track modtime */ + hid_t dcpl_mx_id = -1; /* minimized */ + hid_t dcpl_mT_id = -1; /* minimized, Track */ + hid_t dcpl_mN_id = -1; /* minimized, do Not track */ + hid_t dset_xx_id = -1; + hid_t dset_xT_id = -1; + hid_t dset_mx_id = -1; + hid_t dset_mT_id = -1; + hid_t dset_mN_id = -1; + hid_t file_id = -1; + hid_t fapl_id = -1; + herr_t ret; + + unsigned i = 0; /* for testcase loop */ + unsigned n_cases = 2; /* must match `cases` array size below */ + struct testcase cases[2] = { + { 1, }, /* version 1 object header */ + { 2, }, /* version 2 object header */ + }; + + /* dcpl suffixes: + * | default | minimize + * ------------+---------+--------- + * default | xx | mx + * ------------+---------+--------- + * don't track | xN | mN + * ------------+---------+--------- + * track | xT | mT + */ + + TESTING("minimized dset object headers with modification times"); + + /********* + * SETUP * + *********/ + + if(h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dcpl_mx_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mx_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mx_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_xT_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_xT_id < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_xT_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_mT_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mT_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mT_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_mT_id, TRUE); + if(ret < 0) TEST_ERROR + + dcpl_mN_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_mN_id < 0) TEST_ERROR + ret = H5Pset_dset_no_attrs_hint(dcpl_mN_id, TRUE); + if(ret < 0) TEST_ERROR + ret = H5Pset_obj_track_times(dcpl_mN_id, FALSE); + if(ret < 0) TEST_ERROR + + dspace_id = H5Screate_simple(1, extents, extents); + if(dspace_id < 0) TEST_ERROR + + dtype_id = H5Tcopy(H5T_NATIVE_INT); + if(dtype_id < 0) TEST_ERROR + + for (i = 0; i < n_cases; i++) { + + /* -------------- * + * per-case setup * + * -------------- */ + + fapl_id = H5Pcopy(_fapl_id); + if(fapl_id < 0) TEST_ERROR + + if(cases[i].oh_version > 1) { + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + if(fapl_id < 0) TEST_ERROR + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_V110); + if(ret < 0) TEST_ERROR + } + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_xx_id = H5Dcreate2( file_id, "xx", dtype_id, dspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_xx_id < 0) TEST_ERROR + + dset_mx_id = H5Dcreate2(file_id, "mx", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mx_id, H5P_DEFAULT); + if(dset_mx_id < 0) TEST_ERROR + + dset_xT_id = H5Dcreate2(file_id, "xT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_xT_id, H5P_DEFAULT); + if(dset_xT_id < 0) TEST_ERROR + dset_mT_id = H5Dcreate2(file_id, "mT", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mT_id, H5P_DEFAULT); + if(dset_mT_id < 0) TEST_ERROR + + dset_mN_id = H5Dcreate2(file_id, "mN", dtype_id, dspace_id, H5P_DEFAULT, dcpl_mN_id, H5P_DEFAULT); + if(dset_mN_id < 0) TEST_ERROR + + /* ----- * + * TESTS * + * ----- */ + + /* sanity check */ + if(oh_compare(dset_mx_id, dset_xx_id) != LT) TEST_ERROR + if(oh_compare(dset_mx_id, dset_xT_id) != LT) TEST_ERROR + + if(oh_compare(dset_xx_id, dset_xT_id) != EQ) TEST_ERROR + if(oh_compare(dset_mx_id, dset_mT_id) != EQ) TEST_ERROR + if(oh_compare(dset_mN_id, dset_mT_id) != LT) TEST_ERROR + + if(oh_compare(dset_mT_id, dset_xT_id) != LT) TEST_ERROR + + /* ----------------- * + * per-case teardown * + * ----------------- */ + + if(H5Dclose(dset_xx_id) < 0) TEST_ERROR + if(H5Dclose(dset_xT_id) < 0) TEST_ERROR + if(H5Dclose(dset_mx_id) < 0) TEST_ERROR + if(H5Dclose(dset_mT_id) < 0) TEST_ERROR + if(H5Dclose(dset_mN_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR + if(H5Pclose(fapl_id) < 0) TEST_ERROR + + } /* for each version tested */ + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_xT_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mx_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mT_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_mN_id) < 0) TEST_ERROR + + PASSED() + return SUCCEED; + +error: + H5E_BEGIN_TRY { + (void)H5Sclose(dspace_id); + (void)H5Tclose(dtype_id); + (void)H5Pclose(dcpl_xT_id); + (void)H5Pclose(dcpl_mx_id); + (void)H5Pclose(dcpl_mT_id); + (void)H5Pclose(dcpl_mN_id); + (void)H5Dclose(dset_xx_id); + (void)H5Dclose(dset_xT_id); + (void)H5Dclose(dset_mx_id); + (void)H5Dclose(dset_mT_id); + (void)H5Dclose(dset_mN_id); + (void)H5Fclose(file_id); + (void)H5Pclose(fapl_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_modification_times */ + +/* + * Test minimized dataset object header with a fill value set. + */ +static herr_t +test_minimized_dset_ohdr_fillvalue_backwards_compatability(hid_t _fapl_id) +{ + char filename[512] = ""; + const hsize_t extents[1] = {64}; /* extents of dataspace */ + const int fill[1] = {343}; /* fill value of dataset */ + hid_t file_id = -1; + hid_t dtype_id = -1; + hid_t dspace_id = -1; + hid_t dcpl_id = -1; + hid_t fapl_id = -1; + hid_t dset_0_id = -1; + hid_t dset_1_id = -1; + herr_t ret; + + /********* + * SETUP * + *********/ + + TESTING("minimized dset object headers with fill values and different libver support"); + + if(h5_fixname(FILENAME[1], H5P_DEFAULT, filename, sizeof(filename)) == NULL) + TEST_ERROR + + dspace_id = H5Screate_simple(1, extents, extents); + if(dspace_id < 0) TEST_ERROR + + dtype_id = H5Tcopy(H5T_NATIVE_INT); + if(dtype_id < 0) TEST_ERROR + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + if(dcpl_id < 0) TEST_ERROR + + ret = H5Pset_dset_no_attrs_hint(dcpl_id, TRUE); + if(ret == FAIL) TEST_ERROR; + + ret = H5Pset_fill_value(dcpl_id, dtype_id, fill); + if(ret == FAIL) TEST_ERROR; + + fapl_id = H5Pcopy(_fapl_id); + if(fapl_id < 0) TEST_ERROR + + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST); + if(ret == FAIL) TEST_ERROR; + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_0_id = H5Dcreate2(file_id, "fullrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(dset_0_id < 0) TEST_ERROR + + /* Close file and re-open with different libver bounds. + * Dataset "fullrange" must also be closed for expected reopen behavior. + */ + if(H5Fclose(file_id) < 0) TEST_ERROR; + if(H5Dclose(dset_0_id) < 0) TEST_ERROR + + ret = H5Pset_libver_bounds(fapl_id, H5F_LIBVER_V18, H5F_LIBVER_LATEST); + if(ret == FAIL) TEST_ERROR; + + file_id = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + if(file_id < 0) TEST_ERROR + + dset_1_id = H5Dcreate2(file_id, "upperrange", dtype_id, dspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + if(dset_1_id < 0) TEST_ERROR + + /* re-open "fullrange" dataset + */ + dset_0_id = H5Dopen2(file_id, "fullrange", H5P_DEFAULT); + if(dset_0_id < 0) TEST_ERROR + + /********* + * TESTS * + *********/ + + /* dset not supporting pre-1.08 should be smaller? */ + if(oh_compare(dset_1_id, dset_0_id) != LT) TEST_ERROR + + /************ + * TEARDOWN * + ************/ + + if(H5Sclose(dspace_id) < 0) TEST_ERROR + if(H5Tclose(dtype_id) < 0) TEST_ERROR + if(H5Pclose(dcpl_id) < 0) TEST_ERROR + if(H5Pclose(fapl_id) < 0) TEST_ERROR + if(H5Dclose(dset_0_id) < 0) TEST_ERROR + if(H5Dclose(dset_1_id) < 0) TEST_ERROR + if(H5Fclose(file_id) < 0) TEST_ERROR; + + PASSED() + return SUCCEED; + +error: + H5E_BEGIN_TRY { + (void)H5Sclose(dspace_id); + (void)H5Tclose(dtype_id); + (void)H5Pclose(dcpl_id); + (void)H5Pclose(fapl_id); + (void)H5Dclose(dset_0_id); + (void)H5Dclose(dset_1_id); + (void)H5Fclose(file_id); + } H5E_END_TRY; + return FAIL; +} /* test_minimized_dset_ohdr_fillvalue_backwards_compatability */ + #define STR_EARLIEST "earliest" #define STR_V18 "v18" #define STR_LATEST "latest" @@ -1030,6 +1916,21 @@ main(void) if(test_ohdr_cache(filename, fapl) < 0) TEST_ERROR + if(test_minimized_dset_ohdr_attribute_addition(fapl) < 0) + TEST_ERROR + + if(test_minimized_dset_ohdr_size_comparisons(fapl) < 0) + TEST_ERROR + + if(test_minimized_dset_ohdr_with_filter(fapl) < 0) + TEST_ERROR + + if(test_minimized_dset_ohdr_modification_times(fapl) < 0) + TEST_ERROR + + if(test_minimized_dset_ohdr_fillvalue_backwards_compatability(fapl) < 0) + TEST_ERROR + } /* high */ } /* low */ diff --git a/test/tattr.c b/test/tattr.c index 63a0580..c1167c6 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -146,6 +146,10 @@ float attr_data5=-5.123F; /* Test data for 5th attribute */ /* Used by test_attr_info_null_info_pointer() */ #define GET_INFO_NULL_POINTER_ATTR_NAME "NullInfoPointerAttr" +/* Used by test_attr_rename_invalid_name() */ +#define INVALID_RENAME_TEST_ATTR_NAME "InvalidRenameTestAttr" +#define INVALID_RENAME_TEST_NEW_ATTR_NAME "InvalidRenameTestNewAttr" + /* Attribute iteration struct */ typedef struct { @@ -161,6 +165,12 @@ typedef struct { static herr_t attr_op1(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *op_data); +/* Global dcpl ID, can be re-set as a generated dcpl for various operations + * across multiple tests. + * e.g., minimized dataset object headers + */ +static hid_t dcpl_g = H5P_DEFAULT; + /**************************************************************** @@ -200,7 +210,7 @@ test_attr_basic_write(hid_t fapl) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a dataset */ - dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Create dataspace for attribute */ @@ -520,7 +530,7 @@ test_attr_flush(hid_t fapl) spc = H5Screate(H5S_SCALAR); CHECK(spc, FAIL, "H5Screate"); - set = H5Dcreate2(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + set = H5Dcreate2(fil, DSET1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(set, FAIL, "H5Dcreate2"); att = H5Acreate2(set, ATTR1_NAME, H5T_NATIVE_DOUBLE, spc, H5P_DEFAULT, H5P_DEFAULT); @@ -591,7 +601,7 @@ test_attr_plist(hid_t fapl) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a dataset */ - dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Create dataspace for attribute */ @@ -705,7 +715,7 @@ test_attr_compound_write(hid_t fapl) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a dataset */ - dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Close dataset's dataspace */ @@ -941,7 +951,7 @@ test_attr_scalar_write(hid_t fapl) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a dataset */ - dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Create dataspace for attribute */ @@ -1082,7 +1092,7 @@ test_attr_mult_write(hid_t fapl) CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a dataset */ - dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Close dataset's dataspace */ @@ -1460,7 +1470,7 @@ test_attr_iterate(hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create a new dataset */ - dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(file, DSET2_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Close dataspace */ @@ -1684,7 +1694,7 @@ test_attr_dtype_shared(hid_t fapl) CHECK(space_id, FAIL, "H5Screate"); /* Create dataset */ - dset_id = H5Dcreate2(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dset_id = H5Dcreate2(file_id, DSET1_NAME, type_id, space_id, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dset_id, FAIL, "H5Dcreate2"); /* Check reference count on named datatype */ @@ -1838,7 +1848,7 @@ test_attr_duplicate_ids(hid_t fapl) /* Create a dataset */ dataset = H5Dcreate2(fid1, DSET1_NAME, H5T_NATIVE_UCHAR, sid1, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); + dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); /* Create dataspace for attribute */ @@ -2163,9 +2173,14 @@ test_attr_dense_create(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Create a dataset */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -2294,9 +2309,14 @@ test_attr_dense_open(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Enable creation order tracking on attributes, so creation order tests work */ ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED); @@ -2408,14 +2428,25 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) h5_stat_size_t empty_filesize; /* Size of empty file */ h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ + int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Attributes in Dense Storage\n")); - /* Create file */ + if (use_min_dset_oh) { /* using minimized dataset headers */ + /* modify fcpl... + * sidestep "bug" where file space is lost with minimized dset ohdrs + */ + fcpl = H5Pcopy(fcpl); + CHECK(fcpl, FAIL, "H5Pcopy"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, 1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + } fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); + if (use_min_dset_oh) + CHECK(H5Pclose(fcpl), FAIL, "H5Pclose"); /* Close file */ ret = H5Fclose(fid); @@ -2434,9 +2465,14 @@ test_attr_dense_delete(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (use_min_dset_oh) { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } else { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } /* Enable creation order tracking on attributes, so creation order tests work */ ret = H5Pset_attr_creation_order(dcpl, H5P_CRT_ORDER_TRACKED); @@ -2587,14 +2623,25 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ + int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Attributes in Dense Storage\n")); - /* Create file */ + if (use_min_dset_oh) { /* using minimized dataset headers */ + /* modify fcpl... + * sidestep "bug" where file space is lost with minimized dset ohdrs + */ + fcpl = H5Pcopy(fcpl); + CHECK(fcpl, FAIL, "H5Pcopy"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, 1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + } fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); + if (use_min_dset_oh) + CHECK(H5Pclose(fcpl), FAIL, "H5Pclose"); /* Close file */ ret = H5Fclose(fid); @@ -2613,9 +2660,14 @@ test_attr_dense_rename(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (use_min_dset_oh) { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } else { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } /* Create a dataset */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -2746,20 +2798,29 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) h5_stat_size_t filesize; /* Size of file after modifications */ H5O_info_t oinfo; /* Object info */ unsigned u; /* Local index variable */ + int use_min_dset_oh = (dcpl_g != H5P_DEFAULT); herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Attributes in Dense Storage\n")); - /* Create file */ + if (use_min_dset_oh) { /* using minimized dataset headers */ + /* modify fcpl... + * sidestep "bug" where file space is lost with minimized dset ohdrs + */ + fcpl = H5Pcopy(fcpl); + CHECK(fcpl, FAIL, "H5Pcopy"); + ret = H5Pset_file_space_strategy(fcpl, H5F_FSPACE_STRATEGY_FSM_AGGR, TRUE, 1); + CHECK(ret, FAIL, "H5Pset_file_space_strategy"); + } fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); CHECK(fid, FAIL, "H5Fcreate"); + if (use_min_dset_oh) + CHECK(H5Pclose(fcpl), FAIL, "H5Pclose"); - /* Close file */ ret = H5Fclose(fid); CHECK(ret, FAIL, "H5Fclose"); - /* Get size of file */ empty_filesize = h5_get_file_size(FILENAME, fapl); if(empty_filesize < 0) TestErrPrintf("Line %d: file size wrong!\n", __LINE__); @@ -2772,9 +2833,14 @@ test_attr_dense_unlink(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (use_min_dset_oh) { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } else { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } /* Create a dataset */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -2900,9 +2966,14 @@ test_attr_dense_limits(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Change limits on compact/dense attribute storage */ max_compact = 0; @@ -3067,9 +3138,14 @@ test_attr_dense_dup_ids(hid_t fcpl, hid_t fapl) sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Create a dataset */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -3597,9 +3673,14 @@ test_attr_big(hid_t fcpl, hid_t fapl) big_sid = H5Screate_simple(ATTR6_RANK, dims, NULL); CHECK(big_sid, FAIL, "H5Screate_simple"); - /* Query the group creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + /* need DCPL to query the group creation properties */ + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Retrieve limits for compact/dense attribute storage */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -3864,7 +3945,7 @@ test_attr_null_space(hid_t fcpl, hid_t fapl) CHECK(null_sid, FAIL, "H5Screate"); /* Create a dataset */ - dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); @@ -4057,7 +4138,7 @@ test_attr_deprec(hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create a dataset */ - dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate2"); @@ -4292,8 +4373,13 @@ test_attr_corder_create_basic(hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Get creation order indexing on object */ ret = H5Pget_attr_creation_order(dcpl, &crt_order_flags); @@ -4415,8 +4501,13 @@ test_attr_corder_create_compact(hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Set attribute creation order tracking & indexing for object */ ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)); @@ -4615,8 +4706,13 @@ test_attr_corder_create_dense(hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Set attribute creation order tracking & indexing for object */ ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)); @@ -4950,8 +5046,13 @@ test_attr_corder_transition(hid_t fcpl, hid_t fapl) CHECK(fid, FAIL, "H5Fcreate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Set attribute creation order tracking & indexing for object */ ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)); @@ -5361,8 +5462,13 @@ test_attr_corder_delete(hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Set attribute creation order tracking & indexing for object */ ret = H5Pset_attr_creation_order(dcpl, (H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED)); @@ -5704,8 +5810,13 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Query the attribute creation properties */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -5894,7 +6005,7 @@ test_attr_info_null_info_pointer(hid_t fcpl, hid_t fapl) hid_t attr; hid_t sid; - /* Create dataspace for dataset & attributes */ + /* Create dataspace for attribute */ sid = H5Screate(H5S_SCALAR); CHECK(sid, FAIL, "H5Screate"); @@ -5938,6 +6049,95 @@ test_attr_info_null_info_pointer(hid_t fcpl, hid_t fapl) } +/*************************************************************** +** +** test_attr_rename_invalid_name(): A test to ensure that +** passing a NULL or empty attribute name to +** H5Arename(_by_name) doesn't cause bad behavior. +** +****************************************************************/ +static void +test_attr_rename_invalid_name(hid_t fcpl, hid_t fapl) +{ + herr_t err_ret = -1; + hid_t fid; + hid_t attr; + hid_t sid; + + /* Create dataspace for attribute */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create file */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create attribute */ + attr = H5Acreate2(fid, INVALID_RENAME_TEST_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate2"); + + H5E_BEGIN_TRY { + err_ret = H5Arename(fid, NULL, INVALID_RENAME_TEST_NEW_ATTR_NAME); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename"); + + H5E_BEGIN_TRY { + err_ret = H5Arename(fid, "", INVALID_RENAME_TEST_NEW_ATTR_NAME); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename"); + + H5E_BEGIN_TRY { + err_ret = H5Arename(fid, INVALID_RENAME_TEST_ATTR_NAME, NULL); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename"); + + H5E_BEGIN_TRY { + err_ret = H5Arename(fid, INVALID_RENAME_TEST_ATTR_NAME, ""); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename"); + + H5E_BEGIN_TRY { + err_ret = H5Arename_by_name(fid, ".", NULL, INVALID_RENAME_TEST_NEW_ATTR_NAME, H5P_DEFAULT); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename_by_name"); + + H5E_BEGIN_TRY { + err_ret = H5Arename_by_name(fid, ".", "", INVALID_RENAME_TEST_NEW_ATTR_NAME, H5P_DEFAULT); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename_by_name"); + + H5E_BEGIN_TRY { + err_ret = H5Arename_by_name(fid, ".", INVALID_RENAME_TEST_ATTR_NAME, NULL, H5P_DEFAULT); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename_by_name"); + + H5E_BEGIN_TRY { + err_ret = H5Arename_by_name(fid, ".", INVALID_RENAME_TEST_ATTR_NAME, "", H5P_DEFAULT); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Arename_by_name"); + + /* Close dataspace */ + err_ret = H5Sclose(sid); + CHECK(err_ret, FAIL, "H5Sclose"); + + /* Close attribute */ + err_ret = H5Aclose(attr); + CHECK(err_ret, FAIL, "H5Aclose"); + + /* Close file */ + err_ret = H5Fclose(fid); + CHECK(err_ret, FAIL, "H5Fclose"); +} + + /**************************************************************** ** ** test_attr_delete_by_idx(): Test basic H5A (attribute) code. @@ -5975,8 +6175,13 @@ test_attr_delete_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Query the attribute creation properties */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -6918,8 +7123,13 @@ test_attr_iterate2(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Query the attribute creation properties */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -7279,8 +7489,13 @@ test_attr_open_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Query the attribute creation properties */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -7626,8 +7841,13 @@ test_attr_open_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Query the attribute creation properties */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -7880,8 +8100,13 @@ test_attr_create_by_name(hbool_t new_format, hid_t fcpl, hid_t fapl) CHECK(sid, FAIL, "H5Screate"); /* Create dataset creation property list */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Query the attribute creation properties */ ret = H5Pget_attr_phase_change(dcpl, &max_compact, &min_dense); @@ -8181,8 +8406,13 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) } /* end if */ /* Set up to query the object creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Create datasets */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -8512,8 +8742,13 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) } /* end if */ /* Set up to query the object creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Create datasets */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -8958,8 +9193,13 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) } /* end if */ /* Set up to query the object creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Create datasets */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -9327,8 +9567,13 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) } /* end if */ /* Set up to query the object creation properties */ - dcpl = H5Pcreate(H5P_DATASET_CREATE); - CHECK(dcpl, FAIL, "H5Pcreate"); + if (dcpl_g == H5P_DEFAULT) { + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + } else { + dcpl = H5Pcopy(dcpl_g); + CHECK(dcpl, FAIL, "H5Pcopy"); + } /* Create datasets */ dataset = H5Dcreate2(fid, DSET1_NAME, H5T_NATIVE_UCHAR, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT); @@ -9919,7 +10164,7 @@ test_attr_bug3(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Tcommit2"); /* Create dataset */ - did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did = H5Dcreate2(fid, "dset", tid2, sid2, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); /* Create attribute on datatype, using that datatype as its datatype */ @@ -10054,7 +10299,7 @@ test_attr_bug4(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Tcommit2"); /* Create dataset */ - did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did = H5Dcreate2(fid, "dset", tid, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(did, FAIL, "H5Dcreate2"); /* Create attributes on group and dataset */ @@ -10136,7 +10381,7 @@ test_attr_bug5(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Tcommit2"); /* Create dataset */ - did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + did1 = H5Dcreate2(fid1, BUG3_DSET_NAME, tid1, sid, H5P_DEFAULT, dcpl_g, H5P_DEFAULT); CHECK(did1, FAIL, "H5Dcreate2"); /* Create attribute on root group */ @@ -10834,121 +11079,106 @@ test_attr(void) { hid_t fapl = (-1), fapl2 = (-1); /* File access property lists */ hid_t fcpl = (-1), fcpl2 = (-1); /* File creation property lists */ - unsigned new_format; /* Whether to use the new format or not */ - unsigned use_shared; /* Whether to use shared attributes or not */ - herr_t ret; /* Generic return value */ + hid_t dcpl = -1; + unsigned new_format; /* Whether to use the new format or not */ + unsigned use_shared; /* Whether to use shared attributes or not */ + unsigned minimize_dset_oh; /* Whether to use minimized dataset object headers */ + herr_t ret; /* Generic return value */ - /* Output message about test being performed */ MESSAGE(5, ("Testing Attributes\n")); - /* Create a default file access property list */ fapl = H5Pcreate(H5P_FILE_ACCESS); CHECK(fapl, FAIL, "H5Pcreate"); - /* Copy the file access property list */ fapl2 = H5Pcopy(fapl); CHECK(fapl2, FAIL, "H5Pcopy"); - - /* Set the "use the latest version of the format" bounds for creating objects in the file */ ret = H5Pset_libver_bounds(fapl2, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); - /* Create a default file creation property list */ fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK(fcpl, FAIL, "H5Pcreate"); - /* Copy the file creation property list */ + /* files with fcpl2 make all attributes ( > 1 byte) shared + * (i.e. all of them :-) */ fcpl2 = H5Pcopy(fcpl); CHECK(fcpl2, FAIL, "H5Pcopy"); - - /* Make attributes > 1 byte shared (i.e. all of them :-) */ ret = H5Pset_shared_mesg_nindexes(fcpl2, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); ret = H5Pset_shared_mesg_index(fcpl2, (unsigned)0, H5O_SHMESG_ATTR_FLAG, (unsigned)1); CHECK_I(ret, "H5Pset_shared_mesg_index"); - /* Loop over using new group format */ - for(new_format = FALSE; new_format <= TRUE; new_format++) { - hid_t my_fapl; + for(minimize_dset_oh = 0; minimize_dset_oh <= 1; minimize_dset_oh++) { + if(minimize_dset_oh == 0) { + MESSAGE(7, ("testing with default dataset object headers\n")); + dcpl_g = H5P_DEFAULT; + } else { + MESSAGE(7, ("testing with minimzied dataset object headers\n")); + dcpl = H5Pcreate(H5P_DATASET_CREATE); + CHECK(dcpl, FAIL, "H5Pcreate"); + ret = H5Pset_dset_no_attrs_hint(dcpl, TRUE); + CHECK_I(ret, "H5Pset_dset_no_attrs_hint"); + dcpl_g = dcpl; + } + + for(new_format = FALSE; new_format <= TRUE; new_format++) { + hid_t my_fapl; - /* Set the FAPL for the type of format */ - if(new_format) { - MESSAGE(7, ("testing with new file format\n")); - my_fapl = fapl2; - } /* end if */ - else { - MESSAGE(7, ("testing with old file format\n")); - my_fapl = fapl; - } /* end else */ + if(new_format) { + MESSAGE(7, ("testing with new file format\n")); + my_fapl = fapl2; + } else { + MESSAGE(7, ("testing with old file format\n")); + my_fapl = fapl; + } - /* These next two tests use the same file information */ - test_attr_basic_write(my_fapl); /* Test basic H5A writing code */ - test_attr_basic_read(my_fapl); /* Test basic H5A reading code */ + /* These next two tests use the same file information */ + test_attr_basic_write(my_fapl); /* Test basic H5A writing code */ + test_attr_basic_read(my_fapl); /* Test basic H5A reading code */ - /* These next two tests use their own file information */ - test_attr_flush(my_fapl); /* Test H5A I/O in the presence of H5Fflush calls */ - test_attr_plist(my_fapl); /* Test attribute property lists */ + /* These next two tests use their own file information */ + test_attr_flush(my_fapl); /* Test H5A I/O in the presence of H5Fflush calls */ + test_attr_plist(my_fapl); /* Test attribute property lists */ - /* These next two tests use the same file information */ - test_attr_compound_write(my_fapl); /* Test complex datatype H5A writing code */ - test_attr_compound_read(my_fapl); /* Test complex datatype H5A reading code */ + /* These next two tests use the same file information */ + test_attr_compound_write(my_fapl); /* Test complex datatype H5A writing code */ + test_attr_compound_read(my_fapl); /* Test complex datatype H5A reading code */ - /* These next two tests use the same file information */ - test_attr_scalar_write(my_fapl); /* Test scalar dataspace H5A writing code */ - test_attr_scalar_read(my_fapl); /* Test scalar dataspace H5A reading code */ + /* These next two tests use the same file information */ + test_attr_scalar_write(my_fapl); /* Test scalar dataspace H5A writing code */ + test_attr_scalar_read(my_fapl); /* Test scalar dataspace H5A reading code */ - /* These next four tests use the same file information */ - test_attr_mult_write(my_fapl); /* Test H5A writing code for multiple attributes */ - test_attr_mult_read(my_fapl); /* Test H5A reading code for multiple attributes */ - test_attr_iterate(my_fapl); /* Test H5A iterator code */ - test_attr_delete(my_fapl); /* Test H5A code for deleting attributes */ + /* These next four tests use the same file information */ + test_attr_mult_write(my_fapl); /* Test H5A writing code for multiple attributes */ + test_attr_mult_read(my_fapl); /* Test H5A reading code for multiple attributes */ + test_attr_iterate(my_fapl); /* Test H5A iterator code */ + test_attr_delete(my_fapl); /* Test H5A code for deleting attributes */ - /* This next test uses its own file information */ - test_attr_dtype_shared(my_fapl); /* Test using shared dataypes in attributes */ + /* This next test uses its own file information */ + test_attr_dtype_shared(my_fapl); /* Test using shared dataypes in attributes */ - /* This next test uses its own file information */ - test_attr_duplicate_ids(my_fapl); + /* This next test uses its own file information */ + test_attr_duplicate_ids(my_fapl); - /* Tests on "new format" attribute storage */ - if(new_format == TRUE) { - /* Loop over using shared attributes */ for(use_shared = FALSE; use_shared <= TRUE; use_shared++) { hid_t my_fcpl; - /* Set the FCPL for shared or not */ - if(use_shared) { + if(new_format == TRUE && use_shared) { MESSAGE(7, ("testing with shared attributes\n")); my_fcpl = fcpl2; - } /* end if */ - else { + } else { MESSAGE(7, ("testing without shared attributes\n")); my_fcpl = fcpl; - } /* end else */ - - /* General attribute tests */ - test_attr_dense_create(my_fcpl, my_fapl); /* Test dense attribute storage creation */ - test_attr_dense_open(my_fcpl, my_fapl); /* Test opening attributes in dense storage */ - test_attr_dense_delete(my_fcpl, my_fapl); /* Test deleting attributes in dense storage */ - test_attr_dense_rename(my_fcpl, my_fapl); /* Test renaming attributes in dense storage */ - test_attr_dense_unlink(my_fcpl, my_fapl); /* Test unlinking object with attributes in dense storage */ - test_attr_dense_limits(my_fcpl, my_fapl); /* Test dense attribute storage limits */ - test_attr_dense_dup_ids(my_fcpl, my_fapl); /* Test duplicated IDs for dense attribute storage */ + } test_attr_big(my_fcpl, my_fapl); /* Test storing big attribute */ test_attr_null_space(my_fcpl, my_fapl); /* Test storing attribute with NULL dataspace */ test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */ test_attr_many(new_format, my_fcpl, my_fapl); /* Test storing lots of attributes */ test_attr_info_null_info_pointer(my_fcpl, my_fapl); /* Test passing a NULL attribute info pointer to H5Aget_info(_by_name/_by_idx) */ + test_attr_rename_invalid_name(my_fcpl, my_fapl); /* Test passing a NULL or empty attribute name to H5Arename(_by_name) */ - /* Attribute creation order tests */ - test_attr_corder_create_basic(my_fcpl, my_fapl);/* Test creating an object w/attribute creation order info */ - test_attr_corder_create_compact(my_fcpl, my_fapl); /* Test compact attribute storage on an object w/attribute creation order info */ - test_attr_corder_create_dense(my_fcpl, my_fapl);/* Test dense attribute storage on an object w/attribute creation order info */ - test_attr_corder_create_reopen(my_fcpl, my_fapl);/* Test creating attributes w/reopening file from using new format to using old format */ - test_attr_corder_transition(my_fcpl, my_fapl); /* Test attribute storage transitions on an object w/attribute creation order info */ - test_attr_corder_delete(my_fcpl, my_fapl); /* Test deleting object using dense storage w/attribute creation order info */ - - /* New attribute API routine tests */ + /* New attribute API routine tests + */ test_attr_info_by_idx(new_format, my_fcpl, my_fapl); /* Test querying attribute info by index */ test_attr_delete_by_idx(new_format, my_fcpl, my_fapl); /* Test deleting attribute by index */ test_attr_iterate2(new_format, my_fcpl, my_fapl); /* Test iterating over attributes by index */ @@ -10956,57 +11186,68 @@ test_attr(void) test_attr_open_by_name(new_format, my_fcpl, my_fapl); /* Test opening attributes by name */ test_attr_create_by_name(new_format, my_fcpl, my_fapl); /* Test creating attributes by name */ - /* More complex tests with both "new format" and "shared" attributes */ - if(use_shared == TRUE) { - test_attr_shared_write(my_fcpl, my_fapl); /* Test writing to shared attributes in compact & dense storage */ - test_attr_shared_rename(my_fcpl, my_fapl); /* Test renaming shared attributes in compact & dense storage */ - test_attr_shared_delete(my_fcpl, my_fapl); /* Test deleting shared attributes in compact & dense storage */ - test_attr_shared_unlink(my_fcpl, my_fapl); /* Test unlinking object with shared attributes in compact & dense storage */ - } /* end if */ - - /* Tests that address specific bugs */ + /* Tests that address specific bugs + */ test_attr_bug1(my_fcpl, my_fapl); /* Test odd allocation operations */ test_attr_bug2(my_fcpl, my_fapl); /* Test many deleted attributes */ test_attr_bug3(my_fcpl, my_fapl); /* Test "self referential" attributes */ test_attr_bug4(my_fcpl, my_fapl); /* Test attributes on named datatypes */ test_attr_bug5(my_fcpl, my_fapl); /* Test opening/closing attributes through different file handles */ test_attr_bug6(my_fcpl, my_fapl); /* Test reading empty attribute */ - test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */ + /* test_attr_bug7 is specific to the "new" object header format, + * and in fact fails if used with the old format due to the + * attributes being larger than 64K */ test_attr_bug8(my_fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */ test_attr_bug9(my_fcpl, my_fapl); /* Test large attributes converting to dense storage */ - test_attr_delete_last_dense(my_fcpl, my_fapl); /* Test */ - } /* end for */ - } /* end if */ - else { - /* General attribute tests */ - test_attr_big(fcpl, my_fapl); /* Test storing big attribute */ - test_attr_null_space(fcpl, my_fapl); /* Test storing attribute with NULL dataspace */ - test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */ - test_attr_many(new_format, fcpl, my_fapl); /* Test storing lots of attributes */ - test_attr_info_null_info_pointer(fcpl, my_fapl); /* Test passing a NULL attribute info pointer to H5Aget_info(_by_name/_by_idx) */ - - /* New attribute API routine tests, on old-format storage */ - test_attr_info_by_idx(new_format, fcpl, my_fapl); /* Test querying attribute info by index */ - test_attr_delete_by_idx(new_format, fcpl, my_fapl); /* Test deleting attribute by index */ - test_attr_iterate2(new_format, fcpl, my_fapl); /* Test iterating over attributes by index */ - test_attr_open_by_idx(new_format, fcpl, my_fapl); /* Test opening attributes by index */ - test_attr_open_by_name(new_format, fcpl, my_fapl); /* Test opening attributes by name */ - test_attr_create_by_name(new_format, fcpl, my_fapl); /* Test creating attributes by name */ - - /* Tests that address specific bugs */ - test_attr_bug1(fcpl, my_fapl); /* Test odd allocation operations */ - test_attr_bug2(fcpl, my_fapl); /* Test many deleted attributes */ - test_attr_bug3(fcpl, my_fapl); /* Test "self referential" attributes */ - test_attr_bug4(fcpl, my_fapl); /* Test attributes on named datatypes */ - test_attr_bug5(fcpl, my_fapl); /* Test opening/closing attributes through different file handles */ - test_attr_bug6(fcpl, my_fapl); /* Test reading empty attribute */ - /* Skip test_attr_bug7 because it is specific to the new object - * header format and in fact fails if used with the old format, due - * to the attributes being larger than 64K */ - test_attr_bug8(fcpl, my_fapl); /* Test attribute expanding object header with undecoded messages */ - test_attr_bug9(fcpl, my_fapl); /* Test large attributes converting to dense storage */ - } /* end else */ - } /* end for */ + + /* tests specific to the "new format" + */ + if (new_format == TRUE) { + /* General attribute tests */ + test_attr_dense_create(my_fcpl, my_fapl); /* Test dense attribute storage creation */ + test_attr_dense_open(my_fcpl, my_fapl); /* Test opening attributes in dense storage */ + test_attr_dense_delete(my_fcpl, my_fapl); /* Test deleting attributes in dense storage */ + test_attr_dense_rename(my_fcpl, my_fapl); /* Test renaming attributes in dense storage */ + test_attr_dense_unlink(my_fcpl, my_fapl); /* Test unlinking object with attributes in dense storage */ + test_attr_dense_limits(my_fcpl, my_fapl); /* Test dense attribute storage limits */ + test_attr_dense_dup_ids(my_fcpl, my_fapl); /* Test duplicated IDs for dense attribute storage */ + + /* Attribute creation order tests + */ + test_attr_corder_create_basic(my_fcpl, my_fapl);/* Test creating an object w/attribute creation order info */ + test_attr_corder_create_compact(my_fcpl, my_fapl); /* Test compact attribute storage on an object w/attribute creation order info */ + test_attr_corder_create_dense(my_fcpl, my_fapl);/* Test dense attribute storage on an object w/attribute creation order info */ + test_attr_corder_create_reopen(my_fcpl, my_fapl);/* Test creating attributes w/reopening file from using new format to using old format */ + test_attr_corder_transition(my_fcpl, my_fapl); /* Test attribute storage transitions on an object w/attribute creation order info */ + test_attr_corder_delete(my_fcpl, my_fapl); /* Test deleting object using dense storage w/attribute creation order info */ + + /* More complex tests with exclusively both "new format" and "shared" attributes + */ + if(use_shared == TRUE) { + test_attr_shared_write(my_fcpl, my_fapl); /* Test writing to shared attributes in compact & dense storage */ + test_attr_shared_rename(my_fcpl, my_fapl); /* Test renaming shared attributes in compact & dense storage */ + test_attr_shared_delete(my_fcpl, my_fapl); /* Test deleting shared attributes in compact & dense storage */ + test_attr_shared_unlink(my_fcpl, my_fapl); /* Test unlinking object with shared attributes in compact & dense storage */ + } /* if using shared attributes */ + + test_attr_delete_last_dense(my_fcpl, my_fapl); + + /* test_attr_bug7 is specific to the "new" object header format, + * and in fact fails if used with the old format due to the + * attributes being larger than 64K */ + test_attr_bug7(my_fcpl, my_fapl); /* Test creating and deleting large attributes in ohdr chunk 0 */ + + } /* if using "new format" */ + } /* for unshared/shared attributes */ + } /* for old/new format */ + + if (minimize_dset_oh != 0) { + ret = H5Pclose(dcpl); + CHECK(ret, FAIL, "H5Pclose"); + dcpl_g = H5P_DEFAULT; + } + + } /* for default/minimized dataset object headers */ /* Close FCPLs */ ret = H5Pclose(fcpl); diff --git a/test/test_vol_plugin.sh.in b/test/test_vol_plugin.sh.in new file mode 100644 index 0000000..38220ef --- /dev/null +++ b/test/test_vol_plugin.sh.in @@ -0,0 +1,84 @@ +#! /bin/sh +# +# 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. +# +# This shell script is for testing VOL connector plugins. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +TEST_NAME=vol_plugin +TEST_BIN=`pwd`/$TEST_NAME +FROM_DIR=`pwd`/.libs +case $(uname) in + CYGWIN* ) + NULL_VOL_PLUGIN="$FROM_DIR/cygnull_vol_connector*" + ;; + *) + NULL_VOL_PLUGIN="$FROM_DIR/libnull_vol_connector*" + ;; +esac +TEMP_PLUGIN_DIR=null_vol_plugin_dir +CP="cp -p" # Use -p to preserve mode,ownership, timestamps +RM="rm -rf" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Main Body +# Create test directory if necessary. +test -d $TEMP_PLUGIN_DIR || mkdir -p $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to create VOL connector plugin test directory ($TEMP_PLUGIN_DIR)" + exit $EXIT_FAILURE +fi + +# Copy plugin for the tests. +$CP $NULL_VOL_PLUGIN $TEMP_PLUGIN_DIR +if [ $? != 0 ]; then + echo "Failed to copy NULL VOL plugin ($NULL_VOL_PLUGIN) to test directory." + exit $EXIT_FAILURE +fi + +# setup plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${TEMP_PLUGIN_DIR}" + +# Run the test +$ENVCMD $TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +# print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All VOL plugin tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $TEMP_PLUGIN_DIR + +exit $exit_code diff --git a/test/test_filenotclosed.sh.in b/test/testabort_fail.sh.in index 0b43c5b..925d8a4 100644 --- a/test/test_filenotclosed.sh.in +++ b/test/testabort_fail.sh.in @@ -13,6 +13,9 @@ # # Test to verify that the assertion/abort failure is fixed when the application # does not close the file. (See HDFFV-10160) +# +# Test to verify that the infinite loop closing library/abort failure is fixed +# when the application creates and removes dense attributes (See HDFFV-10659) srcdir=@srcdir@ @@ -20,22 +23,44 @@ nerrors=0 ############################################################################## ############################################################################## -### T H E T E S T ### +### T H E T E S T S ### ############################################################################## ############################################################################## - +# +# echo "Testing file not closed assertion/abort failure" TEST_NAME=filenotclosed # The test name -TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary # # Run the test -#$RUNSERIAL $TEST_BIN >/dev/null 2>&1 -$RUNSERIAL $TEST_BIN 2>&1 +$RUNSERIAL $TEST_BIN >/dev/null 2>&1 exitcode=$? if [ $exitcode -eq 0 ]; then echo "Test PASSED" else + echo "Test FAILED" nerrors="`expr $nerrors + 1`" - echo "***Error encountered***" fi -exit $nerrors +# +# +echo "Testing infinite loop closing library/abort failure" +TEST_NAME=del_many_dense_attrs # The test name +TEST_BIN=`pwd`/$TEST_NAME # The path of the test binary +# Run the test +$RUNSERIAL $TEST_BIN >/dev/null 2>&1 +exitcode=$? +if [ $exitcode -eq 0 ]; then + echo "Test PASSED" +else + echo "Test FAILED" + nerrors="`expr $nerrors + 1`" +fi +# +# +if test $nerrors -eq 0 ; then + echo "All tests for abort failure passed." + exit 0 +else + echo "Tests for abort failure failed with $nerrors errors." + exit 1 +fi diff --git a/test/tfile.c b/test/tfile.c index 8a8b889..5338c32 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -7141,6 +7141,132 @@ test_incr_filesize(void) /**************************************************************** ** +** test_min_dset_ohdr(): +** Test API calls to toggle dataset object header minimization. +** +** TODO (as separate function?): +** + setting persists between close and (re)open? +** + dataset header sizes created while changing value of toggle +** +****************************************************************/ +static void +test_min_dset_ohdr(void) +{ + const char basename[] = "min_dset_ohdr_testfile"; + char filename[FILENAME_LEN] = ""; + hid_t file_id = -1; + hid_t file2_id = -1; + hbool_t minimize; + herr_t ret; + + MESSAGE(5, ("Testing dataset object header minimization\n")); + + /*********/ + /* SETUP */ + /*********/ + + h5_fixname(basename, H5P_DEFAULT, filename, sizeof(filename)); + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK_I(file_id, "H5Fcreate"); + + /*********/ + /* TESTS */ + /*********/ + + /*---------------------------------------- + * TEST default value + */ + ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, FALSE, "minimize flag"); + + /*---------------------------------------- + * TEST set to TRUE + */ + ret = H5Fset_dset_no_attrs_hint(file_id, TRUE); + CHECK(ret, FAIL, "H5Fset_dset_no_attrs_hint"); + + ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, TRUE, "minimize flag"); + + /*---------------------------------------- + * TEST second file open on same filename + */ + file2_id = H5Fopen(filename, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK_I(file2_id, "H5Fopen"); + + /* verify TRUE setting on second open + */ + ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, TRUE, "minimize flag"); + + /* re-set to FALSE on first open + */ + ret = H5Fset_dset_no_attrs_hint(file_id, FALSE); + CHECK(ret, FAIL, "H5Fset_dset_no_attrs_hint"); + + /* verify FALSE set on both opens + */ + ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, FALSE, "minimize flag"); + + ret = H5Fget_dset_no_attrs_hint(file2_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, FALSE, "minimize flag"); + + /* re-set to TRUE on second open + */ + ret = H5Fset_dset_no_attrs_hint(file2_id, TRUE); + CHECK(ret, FAIL, "H5Fset_dset_no_attrs_hint"); + + /* verify TRUE set on both opens + */ + ret = H5Fget_dset_no_attrs_hint(file_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, TRUE, "minimize flag"); + + ret = H5Fget_dset_no_attrs_hint(file2_id, &minimize); + CHECK(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + VERIFY(minimize, TRUE, "minimize flag"); + + /*---------------------------------------- + * TEST error cases + */ + + /* trying to set with invalid file ID */ + H5E_BEGIN_TRY { + ret = H5Fset_dset_no_attrs_hint(-1, TRUE); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Fset_dset_no_attrs_hint"); + + /* trying to get with invalid file ID */ + H5E_BEGIN_TRY { + ret = H5Fget_dset_no_attrs_hint(-1, &minimize); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + + /* trying to get with invalid pointer */ + H5E_BEGIN_TRY { + ret = H5Fget_dset_no_attrs_hint(file_id, NULL); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Fget_dset_no_attrs_hint"); + + /************/ + /* TEARDOWN */ + /************/ + + ret = H5Fclose(file_id); + CHECK(ret, FAIL, "H5Fclose"); + ret = H5Fclose(file2_id); + CHECK(ret, FAIL, "H5Fclose"); +} /* end test_min_dset_ohdr() */ + +/**************************************************************** +** ** test_deprec(): ** Test deprecated functionality. ** @@ -7426,6 +7552,7 @@ test_file(void) test_libver_macros(); /* Test the macros for library version comparison */ test_libver_macros2(); /* Test the macros for library version comparison */ test_incr_filesize(); /* Test H5Fincrement_filesize() and H5Fget_eoa() */ + test_min_dset_ohdr(); /* Test datset object header minimization */ #ifndef H5_NO_DEPRECATED_SYMBOLS test_file_ishdf5(); /* Test detecting HDF5 files correctly */ test_deprec(); /* Test deprecated routines */ diff --git a/test/tsohm.c b/test/tsohm.c index 718b12f..bd73d00 100644 --- a/test/tsohm.c +++ b/test/tsohm.c @@ -13,7 +13,7 @@ /*********************************************************** * -* Test program: tsohm +* Test program: tsohm * * Test Shared Object Header Messages * @@ -25,9 +25,9 @@ * This file needs to access private information from the H5F package. * This file also needs to access the file testing code. */ -#define H5F_FRIEND /*suppress error about including H5Fpkg */ +#define H5F_FRIEND /* suppress error about including H5Fpkg */ #define H5F_TESTING -#include "H5Fpkg.h" /* File access */ +#include "H5Fpkg.h" /* File access */ /* Default SOHM values */ #define DEF_NUM_INDEXES 0 @@ -178,40 +178,39 @@ static void test_sohm_extlink(void); /**************************************************************** ** -** check_fcpl_values(): Helper function for test_sohm_fcpl. -** Verifies that the *_in and *_out parameters are equal. +** verify_fcpl_values(): Verifies that FCPL is set as expected. ** ****************************************************************/ -static void check_fcpl_values(hid_t fcpl_id, const unsigned nindexes_in, - const unsigned *flags_in, const unsigned *minsizes_in, - unsigned l2b, unsigned b2l) +static void +verify_fcpl_values(hid_t fcpl_id, const unsigned nindexes_expected, const unsigned *flags_expected, const unsigned *minsizes_expected, unsigned l2b, unsigned b2l) { - unsigned num_indexes; - unsigned index_flags, min_mesg_size; - unsigned list_size, btree_size; - unsigned x; - herr_t ret; - - /* Verify number of indexes is set to default */ - ret = H5Pget_shared_mesg_nindexes(fcpl_id, &num_indexes); + unsigned nindexes_actual; + unsigned list_size; + unsigned btree_size; + unsigned x; + herr_t ret; + + /* Number of indexes */ + ret = H5Pget_shared_mesg_nindexes(fcpl_id, &nindexes_actual); CHECK_I(ret, "H5Pget_shared_mesg_nindexes"); - VERIFY(num_indexes, nindexes_in, "H5Pget_shared_mesg_nindexes"); + VERIFY(nindexes_actual, nindexes_expected, "H5Pget_shared_mesg_nindexes"); - /* Verify index flags and minsizes are set */ - for(x=0; x<num_indexes; ++x) - { - ret = H5Pget_shared_mesg_index(fcpl_id, x, &index_flags, &min_mesg_size); + /* Index flags and minsizes */ + for(x=0; x<nindexes_actual; ++x) { + unsigned flags_i; + unsigned min_mesg_size; + ret = H5Pget_shared_mesg_index(fcpl_id, x, &flags_i, &min_mesg_size); CHECK_I(ret, "H5Pget_shared_mesg_index"); - VERIFY(index_flags, flags_in[x], "H5Pget_shared_mesg_index"); - VERIFY(min_mesg_size, minsizes_in[x], "H5Pget_shared_mesg_index"); + VERIFY(flags_i, flags_expected[x], "H5Pget_shared_mesg_index"); + VERIFY(min_mesg_size, minsizes_expected[x], "H5Pget_shared_mesg_index"); } - /* Check list-to-btree and btree-to-list values */ + /* List-to-btree and btree-to-list values */ ret = H5Pget_shared_mesg_phase_change(fcpl_id, &list_size, &btree_size); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); VERIFY(list_size, l2b, "H5Pset_shared_mesg_phase_change"); VERIFY(btree_size, b2l, "H5Pset_shared_mesg_phase_change"); -} +} /* verify_fcpl_values */ /**************************************************************** @@ -219,22 +218,21 @@ static void check_fcpl_values(hid_t fcpl_id, const unsigned nindexes_in, ** test_sohm_fcpl(): Test File Creation Property Lists. ** ****************************************************************/ -static void test_sohm_fcpl(void) +static void +test_sohm_fcpl(void) { - hid_t fid = -1; - hid_t fcpl_id = -1; - hid_t fcpl2_id = -1; - unsigned x; - herr_t ret; /* Generic return value */ + hid_t fid = -1; + hid_t fcpl_id = -1; + hid_t fcpl2_id = -1; + unsigned x; + herr_t ret; - /* Output message about test being performed */ MESSAGE(5, ("Testing File Creation Properties for Shared Messages\n")); fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); - /* Verify fcpl values */ - check_fcpl_values(fcpl_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L); + verify_fcpl_values(fcpl_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L); /* Create a file with this fcpl and make sure that all the values can be * retrieved. @@ -245,8 +243,7 @@ static void test_sohm_fcpl(void) fcpl2_id = H5Fget_create_plist(fid); CHECK_I(fcpl2_id, "H5Fcreate"); - /* Verify fcpl values */ - check_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L); + verify_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L); ret = H5Pclose(fcpl2_id); CHECK_I(ret, "H5Pclose"); @@ -262,8 +259,7 @@ static void test_sohm_fcpl(void) fcpl2_id = H5Fget_create_plist(fid); CHECK_I(ret, "H5Fcreate"); - /* Verify fcpl values */ - check_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L); + verify_fcpl_values(fcpl2_id, DEF_NUM_INDEXES, def_type_flags, def_minsizes, DEF_L2B, DEF_B2L); /* Clean up */ ret = H5Pclose(fcpl2_id); @@ -289,7 +285,7 @@ static void test_sohm_fcpl(void) ret = H5Pset_shared_mesg_phase_change(fcpl_id, TEST_L2B, TEST_B2L); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - check_fcpl_values(fcpl_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); + verify_fcpl_values(fcpl_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); /* Use the fcpl to create a file and get it back again */ fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); @@ -297,8 +293,7 @@ static void test_sohm_fcpl(void) fcpl2_id = H5Fget_create_plist(fid); CHECK_I(fcpl2_id, "H5Fcreate"); - /* Verify fcpl values */ - check_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); + verify_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); ret = H5Pclose(fcpl2_id); CHECK_I(ret, "H5Pclose"); @@ -314,8 +309,7 @@ static void test_sohm_fcpl(void) fcpl2_id = H5Fget_create_plist(fid); CHECK_I(ret, "H5Fcreate"); - /* Verify fcpl values */ - check_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); + verify_fcpl_values(fcpl2_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); /* Clean up */ ret = H5Pclose(fcpl2_id); @@ -323,7 +317,70 @@ static void test_sohm_fcpl(void) ret = H5Fclose(fid); CHECK_I(ret, "H5Fclose"); - /* Test giving bogus values to H5P* functions */ + /* Actually, the list max can be exactly 1 greater than the + * btree min, but no more. + * Reset the second index. + */ + ret = H5Pset_shared_mesg_index(fcpl_id, 1, test_type_flags[1], 15); + CHECK_I(ret, "H5Pset_shared_mesg_index"); + ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 11); + CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); + CHECK_I(fid, "H5Fcreate"); + ret = H5Fclose(fid); + CHECK_I(ret, "H5Fclose"); + + /* Test edge cases: + * H5O_SHMESG_MAX_NINDEXES and H5O_SHMESG_MAX_LIST_SIZE should be valid + * values. + * Creating a file with uninitialized indexes should work. (TODO: not implemented?) + */ + ret = H5Pset_shared_mesg_nindexes(fcpl_id, H5O_SHMESG_MAX_NINDEXES); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_phase_change(fcpl_id, H5O_SHMESG_MAX_LIST_SIZE, H5O_SHMESG_MAX_LIST_SIZE); + CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); + CHECK_I(fid, "H5Fcreate"); + + /* Clean up */ + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + ret = H5Fclose(fid); + CHECK_I(ret, "H5Fclose"); +} /* test_sohm_fcpl */ + + +/**************************************************************** +** +** test_sohm_fcpl_errors(): Test bogus FCPL settings for SOHMs +** +****************************************************************/ +static void +test_sohm_fcpl_errors(void) +{ + hid_t fcpl_id = -1; + hid_t fid = -1; + unsigned x; + herr_t ret; + + MESSAGE(5, ("Testing bogus file creation properties for shared messages\n")); + + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + + /* Set up index values */ + ret = H5Pset_shared_mesg_nindexes(fcpl_id, TEST_NUM_INDEXES); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + for(x = 0; x < TEST_NUM_INDEXES; ++x) { + ret = H5Pset_shared_mesg_index(fcpl_id, x, test_type_flags[x], test_minsizes[x]); + CHECK_I(ret, "H5Pset_shared_mesg_index"); + } + + ret = H5Pset_shared_mesg_phase_change(fcpl_id, TEST_L2B, TEST_B2L); + CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); + + verify_fcpl_values(fcpl_id, TEST_NUM_INDEXES, test_type_flags, test_minsizes, TEST_L2B, TEST_B2L); + H5E_BEGIN_TRY { /* Trying to create too many indexes should fail */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, H5O_SHMESG_MAX_NINDEXES + 1); @@ -370,40 +427,7 @@ static void test_sohm_fcpl(void) ret = H5Pset_shared_mesg_phase_change(fcpl_id, H5O_SHMESG_MAX_LIST_SIZE, H5O_SHMESG_MAX_LIST_SIZE+1); VERIFY(ret, -1, "H5Pset_shared_mesg_phase_change"); } H5E_END_TRY - - - /* Actually, the list max can be exactly 1 greater than the - * btree min, but no more. Also, the errors above shouldn't - * have corrupted the fcpl, although we do need to reset the - * second index that we changed above. - */ - ret = H5Pset_shared_mesg_index(fcpl_id, 1, test_type_flags[1], 15); - CHECK_I(ret, "H5Pset_shared_mesg_index"); - ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 11); - CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - CHECK_I(fid, "H5Fcreate"); - ret = H5Fclose(fid); - CHECK_I(ret, "H5Fclose"); - - /* Test edge cases; H5O_SHMESG_MAX_NINDEXES and H5O_SHMESG_MAX_LIST_SIZE should be - * valid values. Also, creating a file with uninitialized indexes - * (indexes 3-5) should work. - */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, H5O_SHMESG_MAX_NINDEXES); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_phase_change(fcpl_id, H5O_SHMESG_MAX_LIST_SIZE, H5O_SHMESG_MAX_LIST_SIZE); - CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); - CHECK_I(fid, "H5Fcreate"); - - - /* Clean up */ - ret = H5Pclose(fcpl_id); - CHECK_I(ret, "H5Pclose"); - ret = H5Fclose(fid); - CHECK_I(ret, "H5Fclose"); -} +} /* test_sohm_fcpl_errors */ /*------------------------------------------------------------------------- @@ -455,7 +479,8 @@ error: H5Tclose(dtype1_id); } H5E_END_TRY return -1; -} +} /* make_dtype1 */ + /*------------------------------------------------------------------------- * Function: make_dtype_2 @@ -518,9 +543,9 @@ error: H5Tclose(int_id); } H5E_END_TRY return -1; -} - +} /* make_dtype2 */ + /*------------------------------------------------------------------------- * Function: close_reopen_file * @@ -540,16 +565,16 @@ error: static hid_t close_reopen_file(hid_t file, const char* filename, hid_t fapl_id) { - hid_t fid; - - if(H5Fclose(file) < 0) FAIL_STACK_ERROR - if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_id)) < 0) FAIL_STACK_ERROR - - return(fid); + if (H5Fclose(file) < 0) + FAIL_STACK_ERROR + file = H5Fopen(filename, H5F_ACC_RDWR, fapl_id); + if (file < 0) + FAIL_STACK_ERROR + return(file); error: return -1; -} +} /* close_reopen_file */ /*------------------------------------------------------------------------- @@ -557,7 +582,6 @@ error: * * Purpose: Creates object headers that use a large datatype message. * - * Used in test_sohm_basic. Should close the file ID passed in. * Set test_file_closing to 1 to add file closing and reopening * whenever possible (to test that SOHMs are written correctly * on disk and not just in memory). @@ -571,7 +595,7 @@ error: *------------------------------------------------------------------------- */ static hid_t -size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_closing) +size1_helper(hid_t file, const char *filename, hid_t fapl_id, int test_file_closing) { dtype1_struct wdata; dtype1_struct rdata; @@ -581,6 +605,32 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos hsize_t dim1[1]; int x; +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Macro: TSOHM_S1H_VERIFY_DATA + * + * Purpose: Encapsulate a common pattern: + * Reads the dataset and verifies that [a subset of] the data + * are as expected. + * + * Programmer: Jacob Smith + * 2018 November 1 + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + */ +#define TSOHM_S1H_VERIFY_DATA(dset_id, dtype_id) \ +{ \ + HDmemset(&rdata, 0, sizeof(rdata)); \ + if (0 > H5Dread((dset_id), (dtype_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata)) { \ + H5_FAILED(); AT(); \ + printf("Can't read data\n"); \ + goto error; \ + } \ + if ((rdata.i1 != wdata.i1) || (rdata.i2 != wdata.i2) || HDstrcmp(rdata.str, wdata.str)) { \ + H5_FAILED(); AT(); \ + printf("incorrect read data\n"); \ + goto error; \ + } \ +} /* TSOHM_S1H_VERIFY_DATA() definition */ + /* Closing and re-opening the file takes a long time on systems without * local disks. Don't close and reopen if express testing is enabled. */ @@ -603,107 +653,68 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos /* Intialize rdata */ HDmemset(&rdata, 0, sizeof(rdata)); - if((dtype1_id = make_dtype_1()) < 0) TEST_ERROR + dtype1_id = make_dtype_1(); + if(dtype1_id < 0) TEST_ERROR - /* Create the dataspace and dataset */ dim1[0] = 1; - if((space_id = H5Screate_simple(1, dim1, NULL)) < 0) TEST_ERROR + space_id = H5Screate_simple(1, dim1, NULL); + if(space_id < 0) TEST_ERROR - if((dset_id = H5Dcreate2(file, DSETNAME[0], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + dset_id = H5Dcreate2(file, DSETNAME[0], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_id < 0) FAIL_STACK_ERROR /* Test writing and reading */ if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) FAIL_STACK_ERROR - - if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) FAIL_STACK_ERROR - - if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { - H5_FAILED(); AT(); - printf("incorrect read data\n"); - goto error; - } /* end if */ + TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id) if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR - /* Close and re-open the file if requested*/ if(test_file_closing) if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - /* Create more datasets with the same datatype */ - if((dset_id = H5Dcreate2(file, DSETNAME[1], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR - if(H5Dclose(dset_id) < 0) FAIL_STACK_ERROR + /* Create 3 more datasets with the same datatype/dataspace */ + for (x = 1; x < 4; x++) { + dset_id = H5Dcreate2(file, DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if (0 > dset_id) FAIL_STACK_ERROR + if (x == 3) + if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) TEST_ERROR + if (H5Dclose(dset_id) < 0) FAIL_STACK_ERROR - /* Close and re-open the file if requested*/ - if(test_file_closing) - if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - - if((dset_id = H5Dcreate2(file, DSETNAME[2], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if(H5Dclose(dset_id) < 0) TEST_ERROR - - /* Close and re-open the file if requested*/ - if(test_file_closing) - if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - - if((dset_id = H5Dcreate2(file,DSETNAME[3],dtype1_id,space_id,H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - - /* Write data to dataset 3 for later */ - if(H5Dwrite(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &wdata) < 0) TEST_ERROR + if (test_file_closing) + if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR + } - if(H5Dclose(dset_id) < 0) TEST_ERROR if(H5Tclose(dtype1_id) < 0) TEST_ERROR - /* Close and re-open the file if requested*/ - if(test_file_closing) - if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - /* Make sure the data has been written successfully */ - if((dset_id = H5Dopen2(file, DSETNAME[0], H5P_DEFAULT)) < 0) TEST_ERROR - if((dtype1_id = H5Dget_type(dset_id)) < 0) TEST_ERROR - - /* Read data back again */ - HDmemset(&rdata, 0, sizeof(rdata)); - if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); - printf("Can't read data\n"); - goto error; - } /* end if */ - - if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { - H5_FAILED(); AT(); - printf("incorrect read data\n"); - goto error; - } /* end if */ + dset_id = H5Dopen2(file, DSETNAME[0], H5P_DEFAULT); + if(dset_id < 0) TEST_ERROR + dtype1_id = H5Dget_type(dset_id); + if(dtype1_id < 0) TEST_ERROR + TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id) if(H5Dclose(dset_id) < 0) TEST_ERROR - /* Create several copies of the dataset (this increases the amount of space saved by sharing the datatype message) */ + /* Create several copies of the dataset + * this increases the amount of space saved by sharing the datatype message + */ for(x = 0; x < SOHM_HELPER_NUM_EX_DSETS; x++) { - if((dset_id = H5Dcreate2(file, EXTRA_DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + dset_id = H5Dcreate2(file, EXTRA_DSETNAME[x], dtype1_id, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + if(dset_id < 0) TEST_ERROR if(H5Dclose(dset_id) < 0) TEST_ERROR - /* Close and re-open the file if requested*/ if(test_file_closing) if((file = close_reopen_file(file, filename, fapl_id)) < 0) TEST_ERROR - } /* end for */ + } if(H5Tclose(dtype1_id) < 0) TEST_ERROR if(H5Sclose(space_id) < 0) TEST_ERROR /* Ensure that we can still read data back from dataset 3 */ - if((dset_id = H5Dopen2(file, DSETNAME[3], H5P_DEFAULT)) < 0) TEST_ERROR - if((dtype1_id = H5Dget_type(dset_id)) < 0) TEST_ERROR - - /* Read data back again */ - HDmemset(&rdata, 0, sizeof(rdata)); - if(H5Dread(dset_id, dtype1_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, &rdata) < 0) { - H5_FAILED(); AT(); - printf("Can't read data\n"); - goto error; - } /* end if */ - - if(rdata.i1 != wdata.i1 || rdata.i2 != wdata.i2 || HDstrcmp(rdata.str, wdata.str)) { - H5_FAILED(); AT(); - printf("incorrect read data\n"); - goto error; - } /* end if */ + dset_id = H5Dopen2(file, DSETNAME[3], H5P_DEFAULT); + if(dset_id < 0) TEST_ERROR + dtype1_id = H5Dget_type(dset_id); + if(dtype1_id < 0) TEST_ERROR + TSOHM_S1H_VERIFY_DATA(dset_id, dtype1_id) if(H5Dclose(dset_id) < 0) TEST_ERROR if(H5Tclose(dtype1_id) < 0) TEST_ERROR @@ -717,7 +728,42 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos H5Fclose(file); } H5E_END_TRY return -1; -} +#undef TSOHM_S1H_VERIFY_DATA /* macro is exclusive to this function */ +} /* size1_helper */ + + +/*---------------------------------------------------------------------------- + * Function: getsize_testsize1 + * + * Purpose: Creates a test file, populates it, and returns its file size. + * Oject header information from the "first" dataset in the file + * is stored in pointer `oinfo`. + * + * Programmer: Jacob Smith + * 2018 November 1 + *---------------------------------------------------------------------------- + */ +static h5_stat_size_t +getsize_testsize1(const char *filename, hid_t fcpl_id, hid_t fapl_id, unsigned open_close, H5O_info_t *oinfo) +{ + hid_t file = -1; + herr_t ret; + + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK_I(file, "H5Fcreate"); + + file = size1_helper(file, FILENAME, fapl_id, open_close); + CHECK_I(file, "size1_helper"); + + ret = H5Oget_info_by_name2(file, DSETNAME[0], oinfo, H5O_INFO_HDR, H5P_DEFAULT); + CHECK_I(ret, "H5Oget_info_by_name"); + + ret = H5Fclose(file); + CHECK_I(ret, "H5Fclose"); + + return h5_get_file_size(FILENAME, fapl_id); +} /* getsize_testsize1 */ + /*------------------------------------------------------------------------- * Function: test_sohm_size1 @@ -727,17 +773,26 @@ size1_helper(hid_t file, const char* filename, hid_t fapl_id, int test_file_clos * Programmer: James Laird * Monday, April 10, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ -static void test_sohm_size1(void) +static void +test_sohm_size1(void) { hid_t file = -1; hid_t fcpl_id = -1; hid_t fapl_id = -1; - hsize_t sohm_oh_size; - hsize_t sohm_btree_oh_size; + + unsigned use_shared = 0; + unsigned use_btree = 0; + unsigned open_close = 0; + h5_stat_size_t file_sizes[9]; + unsigned size_index = 0; + hsize_t oh_sizes[3]; + unsigned oh_size_index = 0; + + hsize_t norm_oh_size; + hsize_t sohm_oh_size; + hsize_t sohm_btree_oh_size; h5_stat_size_t norm_empty_filesize; h5_stat_size_t sohm_empty_filesize; h5_stat_size_t sohm_btree_empty_filesize; @@ -747,6 +802,7 @@ static void test_sohm_size1(void) h5_stat_size_t norm_final_filesize2; h5_stat_size_t sohm_final_filesize2; h5_stat_size_t sohm_btree_final_filesize2; + H5O_info_t oinfo; unsigned num_indexes = 1; unsigned index_flags = H5O_SHMESG_DTYPE_FLAG; @@ -757,177 +813,103 @@ static void test_sohm_size1(void) MESSAGE(5, ("Testing that shared datatypes save space\n")); - /* Create a FAPL with "semi" close degree, to detect dangling IDs */ fapl_id = H5Pcreate(H5P_FILE_ACCESS); CHECK_I(fapl_id, "H5Pcreate"); - ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI); CHECK_I(ret, "H5Pset_fclose_degree"); - /* Create a file with SOHMs disabled and get its size */ - fcpl_id = H5Pcreate(H5P_FILE_CREATE); - CHECK_I(fcpl_id, "H5Pcreate"); - - ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK_I(file, "H5Fcreate"); - - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - - /* Get the file size */ - norm_empty_filesize = h5_get_file_size(FILENAME, fapl_id); - - /* Add a bunch of large datatypes to the file */ - file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id); - CHECK_I(file, "H5Fopen"); - file = size1_helper(file, FILENAME, fapl_id, 0); - CHECK_I(file, "size1_helper"); - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - - /* Get the new file size */ - norm_final_filesize = h5_get_file_size(FILENAME, fapl_id); - - /* Use the same property list to create a new file. */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK_I(file, "H5Fcreate"); - - ret = H5Pclose(fcpl_id); - CHECK_I(ret, "H5Pclose"); - - /* Add the same large datatypes, but keep closing and re-opening the file */ - file = size1_helper(file, FILENAME, fapl_id, 1); - CHECK_I(file, "size1_helper"); - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - - /* Get the file size */ - norm_final_filesize2 = h5_get_file_size(FILENAME, fapl_id); - - - - /* Now do the same thing for a file with SOHMs enabled */ - /* Create FCPL with SOHMs enabled */ - fcpl_id = H5Pcreate(H5P_FILE_CREATE); - CHECK_I(fcpl_id, "H5Pcreate"); - - /* Tests one index holding only datatype messages */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size); - CHECK_I(ret, "H5Pset_shared_mesg_index"); - ret = H5Pset_shared_mesg_phase_change(fcpl_id, list_max, btree_min); - CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - - /* Create a file */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK_I(file, "H5Fcreate"); - - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - - sohm_empty_filesize = h5_get_file_size(FILENAME, fapl_id); - - /* Add a bunch of datatypes to this file */ - file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id); - CHECK_I(file, "H5Fopen"); - file = size1_helper(file, FILENAME, fapl_id, 0); - CHECK_I(file, "size1_helper"); + /* ---------------------------------------- + * Run operations, accumulating file sizes to compare later. + */ + + for (use_shared = 0; use_shared < 2; use_shared++) { + for (use_btree = 0; use_btree < 2; use_btree++) { + + /* cannot use btree indexing without shared messages; skip case */ + if (use_btree && !use_shared) + continue; + + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + + if (use_shared) { + /* Tests one index holding only datatype messages */ + ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size); + CHECK_I(ret, "H5Pset_shared_mesg_index"); + + if (use_btree) { + ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); + } else { + ret = H5Pset_shared_mesg_phase_change(fcpl_id, list_max, btree_min); + } + CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); + } else { + ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + } + + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK_I(file, "H5Fcreate"); + ret = H5Fclose(file); + CHECK_I(ret, "H5Fclose"); - /* Get the size of a dataset object header */ - ret = H5Oget_info_by_name2(file, DSETNAME[0], &oinfo, H5O_INFO_HDR, H5P_DEFAULT); - CHECK_I(ret, "H5Oget_info_by_name"); - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - sohm_oh_size = oinfo.hdr.space.total; + /* size of empty file */ + file_sizes[size_index++] = h5_get_file_size(FILENAME, fapl_id); - /* Get the new file size */ - sohm_final_filesize = h5_get_file_size(FILENAME, fapl_id); + /* size of populated file, with different populating behaviors */ + for (open_close = 0; open_close < 2; open_close++) + file_sizes[size_index++] = getsize_testsize1(FILENAME, fcpl_id, fapl_id, open_close, &oinfo); + oh_sizes[oh_size_index++] = oinfo.hdr.space.total; - /* Use the same property list to create a new file. */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK_I(file, "H5Fcreate"); + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + } /* for btree/listed messages */ + } /* for normal/shared messages */ - ret = H5Pclose(fcpl_id); + ret = H5Pclose(fapl_id); CHECK_I(ret, "H5Pclose"); - /* Add the same large datatypes, but keep closing and re-opening the file */ - file = size1_helper(file, FILENAME, fapl_id, 1); - CHECK_I(file, "size1_helper"); - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - - /* Get the file size */ - sohm_final_filesize2 = h5_get_file_size(FILENAME, fapl_id); - - - - /* Create FCPL with SOHMs enabled that uses a B-tree index */ - fcpl_id = H5Pcreate(H5P_FILE_CREATE); - CHECK_I(fcpl_id, "H5Pcreate"); - - /* Tests one index holding only datatype messages */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size); - CHECK_I(ret, "H5Pset_shared_mesg_index"); - ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); - CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - - /* Create a file */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK_I(file, "H5Fcreate"); - - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); + /* sanity-check state of arrays */ + VERIFY(9, size_index, "size_index"); + VERIFY(3, oh_size_index, "oh_size_index"); - sohm_btree_empty_filesize = h5_get_file_size(FILENAME, fapl_id); - - /* Add a bunch of datatypes to this file */ - file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id); - CHECK_I(file, "H5Fopen"); - file = size1_helper(file, FILENAME, fapl_id, 0); - CHECK_I(file, "size1_helper"); - - /* Get the size of a dataset object header */ - ret = H5Oget_info_by_name2(file, DSETNAME[0], &oinfo, H5O_INFO_HDR, H5P_DEFAULT); - CHECK_I(ret, "H5Oget_info_by_name"); - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); - sohm_btree_oh_size = oinfo.hdr.space.total; - - /* Get the new file size */ - sohm_btree_final_filesize = h5_get_file_size(FILENAME, fapl_id); - - /* Use the same property list to create a new file. */ - file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); - CHECK_I(file, "H5Fcreate"); - - ret = H5Pclose(fcpl_id); - CHECK_I(ret, "H5Pclose"); + /* ---------------------------------------- + * Check that all sizes make sense. + */ - /* Add the same large datatypes, but keep closing and re-opening the file */ - file = size1_helper(file, FILENAME, fapl_id, 1); - CHECK_I(file, "size1_helper"); - ret = H5Fclose(file); - CHECK_I(ret, "H5Fclose"); + /* Put result sizes into human-readable symbolic names. + * Order dependent on loop execution above. + */ + norm_empty_filesize = file_sizes[0]; + norm_final_filesize = file_sizes[1]; + norm_final_filesize2 = file_sizes[2]; + norm_oh_size = oh_sizes[0]; - /* Get the file size */ - sohm_btree_final_filesize2 = h5_get_file_size(FILENAME, fapl_id); + sohm_empty_filesize = file_sizes[3]; + sohm_final_filesize = file_sizes[4]; + sohm_final_filesize2 = file_sizes[5]; + sohm_oh_size = oh_sizes[1]; + sohm_btree_empty_filesize = file_sizes[6]; + sohm_btree_final_filesize = file_sizes[7]; + sohm_btree_final_filesize2 = file_sizes[8]; + sohm_btree_oh_size = oh_sizes[2]; + /* How the SOHM messages are stored shouldn't affect the + * size of the object header. + */ + VERIFY(sohm_btree_oh_size, sohm_oh_size, "H5Oget_info_by_name"); - /* Check that all sizes make sense */ +#if 0 /* TBD: lying comment or bug. See Jira HDFFV-10646 */ /* Object headers in SOHM files should be smaller than normal object - * headers. How the SOHM messages are stored shouldn't affect the - * size of the object header. + * headers. */ - if(sohm_oh_size != sohm_btree_oh_size) - VERIFY(sohm_btree_oh_size, 1, "H5Oget_info_by_name"); + if (sohm_oh_size >= norm_oh_size) + VERIFY(norm_oh_size, 1, "H5Oget_info_by_name"); +#endif /* Jira HDFFV-10646 */ /* Both sohm files should be bigger than a normal file when empty. * It's hard to say whether a B-tree with no nodes allocated should be @@ -942,23 +924,127 @@ static void test_sohm_size1(void) VERIFY(sohm_btree_empty_filesize, 1, "h5_get_file_size"); /* When full, the sohm btree file should be smaller than the normal file. - * The sohm list file should be at least as small, since it doesn't need the - * overhead of a B-tree. + * The sohm list file should be at least as small, since it doesn't need + * the overhead of a B-tree. */ if(sohm_btree_final_filesize >= norm_final_filesize) VERIFY(sohm_btree_final_filesize, 1, "h5_get_file_size"); if(sohm_final_filesize > sohm_btree_final_filesize) VERIFY(sohm_final_filesize, 1, "h5_get_file_size"); - /* This shouldn't change even if we open and close the file */ + /* Comparative sizes shouldn't change even if we open and close the file + */ if(sohm_btree_final_filesize2 >= norm_final_filesize2) VERIFY(sohm_btree_final_filesize2, 1, "h5_get_file_size"); if(sohm_final_filesize2 > sohm_btree_final_filesize2) VERIFY(sohm_final_filesize2, 1, "h5_get_file_size"); +} /* test_sohm_size1 */ + + +/*--------------------------------------------------------------------------- + * Function: test_sohm_size_consistency_open_create + * + * Purpose: Tests that header size is different depending on file open + * procedure? + * Uses "size1_helper" for file setup directed to a specific + * file handle. + * + * Programmer: Jacob Smith + * 2018 November 1 + * + *--------------------------------------------------------------------------- + */ +static void +test_sohm_size_consistency_open_create(void) +{ + hid_t file = -1; + hid_t fcpl_id = -1; + hid_t fapl_id = -1; + unsigned use_btree; + hsize_t oh_size_open; + hsize_t oh_size_create; + H5O_info_t oinfo; + unsigned num_indexes = 1; + unsigned index_flags = H5O_SHMESG_DTYPE_FLAG; + unsigned min_mesg_size = 50; + unsigned list_max = 11; + unsigned btree_min = 10; + herr_t ret; + + MESSAGE(5, \ + ("Testing that header size is consistent between H5Fopen and H5Fcreate\n")); + + /* Create a FAPL with "semi" close degree, to detect dangling IDs */ + fapl_id = H5Pcreate(H5P_FILE_ACCESS); + CHECK_I(fapl_id, "H5Pcreate"); + ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI); + CHECK_I(ret, "H5Pset_fclose_degree"); + + for (use_btree = 0; use_btree < 2; use_btree++) { + /* Create FCPL with SOHMs enabled + */ + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + ret = H5Pset_shared_mesg_nindexes(fcpl_id, num_indexes); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 0, index_flags, min_mesg_size); + CHECK_I(ret, "H5Pset_shared_mesg_index"); + if (use_btree) { + MESSAGE(5, ("----testing with btree index----\n")); + ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); + CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); + } else { + MESSAGE(5, ("----testing with normal index----\n")); + ret = H5Pset_shared_mesg_phase_change(fcpl_id, list_max, btree_min); + CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); + } + + /* Create empty file */ + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK_I(file, "H5Fcreate"); + ret = H5Fclose(file); + CHECK_I(ret, "H5Fclose"); + + /* Test Open/Write + * Add messages to previously-created file */ + file = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl_id); + CHECK_I(file, "H5Fopen"); + file = size1_helper(file, FILENAME, fapl_id, 0); + CHECK_I(file, "size1_helper"); + + /* Get the size of a dataset object header */ + ret = H5Oget_info_by_name2(file, DSETNAME[0], &oinfo, H5O_INFO_HDR, H5P_DEFAULT); + CHECK_I(ret, "H5Oget_info_by_name"); + oh_size_open = oinfo.hdr.space.total; + + ret = H5Fclose(file); + CHECK_I(ret, "H5Fclose"); + + /* Test Create/Write + * Add messages to a newly-created file */ + file = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl_id); + CHECK_I(file, "H5Fcreate"); + file = size1_helper(file, FILENAME, fapl_id, 0); + CHECK_I(file, "size1_helper"); + + /* Get the size of a dataset object header */ + ret = H5Oget_info_by_name2(file, DSETNAME[0], &oinfo, H5O_INFO_HDR, H5P_DEFAULT); + CHECK_I(ret, "H5Oget_info_by_name"); + oh_size_create = oinfo.hdr.space.total; + + ret = H5Fclose(file); + CHECK_I(ret, "H5Fclose"); + + VERIFY(oh_size_create, oh_size_open, "H5Oget_info_by_name2"); + + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + } /* for normal/btree indexing */ + ret = H5Pclose(fapl_id); CHECK_I(ret, "H5Pclose"); -} +} /* test_sohm_size_consistency_open_create */ /*------------------------------------------------------------------------- @@ -966,149 +1052,110 @@ static void test_sohm_size1(void) * * Purpose: Given an fcpl, tests creating attributes with and without * committed datatypes. + * Verify that an attribute can be written and read back. + * Tests attribute on a Group. + * Tests committed and non-committed datatypes. + * Tests attribute access through `H5Aopen()`. * * Programmer: James Laird * Thursday, November 30, 2006 * *------------------------------------------------------------------------- */ -static void sohm_attr_helper(hid_t fcpl_id) +static void +sohm_attr_helper(hid_t fcpl_id) { hid_t file_id; - hid_t type_id; hid_t space_id; - hid_t group_id; - hid_t attr_id, attr_id2; hsize_t dims = 2; int wdata[2] = {7, 42}; int rdata[2]; herr_t ret; size_t x; + unsigned op_index=0; +#define TSOHM_SAH_OP_COUNT 3 + const char *groupnames[TSOHM_SAH_OP_COUNT] = { + "group_for_nothing_special", + "group_for_commited_dtype", + "group_for_commited_dtype_and_other_ID_access", + }; - /*---------------------------------------------------------------------------- - * Test attribute with transient datatype - */ - /* Create a file using the fcpl */ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); CHECK_I(file_id, "H5Fcreate"); - /* Create a normal datatype and dataset */ - type_id = H5Tcopy(H5T_NATIVE_INT); - CHECK_I(type_id, "H5Tcopy"); space_id = H5Screate_simple(1, &dims, &dims); CHECK_I(space_id, "H5Screate_simple"); - /* Create and verify an attribute on a group */ - group_id = H5Gcreate2(file_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(group_id, "H5Gcreate2"); - attr_id = H5Acreate2(group_id, "attribute", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(attr_id, "H5Acreate2"); - ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata); - CHECK_I(ret, "H5Awrite"); - - /* Close the datatype and group */ - ret = H5Tclose(type_id); - CHECK_I(ret, "H5Tclose"); - ret = H5Gclose(group_id); - CHECK_I(ret, "H5Gclose"); - - /* Flush the file to force data to be written */ - ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); - CHECK_I(ret, "H5Fflush"); - - /* Verify */ - HDmemset(rdata, 0, sizeof(rdata)); - ret = H5Aread(attr_id, H5T_NATIVE_INT, rdata); - CHECK_I(ret, "H5Aread"); - for(x = 0; x < (size_t)dims; ++x) - VERIFY(rdata[x], wdata[x], "H5Aread"); - - /* Cleanup */ - ret = H5Aclose(attr_id); - CHECK_I(ret, "H5Aclose"); - - /*---------------------------------------------------------------------------- - * Test attribute with committed datatype + /* loop: + * 0 - nothing special + * 1 - committed datatype + * 2 - committed datatype, read through second ID */ - /* Repeat with a committed datatype */ - type_id = H5Tcopy(H5T_NATIVE_INT); - CHECK_I(type_id, "H5Tcopy"); - ret = H5Tcommit2(file_id, "datatype", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(ret, "H5Tcommit2"); + for (op_index = 0; op_index < TSOHM_SAH_OP_COUNT; op_index++) { + hid_t type_id = -1; + hid_t group_id = -1; + hid_t attr_id = -1; + hid_t attr_id2 = -1; + hid_t attr_read_id; - /* Create and verify an attribute */ - group_id = H5Gcreate2(file_id, "another_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(group_id, "H5Gcreate2"); - attr_id = H5Acreate2(group_id, "attribute", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(attr_id, "H5Acreate2"); - ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata); - CHECK_I(ret, "H5Awrite"); - - /* Close the datatype and group */ - ret = H5Tclose(type_id); - CHECK_I(ret, "H5Tclose"); - ret = H5Gclose(group_id); - CHECK_I(ret, "H5Gclose"); + /* create group in file with name unique to op_index */ + group_id = H5Gcreate2(file_id, groupnames[op_index], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK_I(group_id, "H5Gcreate2"); - /* Flush the file to force data to be written */ - ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); - CHECK_I(ret, "H5Fflush"); + type_id = H5Tcopy(H5T_NATIVE_INT); + CHECK_I(type_id, "H5Tcopy"); - /* Verify */ - HDmemset(rdata, 0, sizeof(rdata)); - ret = H5Aread(attr_id, H5T_NATIVE_INT, rdata); - CHECK_I(ret, "H5Aread"); - for(x = 0; x < (size_t)dims; ++x) - VERIFY(rdata[x], wdata[x], "H5Aread"); - - /* Cleanup */ - ret = H5Aclose(attr_id); - CHECK_I(ret, "H5Aclose"); - - /*---------------------------------------------------------------------------- - * Test attribute operation with two ID handles - */ - /* Create and verify an attribute */ - group_id = H5Gcreate2(file_id, "yet_another_group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(group_id, "H5Gcreate2"); - - attr_id = H5Acreate2(group_id, "attribute", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT); - CHECK_I(attr_id, "H5Acreate2"); + /* Commit the datatype for the latter iterations. + * Only do this ONCE. + */ + if (op_index == 1) { + ret = H5Tcommit2(file_id, "datatype", type_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + CHECK_I(ret, "H5Tcommit2"); + } - /* Open the attribute to get another handle */ - attr_id2 = H5Aopen(group_id, "attribute", H5P_DEFAULT); - CHECK_I(attr_id2, "H5Aopen"); + attr_id = H5Acreate2(group_id, "attribute", type_id, space_id, H5P_DEFAULT, H5P_DEFAULT); + CHECK_I(attr_id, "H5Acreate2"); - ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata); - CHECK_I(ret, "H5Awrite"); + if (op_index == 2) { + /* Open the attribute to get another handle */ + attr_id2 = H5Aopen(group_id, "attribute", H5P_DEFAULT); + CHECK_I(attr_id2, "H5Aopen"); + } - /* Close the group */ - ret = H5Gclose(group_id); - CHECK_I(ret, "H5Gclose"); + ret = H5Awrite(attr_id, H5T_NATIVE_INT, wdata); + CHECK_I(ret, "H5Awrite"); - /* Flush the file to force data to be written */ - ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); - CHECK_I(ret, "H5Fflush"); + ret = H5Gclose(group_id); + CHECK_I(ret, "H5Gclose"); + ret = H5Tclose(type_id); + CHECK_I(ret, "H5Tclose"); - /* Verify the data with another ID handle */ - HDmemset(rdata, 0, sizeof(rdata)); - ret = H5Aread(attr_id2, H5T_NATIVE_INT, rdata); - CHECK_I(ret, "H5Aread"); + /* Flush the file to force data to be written */ + ret = H5Fflush(file_id, H5F_SCOPE_GLOBAL); + CHECK_I(ret, "H5Fflush"); - for(x = 0; x < (size_t)dims; ++x) - VERIFY(rdata[x], wdata[x], "H5Aread"); + /* Verify */ + attr_read_id = (op_index == 2) ? attr_id2 : attr_id; + HDmemset(rdata, 0, sizeof(rdata)); + ret = H5Aread(attr_read_id, H5T_NATIVE_INT, rdata); + CHECK_I(ret, "H5Aread"); + for(x = 0; x < (size_t)dims; ++x) + VERIFY(rdata[x], wdata[x], "H5Aread"); - /* Cleanup */ - ret = H5Aclose(attr_id); - CHECK_I(ret, "H5Aclose"); - ret = H5Aclose(attr_id2); - CHECK_I(ret, "H5Aclose"); + ret = H5Aclose(attr_id); + CHECK_I(ret, "H5Aclose"); + if (attr_id2 > -1 ) { + ret = H5Aclose(attr_id2); + CHECK_I(ret, "H5Aclose"); + } + } /* for each attribute operation */ ret = H5Sclose(space_id); CHECK_I(ret, "H5Sclose"); ret = H5Fclose(file_id); CHECK_I(ret, "H5Fclose"); -} +#undef TSOHM_SAH_OP_COUNT +} /* sohm_attr_helper */ /*------------------------------------------------------------------------- @@ -1125,101 +1172,160 @@ static void sohm_attr_helper(hid_t fcpl_id) * *------------------------------------------------------------------------- */ -static void test_sohm_attrs(void) +static void +test_sohm_attrs(void) { hid_t fcpl_id; + unsigned i = 0; +#define TSOHM_TSA_NFLAGS_1 7 + unsigned flags1[TSOHM_TSA_NFLAGS_1] = { + H5O_SHMESG_ATTR_FLAG, + H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, + }; +#define TSOHM_TSA_NFLAGS_2 6 + unsigned flags2[TSOHM_TSA_NFLAGS_2][2] = { + { H5O_SHMESG_ATTR_FLAG, + H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, + }, + { H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, + }, + { H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG, + }, + { H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG, + }, + { H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_SDSPACE_FLAG, + }, + { H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_DTYPE_FLAG, + }, + }; +#define TSOHM_TSA_NFLAGS_3 5 + unsigned flags3[TSOHM_TSA_NFLAGS_3][3] = { + { H5O_SHMESG_ATTR_FLAG, + H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_DTYPE_FLAG, + }, + { H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG, + H5O_SHMESG_SDSPACE_FLAG, + }, + { H5O_SHMESG_SDSPACE_FLAG, + H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG, + }, + { 0, /* first index does not hold a shared message type? */ + H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG, + }, + { 0, /* missing SDSPACE flag */ + H5O_SHMESG_DTYPE_FLAG, + H5O_SHMESG_ATTR_FLAG, + }, + }; herr_t ret; MESSAGE(5, ("Testing that shared messages work with attributes\n")); - /* Create an fcpl with no shared messages */ + /* No shared messages + */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl_id, 0); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - /* Make sure attributes can be read with these settings (they'd better!) */ - sohm_attr_helper(fcpl_id); - - - /* Run tests with only one kind of message to be shared */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - /* Verify */ - sohm_attr_helper(fcpl_id); - - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - sohm_attr_helper(fcpl_id); - - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_DTYPE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - sohm_attr_helper(fcpl_id); - - - /* Run with any two types shared */ - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - sohm_attr_helper(fcpl_id); - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - sohm_attr_helper(fcpl_id); - - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_ATTR_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - sohm_attr_helper(fcpl_id); - - - /* Run test with all three kinds of message shared */ - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG | H5O_SHMESG_DTYPE_FLAG | H5O_SHMESG_ATTR_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); - sohm_attr_helper(fcpl_id); + /* One shared message index + */ + for (i=0; i < TSOHM_TSA_NFLAGS_1; i++) { + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 0, flags1[i], 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + sohm_attr_helper(fcpl_id); - /* Try using two indexes */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG | H5O_SHMESG_DTYPE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_SDSPACE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + } - sohm_attr_helper(fcpl_id); + /* two shared message indices + */ + for (i=0; i < TSOHM_TSA_NFLAGS_2; i++) { + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 0, flags2[i][0], 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 1, flags2[i][1], 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_DTYPE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + sohm_attr_helper(fcpl_id); - sohm_attr_helper(fcpl_id); + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + } - ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + /* duplicate flags in separate indices causes problems + */ + H5E_BEGIN_TRY { + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + ret = H5Pset_shared_mesg_nindexes(fcpl_id, 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ATTR_FLAG, 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 1, H5O_SHMESG_ATTR_FLAG, 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + + ret = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); + VERIFY(ret, -1, "H5Fcreate"); + + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + } H5E_END_TRY; - sohm_attr_helper(fcpl_id); + /* three shared message indices + */ + for (i=0; i < TSOHM_TSA_NFLAGS_3; i++) { + fcpl_id = H5Pcreate(H5P_FILE_CREATE); + CHECK_I(fcpl_id, "H5Pcreate"); + ret = H5Pset_shared_mesg_nindexes(fcpl_id, 3); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 0, flags3[i][0], 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 1, flags3[i][1], 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pset_shared_mesg_index(fcpl_id, 2, flags3[i][2], 2); + CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + sohm_attr_helper(fcpl_id); - /* One index for each kind of message */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, 3); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - ret = H5Pset_shared_mesg_index(fcpl_id, 2, H5O_SHMESG_SDSPACE_FLAG, 2); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); + ret = H5Pclose(fcpl_id); + CHECK_I(ret, "H5Pclose"); + } - sohm_attr_helper(fcpl_id); +#undef TSOHM_TSA_NFLAGS_1 +#undef TSOHM_TSA_NFLAGS_2 +#undef TSOHM_TSA_NFLAGS_3 +} /* test_sohm_attrs */ - /* Close the FCPL */ - ret = H5Pclose(fcpl_id); - CHECK_I(ret, "H5Pclose"); -} /*------------------------------------------------------------------------- * Function: size2_verify_plist1 @@ -1233,7 +1339,8 @@ static void test_sohm_attrs(void) * *------------------------------------------------------------------------- */ -static void size2_verify_plist1(hid_t plist) +static void +size2_verify_plist1(hid_t plist) { size_t cd_nelmts; unsigned int cd_value; @@ -1281,7 +1388,8 @@ static void size2_verify_plist1(hid_t plist) ret = H5Tclose(dtype1_id); CHECK_I(ret, "H5Tclose"); -} +} /* size2_verify_plist1 */ + /*------------------------------------------------------------------------- * Function: size2_verify_plist2 @@ -1295,7 +1403,8 @@ static void size2_verify_plist1(hid_t plist) * *------------------------------------------------------------------------- */ -static void size2_verify_plist2(hid_t plist) +static void +size2_verify_plist2(hid_t plist) { size_t cd_nelmts; unsigned int cd_value; @@ -1352,7 +1461,7 @@ static void size2_verify_plist2(hid_t plist) ret = H5Tclose(dtype2_id); CHECK_I(ret, "H5Tclose"); -} +} /* size2_verify_plist2 */ #ifdef NOT_NOW @@ -1382,7 +1491,7 @@ size2_dump_struct(const char *name, size2_helper_struct *sizes) printf(" interleaved: %llu \tdelta: %llu\n", (unsigned long long)sizes->interleaved, (unsigned long long)(sizes->interleaved - sizes->dsets2)); printf(" attributes: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs1, (unsigned long long)(sizes->attrs1 - sizes->interleaved)); printf(" attributes 2: %llu \tdelta: %llu\n", (unsigned long long)sizes->attrs2, (unsigned long long)(sizes->attrs2 - sizes->attrs1)); -} +} /* size2_dump_struct */ #endif /* NOT_NOW */ @@ -1573,15 +1682,14 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size ret_sizes->dsets1 = h5_get_file_size(FILENAME, H5P_DEFAULT); - /* Now create a new group filled with datasets that use all different messages */ + /* Create new group filled with datasets that use all different messages */ file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); CHECK_I(file_id, "H5Fopen"); group_id = H5Gcreate2(file_id, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK_I(group_id, "H5Gcreate2"); /* Create NUM_DATASETS datasets in the new group */ - for(x=0; x<NUM_DATASETS; ++x) - { + for(x=0; x<NUM_DATASETS; ++x) { dset_id = H5Dcreate2(group_id, DSETNAME[x], dtype2_id, dspace2_id, H5P_DEFAULT, dcpl2_id, H5P_DEFAULT); CHECK_I(dset_id, "H5Dcreate2"); @@ -1768,7 +1876,7 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size CHECK_I(ret, "H5Pclose"); return 0; -} +} /* size2_helper */ /*------------------------------------------------------------------------- @@ -1785,7 +1893,8 @@ size2_helper(hid_t fcpl_id, int test_file_closing, size2_helper_struct *ret_size * *------------------------------------------------------------------------- */ -static void size2_verify(void) +static void +size2_verify(void) { hid_t file_id = -1; hid_t dset_id=-1; @@ -1968,7 +2077,7 @@ static void size2_verify(void) CHECK_I(ret, "H5Gclose"); ret = H5Fclose(file_id); CHECK_I(ret, "H5Fclose"); -} +} /* size2_verify */ /*------------------------------------------------------------------------- @@ -1993,7 +2102,8 @@ static void size2_verify(void) * *------------------------------------------------------------------------- */ -static void test_sohm_size2(int close_reopen) +static void +test_sohm_size2(int close_reopen) { hid_t fcpl_id = -1; /* Sizes for file with no shared messages at all */ @@ -2585,7 +2695,7 @@ static void test_sohm_size2(int close_reopen) VERIFY(0, 1, "h5_get_file_size"); if((h5_stat_size_t)((float)share_tiny_index.attrs2 * OVERHEAD_ALLOWED) < type_space_index.attrs2) VERIFY(0, 1, "h5_get_file_size"); -} /* end test_sohm_size2() */ +} /* test_sohm_size2 */ /*------------------------------------------------------------------------- @@ -2601,27 +2711,22 @@ static void test_sohm_size2(int close_reopen) * *------------------------------------------------------------------------- */ -static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x) +static void +delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, int x) { - hid_t dset_id = -1; - hid_t attr_id = -1; - char wdata; + hid_t dset_id = -1; + hid_t attr_id = -1; + char wdata; herr_t ret; - /* Create dataset */ dset_id = H5Dcreate2(file_id, DSETNAME[x], H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, dcpl_id[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dcreate2"); - - /* Write data to dataset */ wdata = (char)(x + 'a'); ret = H5Dwrite(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &wdata); CHECK_I(ret, "H5Dwrite"); - /* Create an attribute on the dataset. */ attr_id = H5Acreate2(dset_id, "attr_name", H5T_NATIVE_CHAR, dspace_id[x], H5P_DEFAULT, H5P_DEFAULT); CHECK_I(attr_id, "H5Acreate2"); - - /* Write to attribute */ ret = H5Awrite(attr_id, H5T_NATIVE_CHAR, &wdata); CHECK_I(ret, "H5Awrite"); @@ -2629,7 +2734,7 @@ static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, CHECK_I(ret, "H5Aclose"); ret = H5Dclose(dset_id); CHECK_I(ret, "H5Dclose"); -} +} /* delete_helper_write */ /*------------------------------------------------------------------------- @@ -2645,39 +2750,33 @@ static void delete_helper_write(hid_t file_id, hid_t *dspace_id, hid_t *dcpl_id, * *------------------------------------------------------------------------- */ -static void delete_helper_read(hid_t file_id, hid_t *dspace_id, int x) +static void +delete_helper_read(hid_t file_id, hid_t *dspace_id, int x) { hid_t dset_id = -1; hid_t attr_id = -1; char rdata; herr_t ret; - /* Open dataset */ dset_id = H5Dopen2(file_id, DSETNAME[x], H5P_DEFAULT); CHECK_I(dset_id, "H5Dopen2"); - - /* Read */ rdata = '\0'; ret = H5Dread(dset_id, H5T_NATIVE_CHAR, dspace_id[x], dspace_id[x], H5P_DEFAULT, &rdata); CHECK_I(ret, "H5Dread"); VERIFY(rdata, (x + 'a'), "H5Dread"); - /* Open attribute */ attr_id = H5Aopen(dset_id, "attr_name", H5P_DEFAULT); CHECK_I(attr_id, "H5Aopen"); - - /* Read */ rdata = '\0'; ret = H5Aread(attr_id, H5T_NATIVE_CHAR, &rdata); CHECK_I(ret, "H5Dread"); VERIFY(rdata, (x + 'a'), "H5Dread"); - /* Cleanup */ ret = H5Aclose(attr_id); CHECK_I(ret, "H5Aclose"); ret = H5Dclose(dset_id); CHECK_I(ret, "H5Dclose"); -} +} /* delete_helper_read */ /*------------------------------------------------------------------------- @@ -2701,7 +2800,8 @@ static void delete_helper_read(hid_t file_id, hid_t *dspace_id, int x) * *------------------------------------------------------------------------- */ -static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id) +static void +delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id) { hid_t file_id=-1; int x; @@ -2765,7 +2865,7 @@ static void delete_helper(hid_t fcpl_id, hid_t *dspace_id, hid_t *dcpl_id) VERIFY(norm_filesize, deleted_filesize, "h5_get_file_size"); if(deleted_filesize > (h5_stat_size_t)((float)norm_filesize * OVERHEAD_ALLOWED)) VERIFY(deleted_filesize, norm_filesize, "h5_get_file_size"); -} +} /* delete_helper */ /*------------------------------------------------------------------------- @@ -2799,6 +2899,8 @@ test_sohm_delete(void) hsize_t dims[] = DELETE_DIMS; herr_t ret; + MESSAGE(5, ("Testing deletion of SOHMs\n")); + /* Create a number of different dataspaces. * For simplicity, each dataspace has only one element. */ @@ -2910,17 +3012,18 @@ test_sohm_delete(void) ret = H5Pclose(dcpl_id[x]); CHECK_I(ret, "H5Pclose"); } /* end for */ -} /* end test_sohm_delete() */ +} /* test_sohm_delete */ /*------------------------------------------------------------------------- - * Function: test_sohm_delete_revert_helper + * Function: verify_dset_create_and_delete_does_not_grow_file * * Purpose: Tests that shared object header message deletion returns * the file to its previous state using the supplied FCPL. * - * Creates shared messages and then deletes them. Ensures - * that the file has not grown in size. + * Creates a file according to the supplied FCPL, + * then creates datasets and deletes them. + * Done in two passes: once with one dataset, once with two. * * Programmer: James Laird * Wednesday, January 3, 2007 @@ -2930,7 +3033,7 @@ test_sohm_delete(void) *------------------------------------------------------------------------- */ static int -test_sohm_delete_revert_helper(hid_t fcpl_id) +verify_dset_create_and_delete_does_not_grow_file(hid_t fcpl_id) { hid_t file_id; hid_t dspace_id; @@ -3017,13 +3120,14 @@ test_sohm_delete_revert_helper(hid_t fcpl_id) return(0); else return(-1); -} /* test_sohm_delete_revert_helper() */ +} /* verify_dset_create_and_delete_does_not_grow_file */ /*------------------------------------------------------------------------- * Function: test_sohm_delete_revert * - * Purpose: Calls test_sohm_delete_revert_helper with different FCPLs. + * Purpose: Verifies that creation and deletion of datasets with shared + * message headers will not increase file size. * * Programmer: James Laird * Wednesday, January 3, 2007 @@ -3038,6 +3142,8 @@ test_sohm_delete_revert(void) hid_t fcpl_id; herr_t ret; + MESSAGE(5, ("Testing that file reverts to original size on SOHM deletion\n")); + /* Create an fcpl with messages in two indexes */ fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); @@ -3049,14 +3155,14 @@ test_sohm_delete_revert(void) CHECK_I(ret, "H5Pset_shared_mesg_index"); /* Call the helper function to test this FCPL. */ - ret = test_sohm_delete_revert_helper(fcpl_id); - CHECK_I(ret, "test_sohm_delete_revert_helper"); + ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); + CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); /* Try using B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_delete_revert_helper(fcpl_id); - CHECK_I(ret, "test_sohm_delete_revert_helper"); + ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); + CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); /* Try sharing all messages */ @@ -3067,14 +3173,14 @@ test_sohm_delete_revert(void) ret = H5Pset_shared_mesg_phase_change(fcpl_id, 10, 5); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_delete_revert_helper(fcpl_id); - CHECK_I(ret, "test_sohm_delete_revert_helper"); + ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); + CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); /* Try using B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_delete_revert_helper(fcpl_id); - CHECK_I(ret, "test_sohm_delete_revert_helper"); + ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); + CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); /* There should be at least two messages in the test (datatype and * dataspace). Use an index that will transition from a list to @@ -3082,8 +3188,8 @@ test_sohm_delete_revert(void) */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 1, 2); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_delete_revert_helper(fcpl_id); - CHECK_I(ret, "test_sohm_delete_revert_helper"); + ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); + CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); /* Try with shared messages enabled, but when messages are too big @@ -3091,16 +3197,16 @@ test_sohm_delete_revert(void) */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 35); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_delete_revert_helper(fcpl_id); - CHECK_I(ret, "test_sohm_delete_revert_helper"); + ret = verify_dset_create_and_delete_does_not_grow_file(fcpl_id); + CHECK_I(ret, "verify_dset_create_and_delete_does_not_grow_file"); ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); -} +} /* test_sohm_delete_revert */ /*------------------------------------------------------------------------- - * Function: test_sohm_extlink_helper + * Function: verify_dset_create_and_open_through_extlink_with_sohm * * Purpose: Tests that a dataset created through an external link can * be opened (that shared messages were created or not and @@ -3113,7 +3219,8 @@ test_sohm_delete_revert(void) * *------------------------------------------------------------------------- */ -static void test_sohm_extlink_helper(hid_t src_fcpl_id, hid_t dst_fcpl_id) +static void +verify_dset_create_and_open_through_extlink_with_sohm(hid_t src_fcpl_id, hid_t dst_fcpl_id) { hid_t src_file_id = -1; hid_t dst_file_id = -1; @@ -3164,7 +3271,7 @@ static void test_sohm_extlink_helper(hid_t src_fcpl_id, hid_t dst_fcpl_id) CHECK_I(ret, "H5Dclose"); ret = H5Fclose(dst_file_id); CHECK_I(ret, "H5Fclose"); -} +} /* verify_dset_create_and_open_through_extlink_with_sohm */ /*------------------------------------------------------------------------- @@ -3186,7 +3293,8 @@ test_sohm_extlink(void) hid_t fcpl_id = -1; herr_t ret; - /* Create fcpl */ + MESSAGE(5, ("Testing SOHM creation through external links\n")); + fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); @@ -3194,20 +3302,17 @@ test_sohm_extlink(void) ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 16); CHECK_I(ret, "H5Pset_shared_mesg_index"); - /* Test using external links when the source or destination file uses - * shared messages - */ - test_sohm_extlink_helper(fcpl_id, H5P_DEFAULT); - test_sohm_extlink_helper(H5P_DEFAULT, fcpl_id); - test_sohm_extlink_helper(fcpl_id, fcpl_id); + verify_dset_create_and_open_through_extlink_with_sohm(fcpl_id, H5P_DEFAULT); + verify_dset_create_and_open_through_extlink_with_sohm(H5P_DEFAULT, fcpl_id); + verify_dset_create_and_open_through_extlink_with_sohm(fcpl_id, fcpl_id); ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); -} +} /* test_sohm_extlink */ /*------------------------------------------------------------------------- - * Function: test_sohm_extend_dset_helper + * Function: verify_dataset_extension * * Purpose: Tests extending a dataset's dataspace when sharing is * enabled. @@ -3223,7 +3328,7 @@ test_sohm_extlink(void) *------------------------------------------------------------------------- */ static int -test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen) +verify_dataset_extension(hid_t fcpl_id, hbool_t close_reopen) { hid_t file_id = -1; hid_t orig_space_id = -1; @@ -3236,13 +3341,98 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen) hsize_t out_dims[2]; hsize_t out_maxdims[2]; int x; - int old_nerrs; /* Number of errors when entering this routine */ + int old_nerrs; /* Number of errors when entering this routine */ herr_t ret; - /* Retrieve the current # of reported errors */ + hsize_t *space_dims[3]; + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Macro: TSOHM_VDE_VERIFY_SPACES + * + * Purpose: Encapsulate a common pattern + * Open, read-verify, and close the dataspaces for datasets 1-3 + * + * Programmer: Jacob Smith + * 2018 November 5 + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + */ +#define TSOHM_VDE_VERIFY_SPACES(dims) \ +{ \ + /* Open dataspaces \ + */ \ + space1_id = H5Dget_space(dset1_id); \ + CHECK_I(space1_id, "H5Dget_space"); \ + space2_id = H5Dget_space(dset2_id); \ + CHECK_I(space2_id, "H5Dget_space"); \ + space3_id = H5Dget_space(dset3_id); \ + CHECK_I(space3_id, "H5Dget_space"); \ + /* Verify dataspaces \ + */ \ + ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); \ + CHECK_I(ret, "H5Sget_simple_extent_dims"); \ + for(x=0; x<EXTEND_NDIMS; ++x) { \ + VERIFY(out_dims[x], (dims)[0][x], "H5Sget_simple_extent_dims"); \ + VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); \ + } \ + ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims); \ + CHECK_I(ret, "H5Sget_simple_extent_dims"); \ + for(x=0; x<EXTEND_NDIMS; ++x) { \ + VERIFY(out_dims[x], (dims)[1][x], "H5Sget_simple_extent_dims"); \ + VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); \ + } \ + ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims); \ + CHECK_I(ret, "H5Sget_simple_extent_dims"); \ + for(x=0; x<EXTEND_NDIMS; ++x) { \ + VERIFY(out_dims[x], (dims)[2][x], "H5Sget_simple_extent_dims"); \ + VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); \ + } \ + /* Close dataspaces \ + */ \ + CHECK_I(H5Sclose(space1_id), "H5Sclose"); \ + CHECK_I(H5Sclose(space2_id), "H5Sclose"); \ + CHECK_I(H5Sclose(space3_id), "H5Sclose"); \ +} /* define TSOHM_VDE_VERIFY_SPACES */ + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + * Macro: TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS() + * + * Purpose: Encapsulate a common pattern + * Wrapper to close and reopen file and datasets: + * + "dataset" (dset_id) + * + if n > 1 then include "dataset2" (dset_id2) + * + if n > 2 then include "dataset3" (dset_id3) + * + file (file_id) + * + * Programmer: Jacob Smith + * 2018 November 5 + * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + */ +#define TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(n) \ +{ \ + CHECK_I(H5Dclose(dset1_id), "H5Dclose"); \ + if ((n) > 1) \ + CHECK_I(H5Dclose(dset2_id), "H5Dclose"); \ + if ((n) > 2) \ + CHECK_I(H5Dclose(dset3_id), "H5Dclose"); \ + CHECK_I(H5Fclose(file_id), "H5Fclose"); \ + \ + file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); \ + CHECK_I(file_id, "H5Fopen"); \ + dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); \ + CHECK_I(dset1_id, "H5Dopen2"); \ + if ((n) > 1) { \ + dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); \ + CHECK_I(dset2_id, "H5Dopen2"); \ + } \ + if ((n) > 2) { \ + dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); \ + CHECK_I(dset3_id, "H5Dopen2"); \ + } \ +} /* define TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS */ + + /* Remember the current # of reported errors */ old_nerrs = GetTestNumErrs(); - /* Create file */ file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); CHECK_I(file_id, "H5Fcreate"); @@ -3257,251 +3447,49 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen) CHECK_I(orig_space_id, "H5Screate_simple"); dset1_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset1_id, "H5Dcreate2"); - - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - } + if(close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(1); /* Create another dataset starting with the same dataspace */ dset2_id = H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset2_id, "H5Dcreate2"); - - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(2); /* Create a third dataset with the same dataspace */ dset3_id = H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset3_id, "H5Dcreate2"); - - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset3_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); - CHECK_I(dset3_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); /* Extend the first dataset */ ret = H5Dset_extent(dset1_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset3_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); - CHECK_I(dset3_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); - /* Get the dataspaces from the datasets */ - space1_id = H5Dget_space(dset1_id); - CHECK_I(space1_id, "H5Dget_space"); - space2_id = H5Dget_space(dset2_id); - CHECK_I(space2_id, "H5Dget_space"); - space3_id = H5Dget_space(dset3_id); - CHECK_I(space3_id, "H5Dget_space"); - - /* Verify the dataspaces */ - ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims1[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims1[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - /* Close all three dataspaces */ - ret = H5Sclose(space1_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space2_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space3_id); - CHECK_I(ret, "H5Sclose"); + space_dims[0] = dims2; + space_dims[1] = dims1; + space_dims[2] = dims1; + TSOHM_VDE_VERIFY_SPACES(space_dims); /* Extend the second dataset */ ret = H5Dset_extent(dset2_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset3_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); - CHECK_I(dset3_id, "H5Dopen2"); - } - - /* Get the dataspaces from the datasets */ - space1_id = H5Dget_space(dset1_id); - CHECK_I(space1_id, "H5Dget_space"); - space2_id = H5Dget_space(dset2_id); - CHECK_I(space2_id, "H5Dget_space"); - space3_id = H5Dget_space(dset3_id); - CHECK_I(space3_id, "H5Dget_space"); - - /* Verify the dataspaces */ - ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } + if(close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); - ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims1[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - /* Close all three dataspaces */ - ret = H5Sclose(space1_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space2_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space3_id); - CHECK_I(ret, "H5Sclose"); + space_dims[1] = dims2; + TSOHM_VDE_VERIFY_SPACES(space_dims); /* Extend the third dataset */ ret = H5Dset_extent(dset3_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset3_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); - CHECK_I(dset3_id, "H5Dopen2"); - } - - /* Get the dataspaces from the datasets */ - space1_id = H5Dget_space(dset1_id); - CHECK_I(space1_id, "H5Dget_space"); - space2_id = H5Dget_space(dset2_id); - CHECK_I(space2_id, "H5Dget_space"); - space3_id = H5Dget_space(dset3_id); - CHECK_I(space3_id, "H5Dget_space"); - - /* Verify the dataspaces */ - ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } + if(close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); - /* Close all three dataspaces */ - ret = H5Sclose(space1_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space2_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space3_id); - CHECK_I(ret, "H5Sclose"); + space_dims[2] = dims2; + TSOHM_VDE_VERIFY_SPACES(space_dims); /* Close the datasets and file */ ret = H5Dclose(dset1_id); @@ -3523,164 +3511,44 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen) CHECK_I(file_id, "H5Fcreate"); dset1_id = H5Dcreate2(file_id, "dataset", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset1_id, "H5Dcreate2"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(1); /* Extend the first dataset */ ret = H5Dset_extent(dset1_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(1); /* Create the second dataset. Its dataspace will be unshared and then * become shared when extended. */ dset2_id = H5Dcreate2(file_id, "dataset2", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset2_id, "H5Dcreate2"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(2); /* Extend the second dataset */ ret = H5Dset_extent(dset2_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - } + if (close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(2); /* Create the third dataset. Its dataspace will be unshared and then * become shared when extended. */ dset3_id = H5Dcreate2(file_id, "dataset3", H5T_NATIVE_LONG, orig_space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); CHECK_I(dset3_id, "H5Dcreate2"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset3_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); - CHECK_I(dset3_id, "H5Dopen2"); - } + if(close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); /* Extend the third dataset */ ret = H5Dset_extent(dset3_id, dims2); CHECK_I(ret, "H5Dset_extent"); - if(close_reopen) { - /* If requested, close all open IDs and reopen them */ - ret = H5Dclose(dset1_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset2_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Dclose(dset3_id); - CHECK_I(ret, "H5Dclose"); - ret = H5Fclose(file_id); - CHECK_I(ret, "H5Fclose"); - - file_id = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT); - CHECK_I(file_id, "H5Fopen"); - dset1_id = H5Dopen2(file_id, "dataset", H5P_DEFAULT); - CHECK_I(dset1_id, "H5Dopen2"); - dset2_id = H5Dopen2(file_id, "dataset2", H5P_DEFAULT); - CHECK_I(dset2_id, "H5Dopen2"); - dset3_id = H5Dopen2(file_id, "dataset3", H5P_DEFAULT); - CHECK_I(dset3_id, "H5Dopen2"); - } + if(close_reopen) + TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS(3); - /* Get the dataspaces from the datasets */ - space1_id = H5Dget_space(dset1_id); - CHECK_I(space1_id, "H5Dget_space"); - space2_id = H5Dget_space(dset2_id); - CHECK_I(space2_id, "H5Dget_space"); - space3_id = H5Dget_space(dset3_id); - CHECK_I(space3_id, "H5Dget_space"); - - /* Verify the dataspaces */ - ret = H5Sget_simple_extent_dims(space1_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space2_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - ret = H5Sget_simple_extent_dims(space3_id, out_dims, out_maxdims); - CHECK_I(ret, "H5Sget_simple_extent_dims"); - for(x=0; x<EXTEND_NDIMS; ++x) { - VERIFY(out_dims[x], dims2[x], "H5Sget_simple_extent_dims"); - VERIFY(out_maxdims[x], max_dims[x], "H5Sget_simple_extent_dims"); - } - - /* Close all three dataspaces */ - ret = H5Sclose(space1_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space2_id); - CHECK_I(ret, "H5Sclose"); - ret = H5Sclose(space3_id); - CHECK_I(ret, "H5Sclose"); + TSOHM_VDE_VERIFY_SPACES(space_dims); /* Close the datasets and file */ ret = H5Dclose(dset1_id); @@ -3698,12 +3566,15 @@ test_sohm_extend_dset_helper(hid_t fcpl_id, hbool_t close_reopen) ret = H5Pclose(dcpl_id); CHECK_I(ret, "H5Pclose"); - /* Retrieve current # of errors */ + /* Complain if this test generated errors */ if(old_nerrs == GetTestNumErrs()) return(0); else return(-1); -} /* end test_sohm_extend_dset_helper() */ +/* macros are exclusive to this function */ +#undef TSOHM_VDE_CLOSE_REOPEN_FILE_AND_DSETS +#undef TSOHM_VDE_VERIFY_SPACES +} /* verify_dataset_extension */ /*------------------------------------------------------------------------- @@ -3726,74 +3597,71 @@ test_sohm_extend_dset(void) hid_t fcpl_id = -1; herr_t ret; - /* Create fcpl */ + MESSAGE(5, ("Testing extending shared dataspaces\n")); + fcpl_id = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl_id, "H5Pcreate"); - - /* Test extending datasets with different FCPLs */ ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); /* No shared messages */ - ret = test_sohm_extend_dset_helper(fcpl_id, FALSE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); - ret = test_sohm_extend_dset_helper(fcpl_id, TRUE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); + ret = verify_dataset_extension(fcpl_id, FALSE); + CHECK_I(ret, "verify_dataset_extension"); + ret = verify_dataset_extension(fcpl_id, TRUE); + CHECK_I(ret, "verify_dataset_extension"); /* Only dataspaces */ ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_SDSPACE_FLAG, 16); CHECK_I(ret, "H5Pset_shared_mesg_index"); - ret = test_sohm_extend_dset_helper(fcpl_id, FALSE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); - ret = test_sohm_extend_dset_helper(fcpl_id, TRUE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); + ret = verify_dataset_extension(fcpl_id, FALSE); + CHECK_I(ret, "verify_dataset_extension"); + ret = verify_dataset_extension(fcpl_id, TRUE); + CHECK_I(ret, "verify_dataset_extension"); /* All messages */ - ret = H5Pset_shared_mesg_nindexes(fcpl_id, 1); - CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); ret = H5Pset_shared_mesg_index(fcpl_id, 0, H5O_SHMESG_ALL_FLAG, 16); CHECK_I(ret, "H5Pset_shared_mesg_index"); - ret = test_sohm_extend_dset_helper(fcpl_id, FALSE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); - ret = test_sohm_extend_dset_helper(fcpl_id, TRUE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); + ret = verify_dataset_extension(fcpl_id, FALSE); + CHECK_I(ret, "verify_dataset_extension"); + ret = verify_dataset_extension(fcpl_id, TRUE); + CHECK_I(ret, "verify_dataset_extension"); /* All messages in lists */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 100, 50); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_extend_dset_helper(fcpl_id, FALSE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); - ret = test_sohm_extend_dset_helper(fcpl_id, TRUE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); + ret = verify_dataset_extension(fcpl_id, FALSE); + CHECK_I(ret, "verify_dataset_extension"); + ret = verify_dataset_extension(fcpl_id, TRUE); + CHECK_I(ret, "verify_dataset_extension"); /* All messages in lists converted to B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 1, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_extend_dset_helper(fcpl_id, FALSE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); - ret = test_sohm_extend_dset_helper(fcpl_id, TRUE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); + ret = verify_dataset_extension(fcpl_id, FALSE); + CHECK_I(ret, "verify_dataset_extension"); + ret = verify_dataset_extension(fcpl_id, TRUE); + CHECK_I(ret, "verify_dataset_extension"); /* All messages in B-trees */ ret = H5Pset_shared_mesg_phase_change(fcpl_id, 0, 0); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - ret = test_sohm_extend_dset_helper(fcpl_id, FALSE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); - ret = test_sohm_extend_dset_helper(fcpl_id, TRUE); - CHECK_I(ret, "test_sohm_extend_dset_helper"); + ret = verify_dataset_extension(fcpl_id, FALSE); + CHECK_I(ret, "verify_dataset_extension"); + ret = verify_dataset_extension(fcpl_id, TRUE); + CHECK_I(ret, "verify_dataset_extension"); ret = H5Pclose(fcpl_id); CHECK_I(ret, "H5Pclose"); -} +} /* test_sohm_extend_dset */ /*------------------------------------------------------------------------- @@ -3827,37 +3695,31 @@ test_sohm_external_dtype(void) unsigned x, i; herr_t ret; + MESSAGE(5, ("Testing shared external datatype\n")); + fcpl = H5Pcreate(H5P_FILE_CREATE); CHECK_I(fcpl, "H5Pcreate"); - - /* Set up index values for sohm */ ret = H5Pset_shared_mesg_nindexes(fcpl, TEST_NUM_INDEXES); CHECK_I(ret, "H5Pset_shared_mesg_nindexes"); - - for(x=0; x<TEST_NUM_INDEXES; ++x) - { + for(x=0; x<TEST_NUM_INDEXES; ++x) { ret = H5Pset_shared_mesg_index(fcpl, x, test_type_flags[x], test_minsizes[x]); CHECK_I(ret, "H5Pset_shared_mesg_index"); } - ret = H5Pset_shared_mesg_phase_change(fcpl, TEST_L2B, TEST_B2L); CHECK_I(ret, "H5Pset_shared_mesg_phase_change"); - /* Create the data space */ space = H5Screate_simple(2, dims, NULL); CHECK_I(space, "H5Screate_simple"); - /* Create a data type for s1_t */ s1_tid = H5Tcreate(H5T_COMPOUND, sizeof(s1_t)); CHECK_I(s1_tid, "H5Tcreate"); - ret = H5Tinsert(s1_tid, "a", HOFFSET(s1_t,a), H5T_NATIVE_INT); CHECK_I(ret, "H5Tinsert"); - ret = H5Tinsert (s1_tid, "b", HOFFSET(s1_t,b), H5T_NATIVE_INT); CHECK_I(ret, "H5Tinsert"); - /* Create the first file for this test */ + /* Set up dataset in first file + */ file1 = H5Fcreate(FILENAME_SRC, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); CHECK_I(file1, "H5Fcreate"); @@ -3866,7 +3728,6 @@ test_sohm_external_dtype(void) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(dmsg_count, 0, "H5F__get_sohm_mesg_count_test"); - /* Create data set */ dataset1 = H5Dcreate2(file1, "dataset_1", s1_tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK_I(dataset1, "H5Dcreate2"); @@ -3876,26 +3737,26 @@ test_sohm_external_dtype(void) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(dmsg_count, 1, "H5F__get_sohm_mesg_count_test"); - /* Retieve the dataset's datatype */ dset1_tid = H5Dget_type(dataset1); CHECK_I(dset1_tid, "H5Dget_type"); /* Allocate space and initialize data */ orig = (s1_t*)HDmalloc(NX * NY * sizeof(s1_t)); + if (orig == NULL) + CHECK_I(-1, "HDmalloc"); for(i=0; i<NX*NY; i++) { s_ptr = (s1_t*)orig + i; s_ptr->a = (int)(i * 3 + 1); s_ptr->b = (int)(i * 3 + 2); } - /* Write the data to the dataset1 */ ret = H5Dwrite(dataset1, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig); CHECK_I(ret, "H5Dwrite"); - ret = H5Dclose(dataset1); CHECK_I(ret, "H5Dclose"); - /* Create the second file for this test */ + /* Create dataset in second file using datatype from dataset in the first file + */ file2 = H5Fcreate(FILENAME_DST, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); CHECK_I(file2, "H5Fcreate"); @@ -3904,7 +3765,6 @@ test_sohm_external_dtype(void) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(dmsg_count, 0, "H5F__get_sohm_mesg_count_test"); - /* Create a data set using the datatype of the dataset in the first file. */ dataset2 = H5Dcreate2(file2, "dataset_2", dset1_tid, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK_I(dataset2, "H5Dcreate2"); @@ -3914,54 +3774,44 @@ test_sohm_external_dtype(void) CHECK(ret, FAIL, "H5F__get_sohm_mesg_count_test"); VERIFY(dmsg_count, 1, "H5F__get_sohm_mesg_count_test"); - /* Write the data to the dataset2 */ ret = H5Dwrite(dataset2, s1_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, orig); CHECK_I(ret, "H5Dwrite"); + /* Close references to the first file */ ret = H5Dclose(dataset2); CHECK_I(ret, "H5Dclose"); - - /* Close file 1 and the dataset's datatype in file 1. Verify that the datatype in - * file 2 is still accessible. */ ret = H5Tclose(dset1_tid); CHECK_I(ret, "H5Tclose"); - ret = H5Fclose(file1); CHECK_I(ret, "H5Fclose"); - /* Open the dataset in file 2 */ + /* Verify that datatype details are still accessible by second file + */ dataset2 = H5Dopen2(file2, "dataset_2", H5P_DEFAULT); CHECK_I(dataset2, "H5Dopen2"); - /* Retieve the dataset's datatype */ dset2_tid = H5Dget_type(dataset2); CHECK_I(dset2_tid, "H5Dget_type"); - /* Verify the datatype is compound */ dtype_class = H5Tget_class(dset2_tid); VERIFY(dtype_class, H5T_COMPOUND, "H5Tget_class"); + /* Cleanup + */ ret = H5Tclose(dset2_tid); CHECK_I(ret, "H5Tclose"); - ret = H5Dclose(dataset2); CHECK_I(ret, "H5Dclose"); - - /* Finishing test and release resources */ ret = H5Sclose(space); CHECK_I(ret, "H5Sclose"); - ret = H5Tclose(s1_tid); CHECK_I(ret, "H5Tclose"); - ret = H5Pclose(fcpl); CHECK_I(ret, "H5Pclose"); - ret = H5Fclose(file2); CHECK_I(ret, "H5Fclose"); - HDfree(orig); -} +} /* test_sohm_external_dtype */ /**************************************************************** @@ -3972,11 +3822,14 @@ test_sohm_external_dtype(void) void test_sohm(void) { - /* Output message about test being performed */ MESSAGE(5, ("Testing Shared Object Header Messages\n")); - test_sohm_fcpl(); /* Test SOHMs and file creation plists */ + test_sohm_fcpl(); /* Test SOHMs and file creation plists */ + test_sohm_fcpl_errors(); /* Bogus H5P* calls for SOHMs */ test_sohm_size1(); /* Tests the sizes of files with one SOHM */ +#if 0 /* TODO: REVEALS BUG TO BE FIXED - SEE JIRA HDFFV-10645 */ + test_sohm_size_consistency_open_create(); +#endif /* Jira HDFFV-10645 */ test_sohm_attrs(); /* Tests shared messages in attributes */ test_sohm_size2(0); /* Tests the sizes of files with multiple SOHMs */ test_sohm_size2(1); /* Tests the sizes of files with multiple @@ -3989,17 +3842,17 @@ test_sohm(void) test_sohm_extend_dset(); /* Test extending shared datasets */ test_sohm_external_dtype(); /* Test using datatype in another file */ -} /* test_sohm() */ +} /* test_sohm */ /*------------------------------------------------------------------------- - * Function: cleanup_sohm + * Function: cleanup_sohm * - * Purpose: Cleanup temporary test files + * Purpose: Cleanup temporary test files * - * Return: none + * Return: none * - * Programmer: James Laird + * Programmer: James Laird * October 9, 2006 * * Modifications: @@ -4012,5 +3865,5 @@ cleanup_sohm(void) remove(FILENAME); remove(FILENAME_SRC); remove(FILENAME_DST); -} +} /* cleanup_sohm */ diff --git a/test/vol_plugin.c b/test/vol_plugin.c new file mode 100644 index 0000000..236a67e --- /dev/null +++ b/test/vol_plugin.c @@ -0,0 +1,291 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Tests basic VOL plugin operations (registration, etc.). + * Uses the null VOL connector (built with the testing code) + * which is loaded as a dynamic plugin. + * + * TO DO: Adapt the null VOL connector to do something interesting with + * the property list. + */ + +#include "h5test.h" + +#include "null_vol_connector.h" + + +/*------------------------------------------------------------------------- + * Function: test_registration_by_value() + * + * Purpose: Tests if we can load, register, and close a VOL + * connector by value. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_registration_by_value(void) +{ + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + + TESTING("VOL registration by value"); + + /* The null VOL connector should not be registered at the start of the test */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector by value */ + if((vol_id = H5VLregister_connector_by_value(NULL_VOL_CONNECTOR_VALUE, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* The connector should be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector was not registered"); + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + /* The connector should not be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5VLunregister_connector(vol_id); + } H5E_END_TRY; + return FAIL; + +} /* end test_registration_by_value() */ + + +/*------------------------------------------------------------------------- + * Function: test_registration_by_name() + * + * Purpose: Tests if we can load, register, and close a VOL + * connector by name. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_registration_by_name(void) +{ + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + + TESTING("VOL registration by name"); + + /* The null VOL connector should not be registered at the start of the test */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector by name */ + if((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* The connector should be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector was not registered"); + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + /* The connector should not be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5VLunregister_connector(vol_id); + } H5E_END_TRY; + return FAIL; + +} /* end test_registration_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: test_multiple_registration() + * + * Purpose: Tests if we can register a VOL connector multiple times. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +#define N_REGISTRATIONS 10 +static herr_t +test_multiple_registration(void) +{ + htri_t is_registered = FAIL; + hid_t vol_ids[N_REGISTRATIONS]; + int i; + + TESTING("registering a VOL connector multiple times"); + + /* The null VOL connector should not be registered at the start of the test */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector multiple times */ + for(i = 0; i < N_REGISTRATIONS; i++) { + if((vol_ids[i] = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + } + + /* The connector should be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(FALSE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector was not registered"); + + /* Unregister the connector */ + for(i = 0; i < N_REGISTRATIONS; i++) { + if(H5VLunregister_connector(vol_ids[i]) < 0) + TEST_ERROR; + /* Also test close on some of the IDs. This call currently works + * identically to unregister. + */ + i++; + if(H5VLclose(vol_ids[i]) < 0) + TEST_ERROR; + } + + /* The connector should not be registered now */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + for(i = 0; i < N_REGISTRATIONS; i++) + H5VLunregister_connector(vol_ids[i]); + } H5E_END_TRY; + return FAIL; + +} /* end test_multiple_registration() */ + + +/*------------------------------------------------------------------------- + * Function: test_getters() + * + * Purpose: Tests H5VL getters + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +test_getters(void) +{ + htri_t is_registered = FAIL; + hid_t vol_id = H5I_INVALID_HID; + hid_t vol_id_out = H5I_INVALID_HID; + + TESTING("VOL getters"); + + /* The null VOL connector should not be registered at the start of the test */ + if((is_registered = H5VLis_connector_registered(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(TRUE == is_registered) + FAIL_PUTS_ERROR("NULL VOL connector is inappropriately registered"); + + /* Register the connector by name */ + if((vol_id = H5VLregister_connector_by_name(NULL_VOL_CONNECTOR_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Get the connector's ID */ + if((vol_id_out = H5VLget_connector_id(NULL_VOL_CONNECTOR_NAME)) < 0) + TEST_ERROR; + if(vol_id != vol_id_out) + FAIL_PUTS_ERROR("VOL connector IDs don't match"); + + /* Unregister the connector */ + if(H5VLunregister_connector(vol_id) < 0) + TEST_ERROR; + + PASSED(); + return SUCCEED; + +error: + H5E_BEGIN_TRY { + H5VLunregister_connector(vol_id); + } H5E_END_TRY; + return FAIL; + +} /* end test_getters() */ + + +/*------------------------------------------------------------------------- + * Function: main + * + * Purpose: Tests VOL connector plugin operations + * + * Return: EXIT_SUCCESS/EXIT_FAILURE + * + *------------------------------------------------------------------------- + */ +int +main(void) +{ + int nerrors = 0; + + h5_reset(); + + HDputs("Testing VOL connector plugin functionality."); + + nerrors += test_registration_by_name() < 0 ? 1 : 0; + nerrors += test_registration_by_value() < 0 ? 1 : 0; + nerrors += test_multiple_registration() < 0 ? 1 : 0; + nerrors += test_getters() < 0 ? 1 : 0; + + if(nerrors) { + HDprintf("***** %d VOL connector plugin TEST%s FAILED! *****\n", + nerrors, nerrors > 1 ? "S" : ""); + HDexit(EXIT_FAILURE); + } + + HDputs("All VOL connector plugin tests passed."); + + HDexit(EXIT_SUCCESS); + +} /* end main() */ + diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index dffb813..a0d7f59 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -22,9 +22,9 @@ foreach (testp ${H5P_TESTS}) add_test (NAME TEST_PAR_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:${testp}> ${MPIEXEC_POSTFLAGS}) endforeach () -# The following will only be correct on windows shared -#set_tests_properties (TEST_PAR_t_pflush1 PROPERTIES WILL_FAIL "true") -set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") +# The t_pflush1 test is hard-coded to fail. +set_tests_properties (TEST_PAR_t_pflush1 PROPERTIES WILL_FAIL "true") +#set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") set_tests_properties (TEST_PAR_t_pflush2 PROPERTIES DEPENDS TEST_PAR_t_pflush1) ############################################################################## diff --git a/testpar/Makefile.am b/testpar/Makefile.am index 7262ca6..a11099d 100644 --- a/testpar/Makefile.am +++ b/testpar/Makefile.am @@ -21,11 +21,19 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test +# Test scripts-- +# testpflush.sh: +TEST_SCRIPT_PARA = testpflush.sh +SCRIPT_DEPEND = t_pflush1$(EXEEXT) t_pflush2$(EXEEXT) + +check_SCRIPTS = $(TEST_SCRIPT_PARA) + # Test programs. These are our main targets. # -TEST_PROG_PARA=t_mpi t_bigio testphdf5 t_cache t_cache_image t_pflush1 t_pflush2 t_pread t_pshutdown t_prestart t_init_term t_shapesame t_filters_parallel +TEST_PROG_PARA=t_mpi t_bigio testphdf5 t_cache t_cache_image t_pread t_pshutdown t_prestart t_init_term t_shapesame t_filters_parallel -check_PROGRAMS = $(TEST_PROG_PARA) +# t_pflush1 and t_pflush2 are used by testpflush.sh +check_PROGRAMS = $(TEST_PROG_PARA) t_pflush1 t_pflush2 testphdf5_SOURCES=testphdf5.c t_dset.c t_file.c t_file_image.c t_mdset.c \ t_ph5basic.c t_coll_chunk.c t_span_tree.c t_chunk_alloc.c t_filter_read.c \ diff --git a/testpar/t_cache.c b/testpar/t_cache.c index da83884..7488728 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -467,9 +467,7 @@ static void lock_and_unlock_random_entry(H5F_t * file_ptr, static void lock_entry(H5F_t * file_ptr, int32_t idx); static void mark_entry_dirty(int32_t idx); static void pin_entry(H5F_t * file_ptr, int32_t idx, hbool_t global, hbool_t dirty); -#ifdef H5_METADATA_TRACE_FILE static void pin_protected_entry(int32_t idx, hbool_t global); -#endif /* H5_METADATA_TRACE_FILE */ static void move_entry(H5F_t * file_ptr, int32_t old_idx, int32_t new_idx); static hbool_t reset_server_counts(void); static void resize_entry(int32_t idx, size_t new_size); @@ -3693,7 +3691,6 @@ pin_entry(H5F_t * file_ptr, } /* pin_entry() */ -#ifdef H5_METADATA_TRACE_FILE /***************************************************************************** * Function: pin_protected_entry() @@ -3762,7 +3759,6 @@ pin_protected_entry(int32_t idx, return; } /* pin_protected_entry() */ -#endif /* H5_METADATA_TRACE_FILE */ /***************************************************************************** @@ -6809,8 +6805,6 @@ smoke_check_5(int metadata_write_strategy) * - H5AC_expunge_entry() * - H5AC_resize_entry() * - * This test is skipped if H5_METADATA_TRACE_FILE is undefined. - * * Return: Success: TRUE * * Failure: FALSE @@ -6823,63 +6817,63 @@ trace_file_check(int metadata_write_strategy) { hbool_t success = TRUE; -#ifdef H5_METADATA_TRACE_FILE - const char *((* expected_output)[]) = NULL; const char * expected_output_0[] = { "### HDF5 metadata cache trace file version 1 ###\n", - "H5AC_set_cache_auto_resize_config 1 0 1 0 \"t_cache_trace.txt\" 1 0 2097152 0.300000 33554432 1048576 50000 1 0.900000 2.000000 1 1.000000 0.250000 1 4194304 3 0.999000 0.900000 1 1048576 3 1 0.100000 262144 0 0\n", - "H5AC_insert_entry 0x400 27 0x0 2 0\n", - "H5AC_insert_entry 0x402 27 0x0 2 0\n", - "H5AC_insert_entry 0x404 27 0x0 4 0\n", - "H5AC_insert_entry 0x408 27 0x0 6 0\n", - "H5AC_protect 0x400 27 0x0 2 1\n", - "H5AC_mark_entry_dirty 0x400 0\n", - "H5AC_unprotect 0x400 27 0x0 0\n", - "H5AC_protect 0x402 27 0x0 2 1\n", - "H5AC_pin_protected_entry 0x402 0\n", - "H5AC_unprotect 0x402 27 0x0 0\n", - "H5AC_unpin_entry 0x402 0\n", - "H5AC_expunge_entry 0x402 27 0\n", - "H5AC_protect 0x404 27 0x0 4 1\n", - "H5AC_pin_protected_entry 0x404 0\n", - "H5AC_unprotect 0x404 27 0x0 0\n", - "H5AC_mark_entry_dirty 0x404 0\n", - "H5AC_resize_entry 0x404 2 0\n", - "H5AC_resize_entry 0x404 4 0\n", - "H5AC_unpin_entry 0x404 0\n", - "H5AC_move_entry 0x400 0x8e65 27 0\n", - "H5AC_move_entry 0x8e65 0x400 27 0\n", - "H5AC_flush 0\n", + "H5AC_set_cache_auto_resize_config", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_protect", + "H5AC_mark_entry_dirty", + "H5AC_unprotect", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_unpin_entry", + "H5AC_expunge_entry", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_mark_entry_dirty", + "H5AC_resize_entry", + "H5AC_resize_entry", + "H5AC_unpin_entry", + "H5AC_move_entry", + "H5AC_move_entry", + "H5AC_flush", + "H5AC_flush", NULL }; const char * expected_output_1[] = { "### HDF5 metadata cache trace file version 1 ###\n", - "H5AC_set_cache_auto_resize_config 1 0 1 0 \"t_cache_trace.txt\" 1 0 2097152 0.300000 33554432 1048576 50000 1 0.900000 2.000000 1 1.000000 0.250000 1 4194304 3 0.999000 0.900000 1 1048576 3 1 0.100000 262144 1 0\n", - "H5AC_insert_entry 0x400 27 0x0 2 0\n", - "H5AC_insert_entry 0x402 27 0x0 2 0\n", - "H5AC_insert_entry 0x404 27 0x0 4 0\n", - "H5AC_insert_entry 0x408 27 0x0 6 0\n", - "H5AC_protect 0x400 27 0x0 2 1\n", - "H5AC_mark_entry_dirty 0x400 0\n", - "H5AC_unprotect 0x400 27 0x0 0\n", - "H5AC_protect 0x402 27 0x0 2 1\n", - "H5AC_pin_protected_entry 0x402 0\n", - "H5AC_unprotect 0x402 27 0x0 0\n", - "H5AC_unpin_entry 0x402 0\n", - "H5AC_expunge_entry 0x402 27 0\n", - "H5AC_protect 0x404 27 0x0 4 1\n", - "H5AC_pin_protected_entry 0x404 0\n", - "H5AC_unprotect 0x404 27 0x0 0\n", - "H5AC_mark_entry_dirty 0x404 0\n", - "H5AC_resize_entry 0x404 2 0\n", - "H5AC_resize_entry 0x404 4 0\n", - "H5AC_unpin_entry 0x404 0\n", - "H5AC_move_entry 0x400 0x8e65 27 0\n", - "H5AC_move_entry 0x8e65 0x400 27 0\n", - "H5AC_flush 0\n", + "H5AC_set_cache_auto_resize_config", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_insert_entry", + "H5AC_protect", + "H5AC_mark_entry_dirty", + "H5AC_unprotect", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_unpin_entry", + "H5AC_expunge_entry", + "H5AC_protect", + "H5AC_pin_protected_entry", + "H5AC_unprotect", + "H5AC_mark_entry_dirty", + "H5AC_resize_entry", + "H5AC_resize_entry", + "H5AC_unpin_entry", + "H5AC_move_entry", + "H5AC_move_entry", + "H5AC_flush", + "H5AC_flush", NULL }; char buffer[256]; @@ -6887,8 +6881,8 @@ trace_file_check(int metadata_write_strategy) hbool_t done = FALSE; int i; int max_nerrors; - int expected_line_len; - int actual_line_len; + size_t expected_line_len; + size_t actual_line_len; hid_t fid = -1; H5F_t * file_ptr = NULL; H5C_t * cache_ptr = NULL; @@ -6896,188 +6890,151 @@ trace_file_check(int metadata_write_strategy) H5AC_cache_config_t config; struct mssg_t mssg; -#endif /* H5_METADATA_TRACE_FILE */ - switch ( metadata_write_strategy ) { + switch(metadata_write_strategy) { + + case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: - case H5AC_METADATA_WRITE_STRATEGY__PROCESS_0_ONLY: -#ifdef H5_METADATA_TRACE_FILE expected_output = &expected_output_0; -#endif /* H5_METADATA_TRACE_FILE */ - if ( world_mpi_rank == 0 ) { - TESTING( - "trace file collection -- process 0 only md write strategy"); - } - break; - case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: -#ifdef H5_METADATA_TRACE_FILE + if(world_mpi_rank == 0) + TESTING("trace file collection -- process 0 only md write strategy"); + break; + + case H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED: + expected_output = &expected_output_1; -#endif /* H5_METADATA_TRACE_FILE */ - if ( world_mpi_rank == 0 ) { - TESTING( - "trace file collection -- distributed md write strategy"); - } - break; + + if(world_mpi_rank == 0) + TESTING("trace file collection -- distributed md write strategy"); + break; default: -#ifdef H5_METADATA_TRACE_FILE + /* this will almost certainly cause a failure, but it keeps us * from de-referenceing a NULL pointer. */ expected_output = &expected_output_0; -#endif /* H5_METADATA_TRACE_FILE */ - if ( world_mpi_rank == 0 ) { - TESTING("trace file collection -- unknown md write strategy"); - } - break; - } -#ifdef H5_METADATA_TRACE_FILE + if(world_mpi_rank == 0) + TESTING("trace file collection -- unknown md write strategy"); + break; + } /* end switch */ + nerrors = 0; init_data(); reset_stats(); - if ( world_mpi_rank == world_server_mpi_rank ) { + if(world_mpi_rank == world_server_mpi_rank) { - if ( ! server_main() ) { + if(!server_main()) { /* some error occured in the server -- report failure */ nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", - world_mpi_rank, FUNC); - } + if ( verbose ) + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } - else /* run the clients */ - { + else { + /* run the clients */ - if ( ! setup_cache_for_test(&fid, &file_ptr, &cache_ptr, - metadata_write_strategy) ) { + if(!setup_cache_for_test(&fid, &file_ptr, &cache_ptr, metadata_write_strategy) ) { nerrors++; fid = -1; cache_ptr = NULL; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", - world_mpi_rank, FUNC); - } + if(verbose) + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } - if ( nerrors == 0 ) { + if(nerrors == 0) { config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if ( H5AC_get_cache_auto_resize_config(cache_ptr, &config) - != SUCCEED ) { - - nerrors++; - HDfprintf(stdout, - "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", - world_mpi_rank, FUNC); - - } else { - + if(H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + nerrors++; + HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); + } + else { config.open_trace_file = TRUE; - strcpy(config.trace_file_name, "t_cache_trace.txt"); + strcpy(config.trace_file_name, "t_cache_trace.txt"); - if ( H5AC_set_cache_auto_resize_config(cache_ptr, &config) - != SUCCEED ) { - - nerrors++; - HDfprintf(stdout, - "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", - world_mpi_rank, FUNC); + if(H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + nerrors++; + HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); } } - } + } /* end if */ - insert_entry(cache_ptr, file_ptr, 0, H5AC__NO_FLAGS_SET); - insert_entry(cache_ptr, file_ptr, 1, H5AC__NO_FLAGS_SET); - insert_entry(cache_ptr, file_ptr, 2, H5AC__NO_FLAGS_SET); - insert_entry(cache_ptr, file_ptr, 3, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 0, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 1, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 2, H5AC__NO_FLAGS_SET); + insert_entry(cache_ptr, file_ptr, 3, H5AC__NO_FLAGS_SET); - lock_entry(file_ptr, 0); - mark_entry_dirty(0); - unlock_entry(file_ptr, 0, H5AC__NO_FLAGS_SET); + lock_entry(file_ptr, 0); + mark_entry_dirty(0); + unlock_entry(file_ptr, 0, H5AC__NO_FLAGS_SET); - lock_entry(file_ptr, 1); + lock_entry(file_ptr, 1); pin_protected_entry(1, TRUE); - unlock_entry(file_ptr, 1, H5AC__NO_FLAGS_SET); + unlock_entry(file_ptr, 1, H5AC__NO_FLAGS_SET); unpin_entry(file_ptr, 1, TRUE, FALSE, FALSE); expunge_entry(file_ptr, 1); - lock_entry(file_ptr, 2); + lock_entry(file_ptr, 2); pin_protected_entry(2, TRUE); - unlock_entry(file_ptr, 2, H5AC__NO_FLAGS_SET); - mark_entry_dirty(2); + unlock_entry(file_ptr, 2, H5AC__NO_FLAGS_SET); + mark_entry_dirty(2); resize_entry(2, data[2].len / 2); resize_entry(2, data[2].len); unpin_entry(file_ptr, 2, TRUE, FALSE, FALSE); - move_entry(file_ptr, 0, 20); - move_entry(file_ptr, 0, 20); + move_entry(file_ptr, 0, 20); + move_entry(file_ptr, 0, 20); - if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { + if(H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", - world_mpi_rank, FUNC); - } + if(verbose) + HDfprintf(stdout, "%d:%s: H5Fflush() failed.\n", world_mpi_rank, FUNC); } - if ( nerrors == 0 ) { - + if(nerrors == 0) { config.version = H5AC__CURR_CACHE_CONFIG_VERSION; - if ( H5AC_get_cache_auto_resize_config(cache_ptr, &config) - != SUCCEED ) { - - nerrors++; - HDfprintf(stdout, - "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", - world_mpi_rank, FUNC); - - } else { - + if(H5AC_get_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + nerrors++; + HDfprintf(stdout, "%d:%s: H5AC_get_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); + } + else { config.open_trace_file = FALSE; config.close_trace_file = TRUE; - config.trace_file_name[0] = '\0'; + config.trace_file_name[0] = '\0'; - if ( H5AC_set_cache_auto_resize_config(cache_ptr, &config) - != SUCCEED ) { - - nerrors++; - HDfprintf(stdout, - "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", - world_mpi_rank, FUNC); + if(H5AC_set_cache_auto_resize_config(cache_ptr, &config) != SUCCEED) { + nerrors++; + HDfprintf(stdout, "%d:%s: H5AC_set_cache_auto_resize_config() failed.\n", world_mpi_rank, FUNC); } } - } - - if ( fid >= 0 ) { + } /* end if */ - if ( ! take_down_cache(fid, cache_ptr) ) { + if(fid >= 0) { + if(!take_down_cache(fid, cache_ptr)) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", - world_mpi_rank, FUNC); - } + if(verbose) + HDfprintf(stdout, "%d:%s: take_down_cache() failed.\n", world_mpi_rank, FUNC); } - } + } /* end if */ /* verify that all instance of datum are back where the started * and are clean. */ - for ( i = 0; i < NUM_DATA_ENTRIES; i++ ) - { - HDassert( data_index[i] == i ); - HDassert( ! (data[i].dirty) ); + for(i = 0; i < NUM_DATA_ENTRIES; i++) { + HDassert(data_index[i] == i); + HDassert(!(data[i].dirty)); } /* compose the done message */ @@ -7091,117 +7048,121 @@ trace_file_check(int metadata_write_strategy) mssg.count = 0; /* not used */ mssg.magic = MSSG_MAGIC; - if ( success ) { - + if(success) { success = send_mssg(&mssg, FALSE); - if ( ! success ) { - + if(!success) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", - world_mpi_rank, FUNC); - } + if(verbose) + HDfprintf(stdout, "%d:%s: send_mssg() failed on done.\n", world_mpi_rank, FUNC); } - } + } /* end if */ - if ( nerrors == 0 ) { + if(nerrors == 0) { + HDsprintf(trace_file_name, "t_cache_trace.txt.%d", (int)file_mpi_rank); - sprintf(trace_file_name, "t_cache_trace.txt.%d", - (int)file_mpi_rank); - - if ( (trace_file_ptr = HDfopen(trace_file_name, "r")) == NULL ) { + if((trace_file_ptr = HDfopen(trace_file_name, "r")) == NULL ) { nerrors++; - if ( verbose ) { - HDfprintf(stdout, "%d:%s: HDfopen failed.\n", - world_mpi_rank, FUNC); - } + if(verbose) + HDfprintf(stdout, "%d:%s: HDfopen failed.\n", world_mpi_rank, FUNC); } - } - - i = 0; - while ( ( nerrors == 0 ) && ( ! done ) ) - { - if ( (*expected_output)[i] == NULL ) { - - expected_line_len = 0; - - } else { - - expected_line_len = HDstrlen((*expected_output)[i]); - } + } /* end if */ - if ( HDfgets(buffer, 255, trace_file_ptr) != NULL ) { - actual_line_len = HDstrlen(buffer); - - } else { - - actual_line_len = 0; - } + i = 0; + while((nerrors == 0) && (!done)) { + /* Get lines of actual and expected data */ + if((*expected_output)[i] == NULL) + expected_line_len = (size_t)0; + else + expected_line_len = HDstrlen((*expected_output)[i]); + + if(HDfgets(buffer, 255, trace_file_ptr) != NULL) + actual_line_len = HDstrlen(buffer); + else + actual_line_len = (size_t)0; + + /* Compare the lines */ + /* Handle running out of data */ + if((actual_line_len == 0) || (expected_line_len == 0)) { + if((actual_line_len == 0) && (expected_line_len == 0)) { + /* Both ran out at the same time - we're done */ + done = TRUE; + } + else { + /* One ran out before the other - BADNESS */ + nerrors++; + if(verbose) { + HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, FUNC, i); + if(expected_line_len == 0) { + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, "<EMPTY>", expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, buffer, actual_line_len); + } + if(actual_line_len == 0) { + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, (*expected_output)[i], expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, "<EMPTY>", actual_line_len); + } + } + HDfprintf(stdout, "BADNESS BADNESS BADNESS\n"); + } + } + /* We directly compare the header line (line 0) */ + else if(0 == i) { + if((actual_line_len != expected_line_len) || (HDstrcmp(buffer, (*expected_output)[i]) != 0 )) { - if ( ( actual_line_len == 0 ) && ( expected_line_len == 0 ) ) { + nerrors++; + if(verbose) { + HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, FUNC, i); + HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", world_mpi_rank, FUNC, (*expected_output)[i], expected_line_len); + HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", world_mpi_rank, FUNC, buffer, actual_line_len); + } + } + } + /* All other lines we tokenize and just compare the function name. This + * keeps the test from being too fragile. + */ + else { + char *tok = NULL; /* token for actual line */ - done = TRUE; + tok = HDstrtok(buffer, " "); - } else if ( ( actual_line_len != expected_line_len ) || - ( HDstrcmp(buffer, (*expected_output)[i]) != 0 ) ) { + if(HDstrcmp(tok, (*expected_output)[i]) != 0 ) { - nerrors++; - if ( verbose ) { - HDfprintf(stdout, - "%d:%s: Unexpected data in trace file line %d.\n", - world_mpi_rank, FUNC, i); - HDfprintf(stdout, "%d:%s: expected = \"%s\" %d\n", - world_mpi_rank, FUNC, (*expected_output)[i], - expected_line_len); - HDfprintf(stdout, "%d:%s: actual = \"%s\" %d\n", - world_mpi_rank, FUNC, buffer, - actual_line_len); + nerrors++; + if(verbose) { + HDfprintf(stdout, "%d:%s: Unexpected data in trace file line %d.\n", world_mpi_rank, FUNC, i); + HDfprintf(stdout, "%d:%s: expected = \"%s\"\n", world_mpi_rank, FUNC, (*expected_output)[i]); + HDfprintf(stdout, "%d:%s: actual = \"%s\"\n", world_mpi_rank, FUNC, tok); + } } - } else { - i++; - } - } + } /* end else */ - if ( trace_file_ptr != NULL ) { + i++; + } /* end while */ - HDfclose(trace_file_ptr); - trace_file_ptr = NULL; -#if 1 - HDremove(trace_file_name); -#endif + /* Clean up the trace file */ + if(trace_file_ptr != NULL) { + HDfclose(trace_file_ptr); + trace_file_ptr = NULL; + HDremove(trace_file_name); } - } + } /* end giant else that runs clients */ max_nerrors = get_max_nerrors(); - if ( world_mpi_rank == 0 ) { - - if ( max_nerrors == 0 ) { - - PASSED(); - - } else { + if(world_mpi_rank == 0) { + if(max_nerrors == 0) { + PASSED(); + } + else { failures++; H5_FAILED(); } } - success = ( ( success ) && ( max_nerrors == 0 ) ); - -#else /* H5_METADATA_TRACE_FILE */ - - if ( world_mpi_rank == 0 ) { - - SKIPPED(); - - HDfprintf(stdout, " trace file support disabled.\n"); - } - -#endif /* H5_METADATA_TRACE_FILE */ + success = ((success) && (max_nerrors == 0)); return(success); diff --git a/testpar/t_pflush1.c b/testpar/t_pflush1.c index 4677bfe..27b561b 100644 --- a/testpar/t_pflush1.c +++ b/testpar/t_pflush1.c @@ -15,11 +15,11 @@ * Programmer: Leon Arber <larber@uiuc.edu> * Sept. 28, 2006. * - * Purpose: This is the first half of a two-part test that makes sure - * that a file can be read after a parallel application crashes as long - * as the file was flushed first. We simulate a crash by - * calling _exit(0) since this doesn't flush HDF5 caches but - * still exits with success. + * Purpose: This is the first half of a two-part test that makes sure + * that a file can be read after a parallel application crashes + * as long as the file was flushed first. We simulate a crash by + * calling _exit() since this doesn't flush HDF5 caches but + * still exits with success. */ #include "h5test.h" @@ -29,171 +29,190 @@ const char *FILENAME[] = { NULL }; -static double the_data[100][100]; +static int data_g[100][100]; +#define N_GROUPS 100 + + /*------------------------------------------------------------------------- - * Function: create_file - * - * Purpose: Creates file used in part 1 of the test + * Function: create_test_file * - * Return: Success: 0 + * Purpose: Creates the file used in part 1 of the test * - * Failure: 1 + * Return: Success: A valid file ID + * Failure: H5I_INVALID_HID * - * Programmer: Leon Arber + * Programmer: Leon Arber * Sept. 26, 2006 * - * Modifications: - * *------------------------------------------------------------------------- */ static hid_t -create_file(char* name, hid_t fapl) +create_test_file(char *name, hid_t fapl_id) { - hid_t file, dcpl, space, dset, groups, grp, plist; - hsize_t ds_size[2] = {100, 100}; - hsize_t ch_size[2] = {5, 5}; - hsize_t i, j; - - - - if((file=H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; + hid_t fid = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2] = {100, 100}; + hsize_t chunk_dims[2] = {5, 5}; + hsize_t i, j; + + if((fid = H5Fcreate(name, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) + goto error; /* Create a chunked dataset */ - if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; - if(H5Pset_chunk(dcpl, 2, ch_size) < 0) goto error; - if((space = H5Screate_simple(2, ds_size, NULL)) < 0) goto error; - if((dset = H5Dcreate2(file, "dset", H5T_NATIVE_FLOAT, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) - goto error; - - plist = H5Pcreate(H5P_DATASET_XFER); - H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); - + if((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) + goto error; + if(H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0) + goto error; + if((sid = H5Screate_simple(2, dims, NULL)) < 0) + goto error; + if((did = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto error; /* Write some data */ - for(i = 0; i < ds_size[0]; i++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - for(j = 0; j < ds_size[1]; j++) - the_data[i][j] = (double)(hssize_t)i/(hssize_t)(j+1); - } - if(H5Dwrite(dset, H5T_NATIVE_DOUBLE, space, space, plist, the_data) < 0) goto error; + for(i = 0; i < dims[0]; i++) + for(j = 0; j < dims[1]; j++) + data_g[i][j] = (int)(i + (i * j) + j); + + if(H5Dwrite(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + goto error; /* Create some groups */ - if((groups = H5Gcreate2(file, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < 100; i++) { - sprintf(name, "grp%02u", (unsigned)i); - if((grp = H5Gcreate2(groups, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; + if((top_level_gid = H5Gcreate2(fid, "some_groups", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + for(i = 0; i < N_GROUPS; i++) { + HDsprintf(name, "grp%02u", (unsigned)i); + if((gid = H5Gcreate2(top_level_gid, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) + goto error; + if(H5Gclose(gid) < 0) + goto error; } - return file; + return fid; error: - HD_exit(1); -} + return H5I_INVALID_HID; +} /* end create_test_file() */ + /*------------------------------------------------------------------------- * Function: main * - * Purpose: Part 1 of a two-part H5Fflush() test. - * - * Return: Success: 0 + * Purpose: Part 1 of a two-part parallel H5Fflush() test. * - * Failure: 1 + * Return: EXIT_FAILURE (always) * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 23, 1998 * - * Modifications: - * Leon Arber - * Sept. 26, 2006, expand test to check for failure if H5Fflush is not called. - * - * *------------------------------------------------------------------------- */ int main(int argc, char* argv[]) { - hid_t file1, file2, fapl; - MPI_File *mpifh_p = NULL; - char name[1024]; - const char *envval = NULL; - int mpi_size, mpi_rank; - MPI_Comm comm = MPI_COMM_WORLD; - MPI_Info info = MPI_INFO_NULL; + hid_t fid1 = H5I_INVALID_HID; + hid_t fid2 = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + MPI_File *mpifh_p = NULL; + char name[1024]; + const char *envval = NULL; + int mpi_size; + int mpi_rank; + MPI_Comm comm = MPI_COMM_WORLD; + MPI_Info info = MPI_INFO_NULL; MPI_Init(&argc, &argv); MPI_Comm_size(comm, &mpi_size); MPI_Comm_rank(comm, &mpi_rank); - fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl, comm, info); - if(mpi_rank == 0) - TESTING("H5Fflush (part1)"); + TESTING("H5Fflush (part1)"); + + /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); if(envval == NULL) envval = "nomatch"; - if(HDstrcmp(envval, "split")) { + + if(!HDstrcmp(envval, "split")) { + if(mpi_rank == 0) { + SKIPPED(); + HDputs(" Test not compatible with current Virtual File Driver"); + } + MPI_Finalize(); + HDexit(EXIT_FAILURE); + } + + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_mpio(fapl_id, comm, info) < 0) + goto error; + /* Create the file */ - h5_fixname(FILENAME[0], fapl, name, sizeof name); - file1 = create_file(name, fapl); + h5_fixname(FILENAME[0], fapl_id, name, sizeof(name)); + if((fid1 = create_test_file(name, fapl_id)) < 0) + goto error; /* Flush and exit without closing the library */ - if(H5Fflush(file1, H5F_SCOPE_GLOBAL) < 0) goto error; + if(H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0) + goto error; /* Create the other file which will not be flushed */ - h5_fixname(FILENAME[1], fapl, name, sizeof name); - file2 = create_file(name, fapl); - + h5_fixname(FILENAME[1], fapl_id, name, sizeof(name)); + if((fid2 = create_test_file(name, fapl_id)) < 0) + goto error; if(mpi_rank == 0) PASSED(); - fflush(stdout); - fflush(stderr); - } /* end if */ - else { - SKIPPED(); - puts(" Test not compatible with current Virtual File Driver"); - } /* end else */ - - /* - * Some systems like AIX do not like files not closed when MPI_Finalize + + HDfflush(stdout); + HDfflush(stderr); + + /* Some systems like AIX do not like files not being closed when MPI_Finalize * is called. So, we need to get the MPI file handles, close them by hand. * Then the _exit is still needed to stop at_exit from happening in some systems. * Note that MPIO VFD returns the address of the file-handle in the VFD struct * because MPI_File_close wants to modify the file-handle variable. */ - /* close file1 */ - if(H5Fget_vfd_handle(file1, fapl, (void **)&mpifh_p) < 0) { - printf("H5Fget_vfd_handle for file1 failed\n"); - goto error; - } /* end if */ - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) { - printf("MPI_File_close for file1 failed\n"); - goto error; - } /* end if */ - /* close file2 */ - if(H5Fget_vfd_handle(file2, fapl, (void **)&mpifh_p) < 0) { - printf("H5Fget_vfd_handle for file2 failed\n"); - goto error; - } /* end if */ - if(MPI_File_close(mpifh_p) != MPI_SUCCESS) { - printf("MPI_File_close for file2 failed\n"); - goto error; - } /* end if */ - - fflush(stdout); - fflush(stderr); - HD_exit(0); + /* Close file 1 */ + if(H5Fget_vfd_handle(fid1, fapl_id, (void **)&mpifh_p) < 0) + goto error; + if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + goto error; + + /* Close file 2 */ + if(H5Fget_vfd_handle(fid2, fapl_id, (void **)&mpifh_p) < 0) + goto error; + if(MPI_File_close(mpifh_p) != MPI_SUCCESS) + goto error; + + HDfflush(stdout); + HDfflush(stderr); + + /* Always exit with a failure code! + * + * In accordance with the standard, not having all processes + * call MPI_Finalize() can be considered an error, so mpiexec + * et al. may indicate failure on return. It's much easier to + * always ignore the failure condition than to handle some + * platforms returning success and others failure. + */ + HD_exit(EXIT_FAILURE); error: - fflush(stdout); - fflush(stderr); - HD_exit(1); -} + HDfflush(stdout); + HDfflush(stderr); + HDprintf("*** ERROR ***\n"); + HDprintf("THERE WAS A REAL ERROR IN t_pflush1.\n"); + HD_exit(EXIT_FAILURE); +} /* end main() */ diff --git a/testpar/t_pflush2.c b/testpar/t_pflush2.c index 2051f4e..f58e5a5 100644 --- a/testpar/t_pflush2.c +++ b/testpar/t_pflush2.c @@ -30,116 +30,124 @@ const char *FILENAME[] = { NULL }; -static double the_data[100][100]; +static int data_g[100][100]; +#define N_GROUPS 100 /*------------------------------------------------------------------------- - * Function: check_file + * Function: check_test_file * - * Purpose: Part 2 of a two-part H5Fflush() test. + * Purpose: Part 2 of a two-part H5Fflush() test. * - * Return: Success: 0 + * Return: SUCCEED/FAIL * - * Failure: 1 - * - * Programmer: Leon Arber + * Programmer: Leon Arber * Sept. 26, 2006. * *------------------------------------------------------------------------- */ -static int -check_file(char* name, hid_t fapl) +static herr_t +check_test_file(char* name, hid_t fapl_id) { - hid_t file, space, dset, groups, grp, plist; - hsize_t ds_size[2]; - double error; - hsize_t i, j; - - plist = H5Pcreate(H5P_DATASET_XFER); - H5Pset_dxpl_mpio(plist, H5FD_MPIO_COLLECTIVE); - if((file = H5Fopen(name, H5F_ACC_RDONLY, fapl)) < 0) goto error; + hid_t fid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + hid_t did = H5I_INVALID_HID; + hid_t top_level_gid = H5I_INVALID_HID; + hid_t gid = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hsize_t dims[2]; + int val; + hsize_t i, j; + + if((dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) + goto error; + if(H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) < 0) + goto error; + if((fid = H5Fopen(name, H5F_ACC_RDONLY, fapl_id)) < 0) + goto error; /* Open the dataset */ - if((dset = H5Dopen2(file, "dset", H5P_DEFAULT)) < 0) goto error; - if((space = H5Dget_space(dset)) < 0) goto error; - if(H5Sget_simple_extent_dims(space, ds_size, NULL) < 0) goto error; - assert(100==ds_size[0] && 100==ds_size[1]); + if((did = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) + goto error; + if((sid = H5Dget_space(did)) < 0) + goto error; + if(H5Sget_simple_extent_dims(sid, dims, NULL) < 0) + goto error; + HDassert(100 == dims[0] && 100 == dims[1]); /* Read some data */ - if (H5Dread(dset, H5T_NATIVE_DOUBLE, space, space, plist, - the_data) < 0) goto error; - for (i=0; i<ds_size[0]; i++) { - for (j=0; j<ds_size[1]; j++) { - /* - * The extra cast in the following statement is a bug workaround - * for the Win32 version 5.0 compiler. - * 1998-11-06 ptl - */ - error = fabs(the_data[i][j]-(double)(hssize_t)i/((hssize_t)j+1)); - if (error>0.0001) { - H5_FAILED(); - printf(" dset[%lu][%lu] = %g\n", - (unsigned long)i, (unsigned long)j, the_data[i][j]); - printf(" should be %g\n", - (double)(hssize_t)i/(hssize_t)(j+1)); - goto error; - } - } + if(H5Dread(did, H5T_NATIVE_INT, sid, sid, dxpl_id, data_g) < 0) + goto error; + for(i = 0; i < dims[0]; i++) { + for(j = 0; j < dims[1]; j++) { + val = (int)(i + (i * j) + j); + if(data_g[i][j] != val) { + H5_FAILED(); + HDprintf(" data_g[%lu][%lu] = %d\n", (unsigned long)i, (unsigned long)j, data_g[i][j]); + HDprintf(" should be %d\n", val); + } + } } /* Open some groups */ - if((groups = H5Gopen2(file, "some_groups", H5P_DEFAULT)) < 0) goto error; - for(i = 0; i < 100; i++) { - sprintf(name, "grp%02u", (unsigned)i); - if((grp = H5Gopen2(groups, name, H5P_DEFAULT)) < 0) goto error; - if(H5Gclose(grp) < 0) goto error; + if((top_level_gid = H5Gopen2(fid, "some_groups", H5P_DEFAULT)) < 0) + goto error; + for(i = 0; i < N_GROUPS; i++) { + HDsprintf(name, "grp%02u", (unsigned)i); + if((gid = H5Gopen2(top_level_gid, name, H5P_DEFAULT)) < 0) + goto error; + if(H5Gclose(gid) < 0) + goto error; } - if(H5Gclose(groups) < 0) goto error; - if(H5Dclose(dset) < 0) goto error; - if(H5Fclose(file) < 0) goto error; - if(H5Pclose(plist) < 0) goto error; - if(H5Sclose(space) < 0) goto error; + if(H5Gclose(top_level_gid) < 0) + goto error; + if(H5Dclose(did) < 0) + goto error; + if(H5Fclose(fid) < 0) + goto error; + if(H5Pclose(dxpl_id) < 0) + goto error; + if(H5Sclose(sid) < 0) + goto error; - return 0; + return SUCCEED; error: H5E_BEGIN_TRY { - H5Pclose(plist); - H5Gclose(groups); - H5Dclose(dset); - H5Fclose(file); - H5Sclose(space); + H5Pclose(dxpl_id); + H5Gclose(top_level_gid); + H5Dclose(did); + H5Fclose(fid); + H5Sclose(sid); + H5Gclose(gid); } H5E_END_TRY; - return 1; -} + return FAIL; +} /* end check_test_file() */ /*------------------------------------------------------------------------- - * Function: main + * Function: main * - * Purpose: Part 2 of a two-part H5Fflush() test. + * Purpose: Part 2 of a two-part H5Fflush() test. * - * Return: Success: 0 + * Return: EXIT_SUCCESS/EXIT_FAIL * - * Failure: 1 - * - * Programmer: Robb Matzke + * Programmer: Robb Matzke * Friday, October 23, 1998 * - * Modifications: - * Leon Arber - * Sept. 26, 2006, expand to check for case where the was file not flushed. - * *------------------------------------------------------------------------- */ int -main(int argc, char* argv[]) +main(int argc, char *argv[]) { + hid_t fapl_id1 = H5I_INVALID_HID; + hid_t fapl_id2 = H5I_INVALID_HID; H5E_auto2_t func; - char name[1024]; + char name[1024]; const char *envval = NULL; - int mpi_size, mpi_rank; + int mpi_size; + int mpi_rank; MPI_Comm comm = MPI_COMM_WORLD; MPI_Info info = MPI_INFO_NULL; @@ -148,69 +156,70 @@ main(int argc, char* argv[]) MPI_Comm_rank(comm, &mpi_rank); if(mpi_rank == 0) - TESTING("H5Fflush (part2 with flush)"); + TESTING("H5Fflush (part2 with flush)"); - /* Don't run this test using the core or split file drivers */ + /* Don't run using the split VFD */ envval = HDgetenv("HDF5_DRIVER"); - if (envval == NULL) + if(envval == NULL) envval = "nomatch"; - if (HDstrcmp(envval, "core") && HDstrcmp(envval, "split")) { - hid_t fapl1, fapl2; - - fapl1 = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl1, comm, info); - - fapl2 = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_mpio(fapl2, comm, info); - - /* Check the case where the file was flushed */ - h5_fixname(FILENAME[0], fapl1, name, sizeof name); - if(check_file(name, fapl1)) - { - H5_FAILED() - goto error; - } - else if(mpi_rank == 0) - { - PASSED() - } - - /* Check the case where the file was not flushed. This should give an error - * so we turn off the error stack temporarily */ - if(mpi_rank == 0) - TESTING("H5Fflush (part2 without flush)"); - H5Eget_auto2(H5E_DEFAULT,&func,NULL); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - - h5_fixname(FILENAME[1], fapl2, name, sizeof name); - if(check_file(name, fapl2)) - { - if(mpi_rank == 0) - { - PASSED() - } - } - else - { - H5_FAILED() - goto error; - } - H5Eset_auto2(H5E_DEFAULT, func, NULL); - - - h5_clean_files(&FILENAME[0], fapl1); - h5_clean_files(&FILENAME[1], fapl2); + + if(!HDstrcmp(envval, "split")) { + if(mpi_rank == 0) { + SKIPPED(); + HDputs(" Test not compatible with current Virtual File Driver"); + } + MPI_Finalize(); + HDexit(EXIT_FAILURE); + } + + if((fapl_id1 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_mpio(fapl_id1, comm, info) < 0) + goto error; + + if((fapl_id2 = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; + if(H5Pset_fapl_mpio(fapl_id2, comm, info) < 0) + goto error; + + /* Check the case where the file was flushed */ + h5_fixname(FILENAME[0], fapl_id1, name, sizeof(name)); + if(check_test_file(name, fapl_id1)) { + H5_FAILED() + goto error; } - else - { - SKIPPED(); - puts(" Test not compatible with current Virtual File Driver"); + else if(mpi_rank == 0) { + PASSED() } + /* Check the case where the file was not flushed. This should give an error + * so we turn off the error stack temporarily. + */ + if(mpi_rank == 0) + TESTING("H5Fflush (part2 without flush)"); + H5Eget_auto2(H5E_DEFAULT,&func, NULL); + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + + h5_fixname(FILENAME[1], fapl_id2, name, sizeof(name)); + if(check_test_file(name, fapl_id2)) { + if(mpi_rank == 0) + PASSED() + } + else { + H5_FAILED() + goto error; + } + + H5Eset_auto2(H5E_DEFAULT, func, NULL); + + h5_clean_files(&FILENAME[0], fapl_id1); + h5_clean_files(&FILENAME[1], fapl_id2); + MPI_Finalize(); - return 0; - error: - return 1; -} + HDexit(EXIT_SUCCESS); + +error: + HDexit(EXIT_FAILURE); +} /* end main() */ diff --git a/testpar/testpflush.sh.in b/testpar/testpflush.sh.in new file mode 100644 index 0000000..02f0e26 --- /dev/null +++ b/testpar/testpflush.sh.in @@ -0,0 +1,64 @@ +#! /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 script for the parallel flush test +# +# The parallel flush test uses two programs to test flush operations +# in parallel HDF5. The first program purposely exits without calling +# MPI_Finalize(), which is an error under the MPI standard and mpiexec +# in some implementations will return an error code even though all +# processes exit successfully. This script lets us swallow the error +# from the first program. +# +# True errors in the first program will be detected as errors in the +# second program, so watch out for that. +# +# Programmer: Dana Robinson +# Fall 2018 + +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi + +# Turn the $$ we use to avoid Autotools munging into $ +# +# Allowing $$ to substitute in both the RUNPARALLEL string and the +# regexp is intentional. There doesn't seem to be a way around +# this using quote shenanigans. The downside is that there is a remote +# chance that the shell's pid will match a number in the RUNPARALLEL +# variable, but that seems less likely to cause problems than expecting +# library builders to specify two almost identical versions of the +# RUNPARALLEL command, one for use in scripts and one via Makefiles. +RUNPARALLELSCRIPT=`echo "@RUNPARALLEL@" | sed "s/$$/\$/g"` + +# ========================================== +# Run the first parallel flush test program +# (note that we ignore any errors here) +# ========================================== +echo "*** NOTE ***********************************************************" +echo "You may see complaints from mpiexec et al. that not all processes" +echo "called MPI_Finalize(). This is an intended characteristic of the" +echo "test and should not be considered an error." +echo "********************************************************************" +eval ${RUNPARALLELSCRIPT} ./t_pflush1 + + +# =========================================== +# Run the second parallel flush test program +# The return code of this call is the return +# code of the script. +# =========================================== +eval ${RUNPARALLELSCRIPT} ./t_pflush2 + diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c index aa779b3..559c677 100644 --- a/tools/test/h5jam/tellub.c +++ b/tools/test/h5jam/tellub.c @@ -53,7 +53,7 @@ usage (const char *prog) /*------------------------------------------------------------------------- * Function: parse_command_line * - * Purpose: Parse the command line for the h5dumper. + * Purpose: Parse the command line. * * Return: Success: void * Failure: Exits program with EXIT_FAILURE value. @@ -89,7 +89,7 @@ parse_command_line (int argc, const char *argv[]) /*------------------------------------------------------------------------- * Function: main * - * Purpose: HDF5 user block unjammer + * Purpose: HDF5 user block tell size * * Return: EXIT_SUCCESS/EXIT_FAILURE *------------------------------------------------------------------------- |