summaryrefslogtreecommitdiffstats
path: root/tools/h5repack
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5repack')
-rw-r--r--tools/h5repack/CMakeLists.txt563
-rw-r--r--tools/h5repack/Makefile.in2
-rw-r--r--tools/h5repack/h5repack.c30
-rw-r--r--tools/h5repack/h5repack_copy.c59
-rw-r--r--tools/h5repack/h5repack_filters.c1
-rw-r--r--tools/h5repack/h5repack_main.c41
-rw-r--r--tools/h5repack/h5repack_opttable.c12
-rw-r--r--tools/h5repack/h5repack_parse.c52
-rw-r--r--tools/h5repack/h5repack_verify.c26
-rw-r--r--tools/h5repack/h5repacktst.c5
-rw-r--r--tools/h5repack/testh5repack_detect_szip.c7
11 files changed, 681 insertions, 117 deletions
diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt
new file mode 100644
index 0000000..cbf40a5
--- /dev/null
+++ b/tools/h5repack/CMakeLists.txt
@@ -0,0 +1,563 @@
+cmake_minimum_required (VERSION 2.8)
+PROJECT (HDF5_TOOLS_H5REPACK)
+
+#-----------------------------------------------------------------------------
+# Setup include Directories
+#-----------------------------------------------------------------------------
+INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib)
+INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test)
+
+# --------------------------------------------------------------------
+# Add h5Repack executables and tests
+# --------------------------------------------------------------------
+SET (REPACK_COMMON_SRCS
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_copy.c
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_filters.c
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_opttable.c
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_parse.c
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_refs.c
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_verify.c
+ ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack.c
+)
+INCLUDE_DIRECTORIES (${HDF5_TEST_SOURCE_DIR})
+ADD_EXECUTABLE (h5repack ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c)
+H5_NAMING (h5repack)
+IF (WIN32)
+ IF (MSVC)
+ IF (NOT BUILD_SHARED_LIBS)
+ SET_TARGET_PROPERTIES (h5repack
+ PROPERTIES
+ LINK_FLAGS "/NODEFAULTLIB:MSVCRT"
+ )
+ ENDIF (NOT BUILD_SHARED_LIBS)
+ ENDIF (MSVC)
+ENDIF (WIN32)
+TARGET_LINK_LIBRARIES (h5repack ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
+
+SET (H5_DEP_EXECUTABLES h5repack)
+
+IF (BUILD_TESTING)
+ ADD_EXECUTABLE (testh5repack_detect_szip ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c)
+ H5_NAMING (testh5repack_detect_szip)
+ IF (WIN32)
+ IF (MSVC)
+ IF (NOT BUILD_SHARED_LIBS)
+ SET_TARGET_PROPERTIES (testh5repack_detect_szip
+ PROPERTIES
+ LINK_FLAGS "/NODEFAULTLIB:MSVCRT"
+ )
+ ENDIF (NOT BUILD_SHARED_LIBS)
+ ENDIF (MSVC)
+ ENDIF (WIN32)
+ TARGET_LINK_LIBRARIES (testh5repack_detect_szip ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+
+ ADD_TEST (NAME testh5repack_detect_szip COMMAND $<TARGET_FILE:testh5repack_detect_szip>)
+ IF (HDF5_ENABLE_SZIP_SUPPORT)
+ SET (passRegex "yes")
+ SET_TESTS_PROPERTIES (testh5repack_detect_szip PROPERTIES PASS_REGULAR_EXPRESSION "yes")
+ ELSE (HDF5_ENABLE_SZIP_SUPPORT)
+ SET (passRegex "no")
+ SET_TESTS_PROPERTIES (testh5repack_detect_szip PROPERTIES PASS_REGULAR_EXPRESSION "no")
+ ENDIF (HDF5_ENABLE_SZIP_SUPPORT)
+
+ ADD_EXECUTABLE (h5repacktest ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repacktst.c)
+ H5_NAMING (h5repacktest)
+ IF (WIN32)
+ IF (MSVC)
+ IF (NOT BUILD_SHARED_LIBS)
+ SET_TARGET_PROPERTIES (h5repacktest
+ PROPERTIES
+ LINK_FLAGS "/NODEFAULTLIB:MSVCRT"
+ )
+ ENDIF (NOT BUILD_SHARED_LIBS)
+ ENDIF (MSVC)
+ ENDIF (WIN32)
+ TARGET_LINK_LIBRARIES (h5repacktest ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET})
+
+ ADD_TEST (NAME h5repacktest COMMAND $<TARGET_FILE:h5repacktest>)
+
+ SET (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES}
+ h5repacktest
+ testh5repack_detect_szip
+ )
+
+
+ SET (INFO_FILE testfiles/h5repack.info)
+
+ SET (FILE0 h5repack_fill.h5)
+ SET (FILE1 h5repack_objs.h5)
+ SET (FILE2 h5repack_attr.h5)
+ SET (FILE3 h5repack_hlink.h5)
+ SET (FILE4 h5repack_layout.h5)
+ SET (FILE5 h5repack_early.h5)
+ SET (FILE7 h5repack_szip.h5)
+ SET (FILE8 h5repack_deflate.h5)
+ SET (FILE9 h5repack_shuffle.h5)
+ SET (FILE10 h5repack_fletcher.h5)
+ SET (FILE11 h5repack_filters.h5)
+ SET (FILE12 h5repack_nbit.h5)
+ SET (FILE13 h5repack_soffset.h5)
+ SET (FILE14 h5repack_layouto.h5 ) # A file with an older version of the layout message (copy of test/tlayouto.h5)
+ SET (FILE15 h5repack_named_dtypes.h5)
+ SET (FILE16 tfamily%05d.h5) # located in common testfiles folder
+ SET (FILE_REF h5repack_refs.h5)
+
+ #-- Copy all the HDF5 files from the test directory into the source directory
+ SET (HDF5_REFERENCE_TEST_FILES
+ h5repack_ext.bin
+ ublock.bin
+ h5repack.info
+ h5repack_attr.h5
+ h5repack_deflate.h5
+ h5repack_early.h5
+ h5repack_ext.h5
+ h5repack_fill.h5
+ h5repack_filters.h5
+ h5repack_fletcher.h5
+ h5repack_hlink.h5
+ h5repack_layout.h5
+ h5repack_layouto.h5
+ h5repack_named_dtypes.h5
+ h5repack_nbit.h5
+ h5repack_objs.h5
+ h5repack_refs.h5
+ h5repack_shuffle.h5
+ h5repack_soffset.h5
+ h5repack_szip.h5
+ )
+ SET (HDF5_COMMON_TEST_FILES
+ tfamily00000.h5
+ tfamily00001.h5
+ tfamily00002.h5
+ tfamily00003.h5
+ tfamily00004.h5
+ tfamily00005.h5
+ tfamily00006.h5
+ tfamily00007.h5
+ tfamily00008.h5
+ tfamily00009.h5
+ tfamily00010.h5
+ )
+
+ FOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES})
+ SET (dest "${PROJECT_BINARY_DIR}/testfiles/${h5_file}")
+ #MESSAGE (STATUS " Copying ${h5_file}")
+ ADD_CUSTOM_COMMAND (
+ TARGET h5repack
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testfiles/${h5_file} ${dest}
+ )
+ ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES})
+
+ FOREACH (h5c_file ${HDF5_COMMON_TEST_FILES})
+ SET (dest "${PROJECT_BINARY_DIR}/testfiles/${h5c_file}")
+ #MESSAGE (STATUS " Copying ${h5_file}")
+ ADD_CUSTOM_COMMAND (
+ TARGET h5repack
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy_if_different ${HDF5_TOOLS_SOURCE_DIR}/testfiles/${h5c_file} ${dest}
+ )
+ ENDFOREACH (h5c_file ${HDF5_COMMON_TEST_FILES})
+
+
+ MACRO (ADD_H5_TEST testname testtype testfile)
+ IF (${testtype} STREQUAL "SKIP")
+ MESSAGE (STATUS "SKIP ${testfile} ${ARGN}")
+ ELSE (${testtype} STREQUAL "SKIP")
+ ADD_TEST (
+ NAME H5REPACK-${testname}
+ COMMAND $<TARGET_FILE:h5repack> ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out.${testfile}
+ )
+ ADD_TEST (
+ NAME H5REPACK-DIFF_${testname}
+ COMMAND $<TARGET_FILE:h5diff> ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out.${testfile}
+ )
+ ENDIF (${testtype} STREQUAL "SKIP")
+ ENDMACRO (ADD_H5_TEST testname testfile testtype)
+
+#
+# The tests
+# We use the files generated by h5repacktst
+# Each run generates "<file>.out.h5" and the tool h5diff is used to
+# compare the input and output files
+#
+# the tests are the same as the program h5repacktst, but run from the CLI
+#
+
+# See which filters are usable (and skip tests for filters we
+# don't have). Do this by searching H5pubconf.h to see which
+# filters are defined.
+
+# detect whether the encoder is present.
+SET (USE_FILTER_SZIP_ENCODER "no")
+IF (HDF5_ENABLE_SZIP_ENCODING)
+ SET (USE_FILTER_SZIP_ENCODER ${testh5repack_detect_szip})
+ENDIF (HDF5_ENABLE_SZIP_ENCODING)
+
+IF (H5_HAVE_FILTER_DEFLATE)
+ SET (USE_FILTER_DEFLATE "true")
+ENDIF (H5_HAVE_FILTER_DEFLATE)
+
+IF (H5_HAVE_FILTER_SZIP)
+ SET (USE_FILTER_SZIP "true")
+ENDIF (H5_HAVE_FILTER_SZIP)
+
+IF (H5_HAVE_FILTER_SHUFFLE)
+ SET (USE_FILTER_SHUFFLE "true")
+ENDIF (H5_HAVE_FILTER_SHUFFLE)
+
+IF (H5_HAVE_FILTER_FLETCHER32)
+ SET (USE_FILTER_FLETCHER32 "true")
+ENDIF (H5_HAVE_FILTER_FLETCHER32)
+
+IF (H5_HAVE_FILTER_NBIT)
+ SET (USE_FILTER_NBIT "true")
+ENDIF (H5_HAVE_FILTER_NBIT)
+
+IF (H5_HAVE_FILTER_SCALEOFFSET)
+ SET (USE_FILTER_SCALEOFFSET "true")
+ENDIF (H5_HAVE_FILTER_SCALEOFFSET)
+
+# copy files (these files have no filters)
+ADD_H5_TEST (fill "TEST" ${FILE0})
+ADD_H5_TEST (objs "TEST" ${FILE1})
+ADD_H5_TEST (attr "TEST" ${FILE2})
+ADD_H5_TEST (hlink "TEST" ${FILE3})
+ADD_H5_TEST (layout "TEST" ${FILE4})
+ADD_H5_TEST (early "TEST" ${FILE5})
+
+# use $FILE4 to write some filters (this file has no filters)
+
+# gzip with individual object
+SET (arg ${FILE4} -f dset1:GZIP=1 -l dset1:CHUNK=20x10)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (gzip_individual ${TESTTYPE} ${arg})
+
+# gzip for all
+SET (arg ${FILE4} -f GZIP=1)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (gzip_all ${TESTTYPE} ${arg})
+
+# szip with individual object
+SET (arg ${FILE4} -f dset2:SZIP=8,EC -l dset2:CHUNK=20x10)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ADD_H5_TEST (szip_individual ${TESTTYPE} ${arg})
+
+# szip for all
+SET (arg ${FILE4} -f SZIP=8,NN)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ADD_H5_TEST (szip_all ${TESTTYPE} ${arg})
+
+# shuffle with individual object
+SET (arg ${FILE4} -f dset2:SHUF -l dset2:CHUNK=20x10)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SHUFFLE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SHUFFLE)
+ADD_H5_TEST (shuffle_individual ${TESTTYPE} ${arg})
+
+# shuffle for all
+SET (arg ${FILE4} -f SHUF)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SHUFFLE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SHUFFLE)
+ADD_H5_TEST (shuffle_all ${TESTTYPE} ${arg})
+
+# fletcher32 with individual object
+SET (arg ${FILE4} -f dset2:FLET -l dset2:CHUNK=20x10)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_FLETCHER32)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_FLETCHER32)
+ADD_H5_TEST (fletcher_individual ${TESTTYPE} ${arg})
+
+# fletcher32 for all
+SET (arg ${FILE4} -f FLET)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_FLETCHER32)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_FLETCHER32)
+ADD_H5_TEST (fletcher_all ${TESTTYPE} ${arg})
+
+# all filters
+SET (arg ${FILE4} -f dset2:SHUF -f dset2:FLET -f dset2:SZIP=8,NN -f dset2:GZIP=1 -l dset2:CHUNK=20x10)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (all_filters ${TESTTYPE} ${arg})
+
+###########################################################
+# the following tests assume the input files have filters
+###########################################################
+
+# szip copy
+SET (arg ${FILE7})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ADD_H5_TEST (szip_copy ${TESTTYPE} ${arg})
+
+# szip remove
+SET (arg ${FILE7} --filter=dset_szip:NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP)
+ADD_H5_TEST (szip_remove ${TESTTYPE} ${arg})
+
+# deflate copy
+SET (arg ${FILE8})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (deflate_copy ${TESTTYPE} ${arg})
+
+# deflate remove
+SET (arg ${FILE8} -f dset_deflate:NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (deflate_remove ${TESTTYPE} ${arg})
+
+# shuffle copy
+SET (arg ${FILE9})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SHUFFLE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SHUFFLE)
+ADD_H5_TEST (shuffle_copy ${TESTTYPE} ${arg})
+
+# shuffle remove
+SET (arg ${FILE9} -f dset_shuffle:NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SHUFFLE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SHUFFLE)
+ADD_H5_TEST (shuffle_remove ${TESTTYPE} ${arg})
+
+# fletcher32 copy
+SET (arg ${FILE10})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_FLETCHER32)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_FLETCHER32)
+ADD_H5_TEST (fletcher_copy ${TESTTYPE} ${arg})
+
+# fletcher32 remove
+SET (arg ${FILE10} -f dset_fletcher32:NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_FLETCHER32)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_FLETCHER32)
+ADD_H5_TEST (fletcher_remove ${TESTTYPE} ${arg})
+
+# nbit copy
+SET (arg ${FILE12})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_NBIT)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_NBIT)
+ADD_H5_TEST (nbit_copy ${TESTTYPE} ${arg})
+
+# nbit remove
+SET (arg ${FILE12} -f dset_nbit:NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_NBIT)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_NBIT)
+ADD_H5_TEST (nbit_remove ${TESTTYPE} ${arg})
+
+# nbit add
+SET (arg ${FILE12} -f dset_int31:NBIT)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_NBIT)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_NBIT)
+ADD_H5_TEST (nbit_add ${TESTTYPE} ${arg})
+
+# scaleoffset copy
+SET (arg ${FILE13})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SCALEOFFSET)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SCALEOFFSET)
+ADD_H5_TEST (scale_copy ${TESTTYPE} ${arg})
+
+# scaleoffset add
+SET (arg ${FILE13} -f dset_none:SOFF=31,IN)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SCALEOFFSET)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SCALEOFFSET)
+ADD_H5_TEST (scale_add ${TESTTYPE} ${arg})
+
+# scaleoffset remove
+SET (arg ${FILE13} -f dset_scaleoffset:NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SCALEOFFSET)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SCALEOFFSET)
+ADD_H5_TEST (scale_remove ${TESTTYPE} ${arg})
+
+# remove all filters
+SET (arg ${FILE11} -f NONE)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_NBIT OR NOT USE_FILTER_SCALEOFFSET)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_FLETCHER32 OR NOT USE_FILTER_DEFLATE OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SHUFFLE OR NOT USE_FILTER_NBIT OR NOT USE_FILTER_SCALEOFFSET)
+ADD_H5_TEST (remove_all ${TESTTYPE} ${arg})
+
+#filter conversions
+
+SET (arg ${FILE8} -f dset_deflate:SZIP=8,NN)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_SZIP OR NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (deflate_convert ${TESTTYPE} ${arg})
+
+SET (arg ${FILE7} -f dset_szip:GZIP=1)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_SZIP OR NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_SZIP OR NOT USE_FILTER_SZIP_ENCODER OR NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (szip_convert ${TESTTYPE} ${arg})
+
+#limit
+SET (arg ${FILE4} -f GZIP=1 -m 1024)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (deflate_limit ${TESTTYPE} ${arg})
+
+#file
+SET (arg ${FILE4} -e ${INFO_FILE})
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (deflate_file ${TESTTYPE} ${arg})
+
+#########################################################
+# layout options (these files have no filters)
+#########################################################
+
+ADD_H5_TEST (dset2_chunk_20x10 "TEST" ${FILE4} --layout=dset2:CHUNK=20x10)
+ADD_H5_TEST (chunk_20x10 "TEST" ${FILE4} -l CHUNK=20x10)
+ADD_H5_TEST (dset2_conti "TEST" ${FILE4} -l dset2:CONTI)
+ADD_H5_TEST (conti "TEST" ${FILE4} -l CONTI)
+ADD_H5_TEST (dset2_compa "TEST" ${FILE4} -l dset2:COMPA)
+ADD_H5_TEST (compa "TEST" ${FILE4} -l COMPA)
+
+
+################################################################
+# layout conversions (file has no filters)
+###############################################################
+
+ADD_H5_TEST (dset_compa_conti "TEST" ${FILE4} -l dset_compact:CONTI)
+ADD_H5_TEST (dset_compa_chunk "TEST" ${FILE4} -l dset_compact:CHUNK=2x5)
+ADD_H5_TEST (dset_compa_compa "TEST" ${FILE4} -l dset_compact:COMPA)
+ADD_H5_TEST (dset_conti_compa "TEST" ${FILE4} -l dset_contiguous:COMPA)
+ADD_H5_TEST (dset_conti_chunk "TEST" ${FILE4} -l dset_contiguous:CHUNK=3x6)
+ADD_H5_TEST (dset_conti_conti "TEST" ${FILE4} -l dset_contiguous:CONTI)
+ADD_H5_TEST (chunk_compa "TEST" ${FILE4} -l dset_chunk:COMPA)
+ADD_H5_TEST (chunk_conti "TEST" ${FILE4} -l dset_chunk:CONTI)
+ADD_H5_TEST (chunk_18x13 "TEST" ${FILE4} -l dset_chunk:CHUNK=18x13)
+
+# Native option
+# Do not use FILE1, as the named dtype will be converted to native, and h5diff will
+# report a difference.
+ADD_H5_TEST (native_fill "TEST" ${FILE0} -n)
+ADD_H5_TEST (native_attr "TEST" ${FILE2} -n)
+
+
+# latest file format with long switches. use FILE4=h5repack_layout.h5 (no filters)
+SET (arg ${FILE4} --layout CHUNK=20x10 --filter GZIP=1 --minimum=10 --native --latest --compact=8 --indexed=6 --ssize=8[:dtype])
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (layout_long_switches ${TESTTYPE} ${arg})
+
+# latest file format with short switches. use FILE4=h5repack_layout.h5 (no filters)
+SET (arg ${FILE4} -l CHUNK=20x10 -f GZIP=1 -m 10 -n -L -c 8 -d 6 -s 8[:dtype])
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+ADD_H5_TEST (layout_short_switches ${TESTTYPE} ${arg})
+
+# several global filters
+SET (arg ${FILE4} --filter GZIP=1 --filter SHUF)
+SET (TESTTYPE "TEST")
+IF (NOT USE_FILTER_DEFLATE OR NOT USE_FILTER_SHUFFLE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE OR NOT USE_FILTER_SHUFFLE)
+ADD_H5_TEST (global_filters ${TESTTYPE} ${arg})
+
+# syntax of -i infile -o outfile
+# latest file format with short switches. use FILE4=h5repack_layout.h5 (no filters)
+SET (arg ${FILE4} -l CHUNK=20x10 -f GZIP=1 -m 10 -n -L -c 8 -d 6 -s 8[:dtype])
+SET (TESTTYPE "LEGACY")
+IF (NOT USE_FILTER_DEFLATE)
+ SET (TESTTYPE "SKIP")
+ENDIF (NOT USE_FILTER_DEFLATE)
+#ADD_H5_TEST (old_style_layout_short_switches ${TESTTYPE} ${arg})
+
+# add a userblock to file
+SET (arg ${FILE1} -u ${PROJECT_BINARY_DIR}/testfiles/ublock.bin -b 2048)
+ADD_H5_TEST (add_userblock "TEST" ${arg})
+
+# add alignment
+SET (arg ${FILE1} -t 1 -a 1)
+ADD_H5_TEST (add_alignment "TEST" ${arg})
+
+# Check repacking file with old version of layout message (should get upgraded
+# to new version and be readable, etc.)
+ADD_H5_TEST (upgrade_layout "TEST" ${FILE14})
+
+# test for datum size > H5TOOLS_MALLOCSIZE
+ADD_H5_TEST (gt_mallocsize "TEST" ${FILE1} -f GZIP=1)
+
+# Check repacking file with committed datatypes in odd configurations
+ADD_H5_TEST (committed_dt "TEST" ${FILE15})
+
+# tests family driver (file is located in common testfiles folder, uses TOOLTEST1
+#ADD_H5_TEST ( family "FAMILY" ${FILE16})
+
+# test various references (bug 1814)
+ADD_H5_TEST (bug1814 "TEST" ${FILE_REF})
+
+ENDIF (BUILD_TESTING)
+
+#-----------------------------------------------------------------------------
+# Rules for Installation of tools using make Install target
+#-----------------------------------------------------------------------------
+INSTALL (
+ TARGETS
+ h5repack
+ RUNTIME DESTINATION
+ bin/tools
+ COMPONENT
+ toolsapplications
+)
diff --git a/tools/h5repack/Makefile.in b/tools/h5repack/Makefile.in
index 7cb956e..ce18bb9 100644
--- a/tools/h5repack/Makefile.in
+++ b/tools/h5repack/Makefile.in
@@ -206,12 +206,12 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INSTRUMENT = @INSTRUMENT@
INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@
+LARGEFILE = @LARGEFILE@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
-LINUX_LFS = @LINUX_LFS@
LIPO = @LIPO@
LL_PATH = @LL_PATH@
LN_S = @LN_S@
diff --git a/tools/h5repack/h5repack.c b/tools/h5repack/h5repack.c
index 4632ea0..eaca09e 100644
--- a/tools/h5repack/h5repack.c
+++ b/tools/h5repack/h5repack.c
@@ -22,10 +22,6 @@
#include "h5tools.h"
#include "h5tools_utils.h"
-
-extern char *progname;
-
-
/*-------------------------------------------------------------------------
* File: h5repack.c
* Purpose: Public API functions
@@ -162,7 +158,7 @@ int h5repack_addfilter(const char* str,
if(options->n_filter_g > H5_REPACK_MAX_NFILTERS)
{
- error_msg(progname, "maximum number of filters exceeded for <%s>\n", str);
+ error_msg("maximum number of filters exceeded for <%s>\n", str);
free(obj_list);
return -1;
}
@@ -200,7 +196,7 @@ int h5repack_addlayout(const char* str,
init_packobject(&pack);
if (options->all_layout==1){
- error_msg(progname, "invalid layout input: 'all' option \
+ error_msg("invalid layout input: 'all' option \
is present with other objects <%s>\n",str);
return -1;
}
@@ -619,7 +615,7 @@ static int check_options(pack_opt_t *options)
break;
case H5D_LAYOUT_ERROR:
case H5D_NLAYOUTS:
- error_msg(progname, "invalid layout\n");
+ error_msg("invalid layout\n");
return -1;
default:
strcpy(slayout,"invalid layout\n");
@@ -660,7 +656,7 @@ static int check_options(pack_opt_t *options)
if (options->all_layout==1 && has_ck)
{
- error_msg(progname, "invalid chunking input: 'all' option\
+ error_msg("invalid chunking input: 'all' option\
is present with other objects\n");
return -1;
}
@@ -722,7 +718,7 @@ static int check_options(pack_opt_t *options)
if (options->all_filter==1 && has_cp)
{
- error_msg(progname, "invalid compression input: 'all' option\
+ error_msg("invalid compression input: 'all' option\
is present with other objects\n");
return -1;
}
@@ -734,24 +730,24 @@ static int check_options(pack_opt_t *options)
if (options->grp_compact < 0)
{
- error_msg(progname, "invalid maximum number of links to store as header messages\n");
+ error_msg("invalid maximum number of links to store as header messages\n");
return -1;
}
if (options->grp_indexed < 0)
{
- error_msg(progname, "invalid minimum number of links to store in the indexed format\n");
+ error_msg("invalid minimum number of links to store in the indexed format\n");
return -1;
}
if (options->grp_indexed > options->grp_compact)
{
- error_msg(progname, "minimum indexed size is greater than the maximum compact size\n");
+ error_msg("minimum indexed size is greater than the maximum compact size\n");
return -1;
}
for (i=0; i<8; i++)
{
if (options->msg_size[i]<0)
{
- error_msg(progname, "invalid shared message size\n");
+ error_msg("invalid shared message size\n");
return -1;
}
}
@@ -773,7 +769,7 @@ static int check_options(pack_opt_t *options)
if ( options->ublock_filename == NULL && options->ublock_size != 0 )
{
- error_msg(progname, "file name missing for user block\n",
+ error_msg("file name missing for user block\n",
options->ublock_filename);
return -1;
}
@@ -786,7 +782,7 @@ static int check_options(pack_opt_t *options)
if ( options->alignment == 0 && options->threshold != 0 )
{
- error_msg(progname, "alignment for H5Pset_alignment missing\n");
+ error_msg("alignment for H5Pset_alignment missing\n");
return -1;
}
@@ -858,7 +854,7 @@ static int check_objects(const char* fname,
/* the input object names are present in the file and are valid */
if(h5trav_getindext(name, travt) < 0)
{
- error_msg(progname, "%s Could not find <%s> in file <%s>. Exiting...\n",
+ error_msg("%s Could not find <%s> in file <%s>. Exiting...\n",
(options->verbose?"\n":""),name,fname);
goto out;
}
@@ -980,7 +976,7 @@ static const char* get_sfilter(H5Z_filter_t filtn)
else if (filtn==H5Z_FILTER_SCALEOFFSET)
return "SOFF";
else {
- error_msg(progname, "input error in filter type\n");
+ error_msg("input error in filter type\n");
exit(EXIT_FAILURE);
}
}
diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c
index 12fdabc..c3475aa 100644
--- a/tools/h5repack/h5repack_copy.c
+++ b/tools/h5repack/h5repack_copy.c
@@ -30,7 +30,6 @@
* globals
*-------------------------------------------------------------------------
*/
-extern char *progname;
/*-------------------------------------------------------------------------
* macros
@@ -90,7 +89,7 @@ int copy_objects(const char* fnamein,
*/
if((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0)
{
- error_msg(progname, "<%s>: %s\n", fnamein, H5FOPENERROR );
+ error_msg("<%s>: %s\n", fnamein, H5FOPENERROR );
goto out;
}
@@ -100,13 +99,13 @@ int copy_objects(const char* fnamein,
if((fcpl_in = H5Fget_create_plist(fidin)) < 0)
{
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto out;
}
if(H5Pget_userblock(fcpl_in, &ub_size) < 0)
{
- error_msg(progname, "failed to retrieve userblock size\n");
+ error_msg("failed to retrieve userblock size\n");
goto out;
}
@@ -114,7 +113,7 @@ int copy_objects(const char* fnamein,
{
if(H5Pget_file_space(fcpl_in, &options->fs_strategy, NULL) < 0)
{
- error_msg(progname, "failed to retrieve file space strategy\n");
+ error_msg("failed to retrieve file space strategy\n");
goto out;
}
}
@@ -123,14 +122,14 @@ int copy_objects(const char* fnamein,
{
if(H5Pget_file_space(fcpl_in, NULL, &options->fs_threshold) < 0)
{
- error_msg(progname, "failed to retrieve file space threshold\n");
+ error_msg("failed to retrieve file space threshold\n");
goto out;
}
}
if(H5Pclose(fcpl_in) < 0)
{
- error_msg(progname, "failed to close property list\n");
+ error_msg("failed to close property list\n");
goto out;
}
}
@@ -141,7 +140,7 @@ int copy_objects(const char* fnamein,
/* Create file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
- error_msg(progname, "fail to create a file creation property list\n");
+ error_msg("fail to create a file creation property list\n");
goto out;
}
@@ -149,7 +148,7 @@ int copy_objects(const char* fnamein,
{
if(H5Pset_userblock(fcpl, ub_size) < 0)
{
- error_msg(progname, "failed to set non-default userblock size\n");
+ error_msg("failed to set non-default userblock size\n");
goto out;
}
}
@@ -162,7 +161,7 @@ int copy_objects(const char* fnamein,
/* (So that it is created in "dense storage" form) */
if(H5Pset_link_phase_change(fcpl, (unsigned)options->grp_compact, (unsigned)options->grp_indexed) < 0)
{
- error_msg(progname, "fail to adjust group creation parameters for root group\n");
+ error_msg("fail to adjust group creation parameters for root group\n");
goto out;
}
@@ -204,7 +203,7 @@ int copy_objects(const char* fnamein,
{
if(H5Pset_shared_mesg_nindexes(fcpl, nindex) < 0)
{
- error_msg(progname, "fail to set the number of shared object header message indexes\n");
+ error_msg("fail to set the number of shared object header message indexes\n");
goto out;
}
@@ -212,7 +211,7 @@ int copy_objects(const char* fnamein,
for(i = 0; i < (nindex - 1); i++)
{
if(H5Pset_shared_mesg_index(fcpl, i, mesg_type_flags[i], min_mesg_sizes[i]) < 0) {
- error_msg(progname, "fail to configure the specified shared object header message index\n");
+ error_msg("fail to configure the specified shared object header message index\n");
goto out;
} /* end if */
} /* end for */
@@ -221,13 +220,13 @@ int copy_objects(const char* fnamein,
/* Create file access property list */
if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
{
- error_msg(progname, "Could not create file access property list\n");
+ error_msg("Could not create file access property list\n");
goto out;
} /* end if */
if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
{
- error_msg(progname, "Could not set property for using latest version of the format\n");
+ error_msg("Could not set property for using latest version of the format\n");
goto out;
} /* end if */
} /* end if */
@@ -254,7 +253,7 @@ int copy_objects(const char* fnamein,
/* set user block size */
if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
{
- error_msg(progname, "failed to set userblock size\n");
+ error_msg("failed to set userblock size\n");
goto out;
}
@@ -266,14 +265,14 @@ int copy_objects(const char* fnamein,
/* create a file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
- error_msg(progname, "fail to create a file creation property list\n");
+ error_msg("fail to create a file creation property list\n");
goto out;
}
/* set user block size */
if(H5Pset_userblock(fcpl, options->ublock_size) < 0)
{
- error_msg(progname, "failed to set userblock size\n");
+ error_msg("failed to set userblock size\n");
goto out;
}
@@ -298,7 +297,7 @@ int copy_objects(const char* fnamein,
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
{
- error_msg(progname, "failed to set alignment\n");
+ error_msg("failed to set alignment\n");
goto out;
}
@@ -310,13 +309,13 @@ int copy_objects(const char* fnamein,
/* create a file access property list */
if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
{
- error_msg(progname, "Could not create file access property list\n");
+ error_msg("Could not create file access property list\n");
goto out;
}
if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
{
- error_msg(progname, "failed to set alignment\n");
+ error_msg("failed to set alignment\n");
goto out;
}
@@ -330,7 +329,7 @@ int copy_objects(const char* fnamein,
/* set file space strategy and free space threshold */
if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
{
- error_msg(progname, "failed to set file space strategy & threshold\n");
+ error_msg("failed to set file space strategy & threshold\n");
goto out;
}
}
@@ -339,14 +338,14 @@ int copy_objects(const char* fnamein,
/* create a file creation property list */
if((fcpl = H5Pcreate(H5P_FILE_CREATE)) < 0)
{
- error_msg(progname, "fail to create a file creation property list\n");
+ error_msg("fail to create a file creation property list\n");
goto out;
}
/* set file space strategy and free space threshold */
if(H5Pset_file_space(fcpl, options->fs_strategy, options->fs_threshold) < 0)
{
- error_msg(progname, "failed to set file space strategy & threshold \n");
+ error_msg("failed to set file space strategy & threshold \n");
goto out;
}
}
@@ -363,7 +362,7 @@ int copy_objects(const char* fnamein,
if((fidout = H5Fcreate(fnameout,H5F_ACC_TRUNC, fcpl, fapl)) < 0)
{
- error_msg(progname, "<%s>: Could not create file\n", fnameout );
+ error_msg("<%s>: Could not create file\n", fnameout );
goto out;
}
@@ -376,7 +375,7 @@ int copy_objects(const char* fnamein,
{
if ( copy_user_block( options->ublock_filename, fnameout, options->ublock_size) < 0 )
{
- error_msg(progname, "Could not copy user block. Exiting...\n");
+ error_msg("Could not copy user block. Exiting...\n");
goto out;
}
@@ -400,7 +399,7 @@ int copy_objects(const char* fnamein,
*/
if(do_copy_objects(fidin, fidout, travt, options) < 0)
{
- error_msg(progname, "<%s>: Could not copy data to: %s\n", fnamein, fnameout);
+ error_msg("<%s>: Could not copy data to: %s\n", fnamein, fnameout);
goto out;
} /* end if */
@@ -442,7 +441,7 @@ int copy_objects(const char* fnamein,
{
if ( copy_user_block(fnamein, fnameout, ub_size) < 0 )
{
- error_msg(progname, "Could not copy user block. Exiting...\n");
+ error_msg("Could not copy user block. Exiting...\n");
goto out;
}
@@ -1406,19 +1405,19 @@ void print_user_block(const char *filename, hid_t fid)
/* get user block size */
if(( fcpl = H5Fget_create_plist(fid)) < 0)
{
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto done;
}
if(H5Pget_userblock(fcpl, &ub_size) < 0)
{
- error_msg(progname, "failed to retrieve userblock size\n");
+ error_msg("failed to retrieve userblock size\n");
goto done;
}
if(H5Pclose(fcpl) < 0)
{
- error_msg(progname, "failed to close property list\n");
+ error_msg("failed to close property list\n");
goto done;
}
diff --git a/tools/h5repack/h5repack_filters.c b/tools/h5repack/h5repack_filters.c
index c7d8b1e..d4a3479 100644
--- a/tools/h5repack/h5repack_filters.c
+++ b/tools/h5repack/h5repack_filters.c
@@ -14,6 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
+#include "h5test.h"
#include "h5tools.h"
/* number of members in an array */
diff --git a/tools/h5repack/h5repack_main.c b/tools/h5repack/h5repack_main.c
index d6998d0..9f8a701 100644
--- a/tools/h5repack/h5repack_main.c
+++ b/tools/h5repack/h5repack_main.c
@@ -20,6 +20,8 @@
#include "h5tools_utils.h"
#include "h5repack.h"
+/* Name of tool */
+#define PROGRAMNAME "h5repack"
static void usage(const char *prog);
static void parse_command_line(int argc, const char **argv, pack_opt_t* options);
@@ -27,8 +29,6 @@ static void read_info(const char *filename,pack_opt_t *options);
/* module-scoped variables */
-const char *progname = "h5repack";
-int d_status = EXIT_SUCCESS;
static int has_i_o = 0;
const char *infile = NULL;
const char *outfile = NULL;
@@ -107,6 +107,9 @@ int main(int argc, const char **argv)
pack_opt_t options; /*the global options */
int ret=-1;
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
/* initialize options */
h5repack_init(&options, 0, 0, 0, (hsize_t)0);
@@ -123,8 +126,8 @@ int main(int argc, const char **argv)
if ( strcmp( infile, outfile ) == 0 )
{
- error_msg(progname, "file names cannot be the same\n");
- usage(progname);
+ error_msg("file names cannot be the same\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
@@ -132,8 +135,8 @@ int main(int argc, const char **argv)
else
{
- error_msg(progname, "file names missing\n");
- usage(progname);
+ error_msg("file names missing\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -316,10 +319,10 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'h':
- usage(progname);
+ usage(h5tools_getprogname());
exit(EXIT_SUCCESS);
case 'V':
- print_version(progname);
+ print_version(h5tools_getprogname());
exit(EXIT_SUCCESS);
case 'v':
options->verbose = 1;
@@ -329,7 +332,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* parse the -f filter option */
if (h5repack_addfilter( opt_arg, options)<0)
{
- error_msg(progname, "in parsing filter\n");
+ error_msg("in parsing filter\n");
exit(EXIT_FAILURE);
}
break;
@@ -338,7 +341,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* parse the -l layout option */
if (h5repack_addlayout( opt_arg, options)<0)
{
- error_msg(progname, "in parsing layout\n");
+ error_msg("in parsing layout\n");
exit(EXIT_FAILURE);
}
break;
@@ -349,7 +352,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
options->min_comp = atoi( opt_arg );
if ((int)options->min_comp<=0)
{
- error_msg(progname, "invalid minimum compress size <%s>\n", opt_arg );
+ error_msg("invalid minimum compress size <%s>\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -442,7 +445,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
options->alignment = atol( opt_arg );
if ( options->alignment < 1 )
{
- error_msg(progname, "invalid alignment size\n", opt_arg );
+ error_msg("invalid alignment size\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -461,7 +464,7 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
else if(!strcmp(strategy, "VFD"))
options->fs_strategy = H5F_FILE_SPACE_VFD;
else {
- error_msg(progname, "invalid file space management strategy\n", opt_arg );
+ error_msg("invalid file space management strategy\n", opt_arg );
exit(EXIT_FAILURE);
}
break;
@@ -481,8 +484,8 @@ void parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* check for file names to be processed */
if (argc <= opt_ind || argv[ opt_ind + 1 ] == NULL)
{
- error_msg(progname, "missing file names\n");
- usage(progname);
+ error_msg("missing file names\n");
+ usage(h5tools_getprogname());
exit(EXIT_FAILURE);
}
}
@@ -515,7 +518,7 @@ void read_info(const char *filename,
int i, rc=1;
if ((fp = fopen(filename, "r")) == (FILE *)NULL) {
- error_msg(progname, "cannot open options file %s\n", filename);
+ error_msg("cannot open options file %s\n", filename);
exit(EXIT_FAILURE);
}
@@ -552,7 +555,7 @@ void read_info(const char *filename,
comp_info[i-1]='\0'; /*cut the last " */
if (h5repack_addfilter(comp_info,options)==-1){
- error_msg(progname, "could not add compression option\n");
+ error_msg("could not add compression option\n");
exit(EXIT_FAILURE);
}
}
@@ -582,7 +585,7 @@ void read_info(const char *filename,
comp_info[i-1]='\0'; /*cut the last " */
if (h5repack_addlayout(comp_info,options)==-1){
- error_msg(progname, "could not add chunck option\n");
+ error_msg("could not add chunck option\n");
exit(EXIT_FAILURE);
}
}
@@ -591,7 +594,7 @@ void read_info(const char *filename,
*-------------------------------------------------------------------------
*/
else {
- error_msg(progname, "bad file format for %s", filename);
+ error_msg("bad file format for %s", filename);
exit(EXIT_FAILURE);
}
}
diff --git a/tools/h5repack/h5repack_opttable.c b/tools/h5repack/h5repack_opttable.c
index 7c87359..50f97bd 100644
--- a/tools/h5repack/h5repack_opttable.c
+++ b/tools/h5repack/h5repack_opttable.c
@@ -18,8 +18,6 @@
#include "h5repack.h"
#include "h5tools_utils.h"
-extern char *progname;
-
/*-------------------------------------------------------------------------
* Function: init_packobject
*
@@ -67,7 +65,7 @@ static void aux_tblinsert_filter(pack_opttbl_t *table,
}
else
{
- error_msg(progname, "cannot insert the filter in this object.\
+ error_msg("cannot insert the filter in this object.\
Maximum capacity exceeded\n");
}
}
@@ -126,7 +124,7 @@ static int aux_inctable(pack_opttbl_t *table, int n_objs )
table->size += n_objs;
table->objs = (pack_info_t*)realloc(table->objs, table->size * sizeof(pack_info_t));
if (table->objs==NULL) {
- error_msg(progname, "not enough memory for options table\n");
+ error_msg("not enough memory for options table\n");
return -1;
}
for (i = table->nelems; i < table->size; i++)
@@ -153,7 +151,7 @@ int options_table_init( pack_opttbl_t **tbl )
if(NULL == (table = (pack_opttbl_t *)malloc(sizeof(pack_opttbl_t))))
{
- error_msg(progname, "not enough memory for options table\n");
+ error_msg("not enough memory for options table\n");
return -1;
}
@@ -161,7 +159,7 @@ int options_table_init( pack_opttbl_t **tbl )
table->nelems = 0;
if(NULL == (table->objs = (pack_info_t*)malloc(table->size * sizeof(pack_info_t))))
{
- error_msg(progname, "not enough memory for options table\n");
+ error_msg("not enough memory for options table\n");
free(table);
return -1;
}
@@ -232,7 +230,7 @@ int options_add_layout( obj_list_t *obj_list,
/* already chunk info inserted for this one; exit */
if (table->objs[i].chunk.rank>0)
{
- error_msg(progname, "chunk information already inserted for <%s>\n",obj_list[j].obj);
+ error_msg("chunk information already inserted for <%s>\n",obj_list[j].obj);
exit(EXIT_FAILURE);
}
/* insert the layout info */
diff --git a/tools/h5repack/h5repack_parse.c b/tools/h5repack/h5repack_parse.c
index 2d8f040..d3a7419 100644
--- a/tools/h5repack/h5repack_parse.c
+++ b/tools/h5repack/h5repack_parse.c
@@ -21,8 +21,6 @@
#include "h5repack.h"
#include "h5tools_utils.h"
-extern char *progname;
-
/*-------------------------------------------------------------------------
* Function: parse_filter
*
@@ -98,7 +96,7 @@ obj_list_t* parse_filter(const char *str,
obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t));
if (obj_list==NULL)
{
- error_msg(progname, "could not allocate object list\n");
+ error_msg("could not allocate object list\n");
return NULL;
}
*n_objs=n;
@@ -121,7 +119,7 @@ obj_list_t* parse_filter(const char *str,
if (end_obj+1==(int)len)
{
if (obj_list) free(obj_list);
- error_msg(progname, "input Error: Invalid compression type in <%s>\n",str);
+ error_msg("input Error: Invalid compression type in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -159,7 +157,7 @@ obj_list_t* parse_filter(const char *str,
c = str[u];
if (!isdigit(c) && l==-1){
if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter not digit in <%s>\n",str);
+ error_msg("compression parameter not digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (l==-1)
@@ -179,7 +177,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_values[j++]=H5_SZIP_EC_OPTION_MASK;
else
{
- error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
+ error_msg("szip mask must be 'NN' or 'EC' \n");
exit(EXIT_FAILURE);
}
@@ -219,7 +217,7 @@ obj_list_t* parse_filter(const char *str,
c = str[u];
if (!isdigit(c) && l==-1){
if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
+ error_msg("compression parameter is not a digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (l==-1)
@@ -239,7 +237,7 @@ obj_list_t* parse_filter(const char *str,
filt->cd_values[j++]=H5Z_SO_FLOAT_DSCALE;
else
{
- error_msg(progname, "scale type must be 'IN' or 'DS' \n");
+ error_msg("scale type must be 'IN' or 'DS' \n");
exit(EXIT_FAILURE);
}
@@ -263,7 +261,7 @@ obj_list_t* parse_filter(const char *str,
c = str[u];
if (!isdigit(c)){
if (obj_list) free(obj_list);
- error_msg(progname, "compression parameter is not a digit in <%s>\n",str);
+ error_msg("compression parameter is not a digit in <%s>\n",str);
exit(EXIT_FAILURE);
}
stype[m]=c;
@@ -309,7 +307,7 @@ obj_list_t* parse_filter(const char *str,
if (no_param)
{ /*no more parameters, GZIP must have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
+ error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -325,7 +323,7 @@ obj_list_t* parse_filter(const char *str,
if (no_param)
{ /*no more parameters, SZIP must have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
+ error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -341,7 +339,7 @@ obj_list_t* parse_filter(const char *str,
if (m>0)
{ /*shuffle does not have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in SHUF <%s>\n",str);
+ error_msg("extra parameter in SHUF <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -356,7 +354,7 @@ obj_list_t* parse_filter(const char *str,
if (m>0)
{ /*shuffle does not have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in FLET <%s>\n",str);
+ error_msg("extra parameter in FLET <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -371,7 +369,7 @@ obj_list_t* parse_filter(const char *str,
if (m>0)
{ /*nbit does not have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "extra parameter in NBIT <%s>\n",str);
+ error_msg("extra parameter in NBIT <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -386,13 +384,13 @@ obj_list_t* parse_filter(const char *str,
if (no_param)
{ /*no more parameters, SOFF must have parameter */
if (obj_list) free(obj_list);
- error_msg(progname, "missing compression parameter in <%s>\n",str);
+ error_msg("missing compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
else {
if (obj_list) free(obj_list);
- error_msg(progname, "invalid filter type in <%s>\n",str);
+ error_msg("invalid filter type in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -415,7 +413,7 @@ obj_list_t* parse_filter(const char *str,
if (filt->cd_values[0]>9 )
{
if (obj_list) free(obj_list);
- error_msg(progname, "invalid compression parameter in <%s>\n",str);
+ error_msg("invalid compression parameter in <%s>\n",str);
exit(EXIT_FAILURE);
}
break;
@@ -430,19 +428,19 @@ obj_list_t* parse_filter(const char *str,
if ((pixels_per_block%2)==1)
{
if (obj_list) free(obj_list);
- error_msg(progname, "pixels_per_block is not even in <%s>\n",str);
+ error_msg("pixels_per_block is not even in <%s>\n",str);
exit(EXIT_FAILURE);
}
if (pixels_per_block>H5_SZIP_MAX_PIXELS_PER_BLOCK)
{
if (obj_list) free(obj_list);
- error_msg(progname, "pixels_per_block is too large in <%s>\n",str);
+ error_msg("pixels_per_block is too large in <%s>\n",str);
exit(EXIT_FAILURE);
}
if ( (strcmp(smask,"NN")!=0) && (strcmp(smask,"EC")!=0) )
{
if (obj_list) free(obj_list);
- error_msg(progname, "szip mask must be 'NN' or 'EC' \n");
+ error_msg("szip mask must be 'NN' or 'EC' \n");
exit(EXIT_FAILURE);
}
break;
@@ -519,7 +517,7 @@ obj_list_t* parse_layout(const char *str,
obj_list = (obj_list_t*) malloc(n*sizeof(obj_list_t));
if (obj_list==NULL)
{
- error_msg(progname, "could not allocate object list\n");
+ error_msg("could not allocate object list\n");
return NULL;
}
*n_objs=n;
@@ -543,7 +541,7 @@ obj_list_t* parse_layout(const char *str,
if (end_obj+1==(int)len)
{
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, no characters after : in <%s>\n",str);
+ error_msg("in parse layout, no characters after : in <%s>\n",str);
exit(EXIT_FAILURE);
}
@@ -560,7 +558,7 @@ obj_list_t* parse_layout(const char *str,
else if (strcmp(slayout,"CHUNK")==0)
pack->layout=H5D_CHUNKED;
else {
- error_msg(progname, "in parse layout, not a valid layout in <%s>\n",str);
+ error_msg("in parse layout, not a valid layout in <%s>\n",str);
exit(EXIT_FAILURE);
}
}
@@ -584,7 +582,7 @@ obj_list_t* parse_layout(const char *str,
if (j>(int)len)
{
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> Chunk dimensions missing\n",str);
+ error_msg("in parse layout, <%s> Chunk dimensions missing\n",str);
exit(EXIT_FAILURE);
}
@@ -598,7 +596,7 @@ obj_list_t* parse_layout(const char *str,
&& c!='N' && c!='O' && c!='N' && c!='E'
){
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> Not a valid character in <%s>\n",
+ error_msg("in parse layout, <%s> Not a valid character in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
}
@@ -611,7 +609,7 @@ obj_list_t* parse_layout(const char *str,
pack->chunk.chunk_lengths[c_index]=atoi(sdim);
if (pack->chunk.chunk_lengths[c_index]==0) {
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
+ error_msg("in parse layout, <%s> conversion to number in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
}
@@ -629,7 +627,7 @@ obj_list_t* parse_layout(const char *str,
pack->chunk.chunk_lengths[c_index]=atoi(sdim);
if (pack->chunk.chunk_lengths[c_index]==0){
if (obj_list) free(obj_list);
- error_msg(progname, "in parse layout, <%s> conversion to number in <%s>\n",
+ error_msg("in parse layout, <%s> conversion to number in <%s>\n",
sdim,str);
exit(EXIT_FAILURE);
}
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index ac4570b..34c5dd6 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -14,9 +14,9 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "h5repack.h"
+#include "h5test.h"
#include "h5tools_utils.h"
-extern char *progname;
static int verify_layout(hid_t pid, pack_info_t *obj);
static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter);
@@ -211,26 +211,26 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* Get file creation property list for input file */
if((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto error;
}
/* Get file space management info for input file */
if(H5Pget_file_space(fcpl_in, &in_strat, &in_thresh) < 0) {
- error_msg(progname, "failed to retrieve file space strategy & threshold\n");
+ error_msg("failed to retrieve file space strategy & threshold\n");
goto error;
}
/* Output file is already opened */
/* Get file creation property list for output file */
if((fcpl_out = H5Fget_create_plist(fidout)) < 0) {
- error_msg(progname, "failed to retrieve file creation property list\n");
+ error_msg("failed to retrieve file creation property list\n");
goto error;
}
/* Get file space management info for output file */
if(H5Pget_file_space(fcpl_out, &out_strat, &out_thresh) < 0) {
- error_msg(progname, "failed to retrieve file space strategy & threshold\n");
+ error_msg("failed to retrieve file space strategy & threshold\n");
goto error;
}
@@ -243,11 +243,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* as what is set via the strategy option
*/
if(!options->fs_strategy && out_strat != in_strat) {
- error_msg(progname, "file space strategy not set as unexpected\n");
+ error_msg("file space strategy not set as unexpected\n");
goto error;
} else if(options->fs_strategy && out_strat!= options->fs_strategy) {
- error_msg(progname, "file space strategy not set as unexpectec\n");
+ error_msg("file space strategy not set as unexpectec\n");
goto error;
}
@@ -260,11 +260,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* as what is set via the threshold option.
*/
if(!options->fs_threshold && out_thresh != in_thresh) {
- error_msg(progname, "free space threshold not set as unexpected\n");
+ error_msg("free space threshold not set as unexpected\n");
goto error;
} else if(options->fs_threshold && out_thresh != options->fs_threshold) {
- error_msg(progname, "free space threshold not set as unexpectec\n");
+ error_msg("free space threshold not set as unexpectec\n");
goto error;
}
@@ -396,12 +396,12 @@ int h5repack_cmp_pl(const char *fname1,
/* Open the files */
if ((fid1=H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
{
- error_msg(progname, "<%s>: %s\n", fname1, H5FOPENERROR );
+ error_msg("<%s>: %s\n", fname1, H5FOPENERROR );
return -1;
}
if ((fid2=H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
{
- error_msg(progname, "<%s>: %s\n", fname2, H5FOPENERROR );
+ error_msg("<%s>: %s\n", fname2, H5FOPENERROR );
H5Fclose(fid1);
return -1;
}
@@ -450,7 +450,7 @@ int h5repack_cmp_pl(const char *fname1,
if ( crt_order_flag1 != crt_order_flag2 )
{
- error_msg(progname, "property lists for <%s> are different\n",trav->objs[i].name);
+ error_msg("property lists for <%s> are different\n",trav->objs[i].name);
goto error;
}
@@ -478,7 +478,7 @@ int h5repack_cmp_pl(const char *fname1,
if(ret == 0)
{
- error_msg(progname, "property lists for <%s> are different\n",trav->objs[i].name);
+ error_msg("property lists for <%s> are different\n",trav->objs[i].name);
goto error;
}
diff --git a/tools/h5repack/h5repacktst.c b/tools/h5repack/h5repacktst.c
index 68763d7..e329082 100644
--- a/tools/h5repack/h5repacktst.c
+++ b/tools/h5repack/h5repacktst.c
@@ -91,9 +91,8 @@ const char *H5REPACK_FILENAMES[] = {
#define H5REPACK_EXTFILE "h5repack_ext.bin"
-
-const char *progname = "h5repacktst";
-int d_status = EXIT_SUCCESS;
+/* Name of tool */
+#define PROGRAMNAME "h5repacktst"
#define DIM1 40
diff --git a/tools/h5repack/testh5repack_detect_szip.c b/tools/h5repack/testh5repack_detect_szip.c
index b16e0d4..332fcc5 100644
--- a/tools/h5repack/testh5repack_detect_szip.c
+++ b/tools/h5repack/testh5repack_detect_szip.c
@@ -16,8 +16,12 @@
#include <stdio.h>
#include "h5repack.h"
#include "h5tools.h"
+#include "h5test.h"
+/* Name of tool */
+#define PROGRAMNAME "h5repack_detect_szip"
+
/*-------------------------------------------------------------------------
* Function: main
*
@@ -40,6 +44,9 @@
int main(void)
{
+ h5tools_setprogname(PROGRAMNAME);
+ h5tools_setstatus(EXIT_SUCCESS);
+
#ifdef H5_HAVE_FILTER_SZIP
if (h5tools_can_encode(H5Z_FILTER_SZIP) == 1) {
printf("yes\n");