diff options
Diffstat (limited to 'tools/h5jam')
-rw-r--r-- | tools/h5jam/CMakeLists.txt | 81 | ||||
-rw-r--r-- | tools/h5jam/CMakeTests.cmake | 384 | ||||
-rw-r--r-- | tools/h5jam/Makefile.am | 45 | ||||
-rw-r--r-- | tools/h5jam/getub.c | 157 | ||||
-rw-r--r-- | tools/h5jam/h5jam.c | 571 | ||||
-rw-r--r-- | tools/h5jam/h5jamgentest.c | 389 | ||||
-rw-r--r-- | tools/h5jam/h5unjam.c | 411 | ||||
-rw-r--r-- | tools/h5jam/tellub.c | 196 | ||||
-rw-r--r-- | tools/h5jam/testfiles/h5jam-help.txt | 24 | ||||
-rw-r--r-- | tools/h5jam/testfiles/h5jam-ub-nohdf5.txt | 2 | ||||
-rw-r--r-- | tools/h5jam/testfiles/h5unjam-help.txt | 27 | ||||
-rw-r--r-- | tools/h5jam/testfiles/tall.h5 | bin | 9968 -> 0 bytes | |||
-rw-r--r-- | tools/h5jam/testfiles/twithub.h5 | bin | 10592 -> 0 bytes | |||
-rw-r--r-- | tools/h5jam/testfiles/twithub513.h5 | bin | 11056 -> 0 bytes | |||
-rw-r--r-- | tools/h5jam/testfiles/u10.txt | 1 | ||||
-rw-r--r-- | tools/h5jam/testfiles/u511.txt | 1 | ||||
-rw-r--r-- | tools/h5jam/testfiles/u512.txt | 1 | ||||
-rw-r--r-- | tools/h5jam/testfiles/u513.txt | 1 | ||||
-rw-r--r-- | tools/h5jam/testh5jam.sh.in | 699 |
19 files changed, 0 insertions, 2990 deletions
diff --git a/tools/h5jam/CMakeLists.txt b/tools/h5jam/CMakeLists.txt deleted file mode 100644 index d2600ca..0000000 --- a/tools/h5jam/CMakeLists.txt +++ /dev/null @@ -1,81 +0,0 @@ -cmake_minimum_required (VERSION 3.1.0) -PROJECT (HDF5_TOOLS_H5JAM) - -#----------------------------------------------------------------------------- -# Setup include Directories -#----------------------------------------------------------------------------- -INCLUDE_DIRECTORIES (${HDF5_TOOLS_DIR}/lib) - -# -------------------------------------------------------------------- -# Add the h5jam executables -# -------------------------------------------------------------------- -add_executable (h5jam ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5jam.c) -TARGET_NAMING (h5jam STATIC) -TARGET_C_PROPERTIES (h5jam STATIC " " " ") -target_link_libraries (h5jam ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (h5jam PROPERTIES FOLDER tools) -set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5jam") - -add_executable (getub ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/getub.c) -TARGET_NAMING (getub STATIC) -TARGET_C_PROPERTIES (getub STATIC " " " ") -target_link_libraries (getub ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (getub PROPERTIES FOLDER tools) - -add_executable (tellub ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/tellub.c) -TARGET_NAMING (tellub STATIC) -TARGET_C_PROPERTIES (tellub STATIC " " " ") -target_link_libraries (tellub ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (tellub PROPERTIES FOLDER tools) - -add_executable (h5unjam ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5unjam.c) -TARGET_NAMING (h5unjam STATIC) -TARGET_C_PROPERTIES (h5unjam STATIC " " " ") -target_link_libraries (h5unjam ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) -set_target_properties (h5unjam PROPERTIES FOLDER tools) -set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5unjam") - -set (H5_DEP_EXECUTABLES - h5jam - getub - tellub - h5unjam -) - -if (BUILD_TESTING) - # -------------------------------------------------------------------- - # Add the h5jam test executables - # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS) - add_executable (h5jamgentest ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5jamgentest.c) - TARGET_NAMING (h5jamgentest STATIC) - TARGET_C_PROPERTIES (testhdf5 STATIC " " " ") - target_link_libraries (h5jamgentest ${HDF5_LIB_TARGET}) - set_target_properties (h5jamgentest PROPERTIES FOLDER generator/tools) - - #add_test (NAME h5jamgentest COMMAND $<TARGET_FILE:h5jamgentest>) - endif (HDF5_BUILD_GENERATORS) - - include (CMakeTests.cmake) - -endif (BUILD_TESTING) - -############################################################################## -############################################################################## -### I N S T A L L A T I O N ### -############################################################################## -############################################################################## - -#----------------------------------------------------------------------------- -# Rules for Installation of tools using make Install target -#----------------------------------------------------------------------------- - -#INSTALL_PROGRAM_PDB (h5jam ${HDF5_INSTALL_BIN_DIR} toolsapplications) - -install ( - TARGETS - h5jam h5unjam - EXPORT - ${HDF5_EXPORTED_TARGETS} - RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications -) diff --git a/tools/h5jam/CMakeTests.cmake b/tools/h5jam/CMakeTests.cmake deleted file mode 100644 index 96061b0..0000000 --- a/tools/h5jam/CMakeTests.cmake +++ /dev/null @@ -1,384 +0,0 @@ - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - set (HDF5_REFERENCE_TXT_FILES - u10.txt - u511.txt - u512.txt - u513.txt - h5jam-help.txt - h5unjam-help.txt - h5jam-ub-nohdf5.txt - ) - set (HDF5_REFERENCE_TEST_FILES - tall.h5 - twithub.h5 - twithub513.h5 - ) - - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) - HDFTEST_COPY_FILE("${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5jam_files") - endforeach (h5_file ${HDF5_REFERENCE_TEST_FILES}) - - foreach (txt_file ${HDF5_REFERENCE_TXT_FILES}) - HDFTEST_COPY_FILE("${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${txt_file}" "${PROJECT_BINARY_DIR}/testfiles/${txt_file}" "h5jam_files") - endforeach (txt_file ${HDF5_REFERENCE_TXT_FILES}) - add_custom_target(h5jam_files ALL COMMENT "Copying files needed by h5jam tests" DEPENDS ${h5jam_files_list}) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - # ============================================================ - # TEST_H5JAM_OUTPUT - # For the purpose to verify only output & exitcode from h5jam - # - MACRO (TEST_H5JAM_OUTPUT expectfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-${expectfile} COMMAND $<TARGET_FILE:h5jam> ${ARGN}) - if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (H5JAM-${expectfile} PROPERTIES WILL_FAIL "true") - endif (NOT "${resultcode}" STREQUAL "0") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5JAM-${expectfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5jam>" - -D "TEST_ARGS:STRING=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=${expectfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=testfiles/${expectfile}.txt" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (TEST_H5JAM_OUTPUT) - - # ============================================================ - # TEST_H5UNJAM_OUTPUT - # For the purpose to verify only output & exitcode from h5unjam - # - MACRO (TEST_H5UNJAM_OUTPUT expectfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-UNJAM-${expectfile} COMMAND $<TARGET_FILE:h5unjam> ${ARGN}) - if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (H5JAM-UNJAM-${expectfile} PROPERTIES WILL_FAIL "true") - endif (NOT "${resultcode}" STREQUAL "0") - else (HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5JAM-UNJAM-${expectfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5unjam>" - -D "TEST_ARGS=${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=${expectfile}.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=testfiles/${expectfile}.txt" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif (HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (TEST_H5UNJAM_OUTPUT) - - MACRO (CHECKFILE testname testdepends expected actual) - # If using memchecker add tests without using scripts - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5JAM-${testname}-CHECKFILE-H5DMP - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=testfiles/${expected}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=${actual}.new" - -D "TEST_EXPECT=0" - -D "TEST_FILTER=(^(HDF5)[^\n]*)" - -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5JAM-${testname}-CHECKFILE-H5DMP PROPERTIES DEPENDS ${testdepends}) - add_test ( - NAME H5JAM-${testname}-CHECKFILE-H5DMP_CMP - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5dump>" - -D "TEST_ARGS:STRING=${actual}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=${actual}.out" - -D "TEST_EXPECT=0" - -D "TEST_FILTER=(^(HDF5)[^\n]*)" - -D "TEST_REFERENCE=${actual}.new" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5JAM-${testname}-CHECKFILE-H5DMP_CMP PROPERTIES DEPENDS H5JAM-${testname}-CHECKFILE-H5DMP) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO(CHECKFILE testname testdepends expected actual) - - MACRO (UNJAMTEST testname setfile infile ufile chkfile outfile) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5JAM-${testname}-UNJAM-SETUP-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove ${infile} - ) - add_test ( - NAME H5JAM-${testname}-UNJAM-SETUP - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${setfile} ${PROJECT_BINARY_DIR}/${infile} - ) - set_tests_properties (H5JAM-${testname}-UNJAM-SETUP PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-SETUP-clear-objects) - add_test ( - NAME H5JAM-${testname}-UNJAM-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove ${outfile} - ) - set_tests_properties (H5JAM-${testname}-UNJAM-clear-objects PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-SETUP) - if (NOT "${ufile}" STREQUAL "NONE") - add_test ( - NAME H5JAM-${testname}-UNJAM_D-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove ${ufile} - ) - set_tests_properties (H5JAM-${testname}-UNJAM_D-clear-objects PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) - add_test (NAME H5JAM-${testname}-UNJAM COMMAND $<TARGET_FILE:h5unjam> -i ${infile} -u ${ufile} -o ${outfile}) - set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM_D-clear-objects) - set (compare_test ${ufile}) - else (NOT "${ufile}" STREQUAL "NONE") - if (NOT "${ARGN}" STREQUAL "--delete") - add_test ( - NAME H5JAM-${testname}-UNJAM - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5unjam>" - -D "TEST_ARGS:STRING=-i;${infile};-o;${outfile}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=${outfile}.ufile.txt" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) - set (compare_test "${outfile}.ufile.txt") - else (NOT "${ARGN}" STREQUAL "--delete") - add_test (NAME H5JAM-${testname}-UNJAM COMMAND $<TARGET_FILE:h5unjam> -i ${infile} -o ${outfile}) - set_tests_properties (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) - set (compare_test "") - endif (NOT "${ARGN}" STREQUAL "--delete") - endif (NOT "${ufile}" STREQUAL "NONE") - if (NOT "${compare_test}" STREQUAL "") - add_test ( - NAME H5JAM-${testname}-UNJAM-CHECK_UB_1-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${infile}.len.txt - ${infile}.cmp - ${infile}-ub.cmp - ) - set_tests_properties (H5JAM-${testname}-UNJAM-CHECK_UB_1-clear-objects PROPERTIES DEPENDS "H5JAM-${testname}-UNJAM") - add_test ( - NAME H5JAM-${testname}-UNJAM-CHECK_UB_1 - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:tellub>" - -D "TEST_GET_PROGRAM=$<TARGET_FILE:getub>" - -D "TEST_CHECKUB=YES" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_HFILE=${infile}" - -D "TEST_UFILE=${compare_test}" - -D "TEST_EXPECT=0" - -D "TEST_OFILE=" - -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" - ) - set_tests_properties (H5JAM-${testname}-UNJAM-CHECK_UB_1 PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-CHECK_UB_1-clear-objects) - endif (NOT "${compare_test}" STREQUAL "") - - add_test ( - NAME H5JAM-${testname}-UNJAM-CHECK_NOUB - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:tellub>" - -D "TEST_GET_PROGRAM=$<TARGET_FILE:getub>" - -D "TEST_CHECKUB=NO" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_HFILE=${outfile}" - -D "TEST_EXPECT=0" - -D "TEST_UFILE=NULL" - -D "TEST_OFILE=NULL" - -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" - ) - if (NOT "${compare_test}" STREQUAL "") - set_tests_properties (H5JAM-${testname}-UNJAM-CHECK_NOUB PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-CHECK_UB_1) - else (NOT "${compare_test}" STREQUAL "") - set_tests_properties (H5JAM-${testname}-UNJAM-CHECK_NOUB PROPERTIES DEPENDS H5JAM-${testname}-UNJAM) - endif (NOT "${compare_test}" STREQUAL "") - - CHECKFILE (${testname} "H5JAM-${testname}-UNJAM-CHECK_NOUB" ${chkfile} ${outfile}) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO(UNJAMTEST testname infile ufile outfile) - - MACRO (JAMTEST testname jamfile infile chkfile outfile) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5JAM-${testname}-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove ${outfile} ${infile}.cpy.h5 - ) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5JAM-${testname} COMMAND $<TARGET_FILE:h5jam> -u testfiles/${jamfile} -i testfiles/${infile} -o ${outfile} ${ARGN}) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - set_tests_properties (H5JAM-${testname} PROPERTIES DEPENDS H5JAM-${testname}-clear-objects) - set (compare_test ${outfile}) - set (compare_orig testfiles/${infile}) - if ("${ARGN}" STREQUAL "--clobber") - set (compare_orig "") - endif ("${ARGN}" STREQUAL "--clobber") - - add_test ( - NAME H5JAM-${testname}-CHECK_UB_1-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${compare_test}.len.txt - ${compare_test}.cmp - ${compare_test}-ub.cmp - ) - set_tests_properties (H5JAM-${testname}-CHECK_UB_1-clear-objects PROPERTIES DEPENDS "H5JAM-${testname}") - add_test ( - NAME H5JAM-${testname}-CHECK_UB_1 - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:tellub>" - -D "TEST_GET_PROGRAM=$<TARGET_FILE:getub>" - -D "TEST_CHECKUB=YES" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_HFILE=${compare_test}" - -D "TEST_UFILE=testfiles/${jamfile}" - -D "TEST_EXPECT=0" - -D "TEST_OFILE=${compare_orig}" - -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" - ) - set_tests_properties (H5JAM-${testname}-CHECK_UB_1 PROPERTIES DEPENDS H5JAM-${testname}-CHECK_UB_1-clear-objects) - CHECKFILE (${testname} "H5JAM-${testname}-CHECK_UB_1" ${chkfile} ${outfile}) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (JAMTEST testname jamfile infile outfile) - - MACRO (JAMTEST_NONE testname jamfile infile setfile chkfile) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - add_test ( - NAME H5JAM-${testname}_NONE-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove - ${chkfile} ${chkfile}.cpy.h5 - ) - add_test ( - NAME H5JAM-${testname}_NONE-SETUP - COMMAND ${CMAKE_COMMAND} -E copy_if_different testfiles/${setfile} ${chkfile} - ) - set_tests_properties (H5JAM-${testname}_NONE-SETUP PROPERTIES DEPENDS H5JAM-${testname}_NONE-clear-objects) - - add_test ( - NAME H5JAM-${testname}_NONE_COPY - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${chkfile} ${chkfile}.cpy.h5 - ) - set_tests_properties (H5JAM-${testname}_NONE_COPY PROPERTIES DEPENDS H5JAM-${testname}_NONE-SETUP) - - add_test (NAME H5JAM-${testname}_NONE COMMAND $<TARGET_FILE:h5jam> -u testfiles/${jamfile} -i ${chkfile} ${ARGN}) - set_tests_properties (H5JAM-${testname}_NONE PROPERTIES DEPENDS H5JAM-${testname}_NONE_COPY) - - set (compare_test ${chkfile}) - set (compare_orig ${chkfile}.cpy.h5) - if ("${ARGN}" STREQUAL "--clobber") - set (compare_orig "") - endif ("${ARGN}" STREQUAL "--clobber") - - add_test ( - NAME H5JAM-${testname}_NONE-CHECK_UB_1-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${compare_test}.len.txt - ${compare_test}.cmp - ${compare_test}-ub.cmp - ) - set_tests_properties (H5JAM-${testname}_NONE-CHECK_UB_1-clear-objects PROPERTIES DEPENDS "H5JAM-${testname}_NONE") - add_test ( - NAME H5JAM-${testname}_NONE-CHECK_UB_1 - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:tellub>" - -D "TEST_GET_PROGRAM=$<TARGET_FILE:getub>" - -D "TEST_CHECKUB=YES" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_HFILE=${compare_test}" - -D "TEST_UFILE=testfiles/${jamfile}" - -D "TEST_EXPECT=0" - -D "TEST_OFILE=${compare_orig}" - -P "${HDF_RESOURCES_DIR}/userblockTest.cmake" - ) - set_tests_properties (H5JAM-${testname}_NONE-CHECK_UB_1 PROPERTIES DEPENDS H5JAM-${testname}_NONE-CHECK_UB_1-clear-objects) - CHECKFILE (${testname} "H5JAM-${testname}_NONE-CHECK_UB_1" ${infile} ${chkfile}) - endif (NOT HDF5_ENABLE_USING_MEMCHECKER) - ENDMACRO (JAMTEST_NONE testname jamfile infile setfile chkfile) - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - -#------------------------------- -# Testing h5jam -#------------------------------- - # help page - TEST_H5JAM_OUTPUT(h5jam-help 0 -h) - - # don't allow HDF5 format file as an user block file - TEST_H5JAM_OUTPUT(h5jam-ub-nohdf5 1 -i testfiles/tall.h5 -u testfiles/tall.h5 -o tall-tmp.h5) - - JAMTEST (tall_u10 u10.txt tall.h5 tall.h5 ta2.h5) - JAMTEST (tall_u511 u511.txt tall.h5 tall.h5 ta3.h5) - JAMTEST (tall_u512 u512.txt tall.h5 tall.h5 ta4.h5) - JAMTEST (tall_u513 u513.txt tall.h5 tall.h5 ta5.h5) - - JAMTEST_NONE (N_ta_u10 u10.txt tall.h5 tall.h5 ta6.h5) - JAMTEST_NONE (N_ta_u511 u511.txt tall.h5 tall.h5 ta7.h5) - JAMTEST_NONE (N_ta_u512 u512.txt tall.h5 tall.h5 ta8.h5) - JAMTEST_NONE (N_ta_u513 u513.txt tall.h5 tall.h5 ta9.h5) - - JAMTEST (twithub_u10 u10.txt twithub.h5 tall.h5 tax2.h5) - JAMTEST (twithub_u511 u511.txt twithub.h5 tall.h5 tax3.h5) - JAMTEST (twithub_u512 u512.txt twithub.h5 tall.h5 tax4.h5) - JAMTEST (twithub_u513 u513.txt twithub.h5 tall.h5 tax5.h5) - - JAMTEST (twithub513_u10 u10.txt twithub513.h5 tall.h5 tax6.h5) - JAMTEST (twithub513_u511 u511.txt twithub513.h5 tall.h5 tax7.h5) - JAMTEST (twithub513_u512 u512.txt twithub513.h5 tall.h5 tax8.h5) - JAMTEST (twithub513_u513 u513.txt twithub513.h5 tall.h5 tax9.h5) - - JAMTEST (twithub_u10_c u10.txt twithub.h5 tall.h5 taz2.h5 --clobber) - JAMTEST (twithub_u511_c u511.txt twithub.h5 tall.h5 taz3.h5 --clobber) - JAMTEST (twithub_u512_c u512.txt twithub.h5 tall.h5 taz4.h5 --clobber) - JAMTEST (twithub_u513_c u513.txt twithub.h5 tall.h5 taz5.h5 --clobber) - - JAMTEST (twithub513_u10_c u10.txt twithub513.h5 tall.h5 taz6.h5 --clobber) - JAMTEST (twithub513_u511_c u511.txt twithub513.h5 tall.h5 taz7.h5 --clobber) - JAMTEST (twithub513_u512_c u512.txt twithub513.h5 tall.h5 taz8.h5 --clobber) - JAMTEST (twithub513_u513_c u513.txt twithub513.h5 tall.h5 taz9.h5 --clobber) - - JAMTEST_NONE (N_twithub_u10_c u10.txt tall.h5 twithub.h5 tay2.h5 --clobber) - JAMTEST_NONE (N_twithub_u511_c u511.txt tall.h5 twithub.h5 tay3.h5 --clobber) - JAMTEST_NONE (N_twithub_u512_c u512.txt tall.h5 twithub.h5 tay4.h5 --clobber) - JAMTEST_NONE (N_twithub_u513_c u513.txt tall.h5 twithub.h5 tay5.h5 --clobber) - - JAMTEST_NONE (N_twithub513_u10_c u10.txt tall.h5 twithub513.h5 tay6.h5 --clobber) - JAMTEST_NONE (N_twithub513_u511_c u511.txt tall.h5 twithub513.h5 tay7.h5 --clobber) - JAMTEST_NONE (N_twithub513_u512_c u512.txt tall.h5 twithub513.h5 tay8.h5 --clobber) - JAMTEST_NONE (N_twithub513_u513_c u513.txt tall.h5 twithub513.h5 tay9.h5 --clobber) - -#------------------------------- -# Testing h5unjam -#------------------------------- - # help page - TEST_H5UNJAM_OUTPUT(h5unjam-help 0 -h) - - UNJAMTEST (twithub_tall twithub.h5 tai1.h5 o10.txt tall.h5 taa1.h5) - UNJAMTEST (twithub513_tall twithub513.h5 tai2.h5 o512.txt tall.h5 taa2.h5) - - UNJAMTEST (N_twithub_tall twithub.h5 tai3.h5 NONE tall.h5 taa3.h5) - UNJAMTEST (N_twithub513_tall twithub513.h5 tai4.h5 NONE tall.h5 taa4.h5) - - UNJAMTEST (D_twithub_tall twithub.h5 taj2.h5 NONE tall.h5 tac2.h5 --delete) - UNJAMTEST (D_twithub513_tall twithub513.h5 taj3.h5 NONE tall.h5 tac3.h5 --delete) diff --git a/tools/h5jam/Makefile.am b/tools/h5jam/Makefile.am deleted file mode 100644 index 60a62b9..0000000 --- a/tools/h5jam/Makefile.am +++ /dev/null @@ -1,45 +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 files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -## -## Makefile.am -## Run automake to generate a Makefile.in from this file. -# -# HDF5 Library Makefile(.in) -# - -include $(top_srcdir)/config/commence.am - -# Include src and tools/lib directories -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib - -bin_PROGRAMS=h5jam h5unjam -check_PROGRAMS=tellub h5jamgentest getub -TEST_SCRIPT=testh5jam.sh - -# Add h5jam and h5unjam specific linker flags here -h5jam_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) -h5unjam_LDFLAGS = $(LT_STATIC_EXEC) $(AM_LDFLAGS) - -check_SCRIPTS=$(TEST_SCRIPT) -SCRIPT_DEPEND=h5jam$(EXEEXT) h5unjam$(EXEEXT) - -# Link against the main HDF5 library and tools library -LDADD=$(LIBH5TOOLS) $(LIBHDF5) - -# Temporary files. *.h5 are generated by jamgentest. They should -# copied to the testfiles/ directory if update is required. -CHECK_CLEANFILES+=*.h5 testfiles/h5jam-*-sav testfiles/h5unjam-*-sav -DISTCLEANFILES=testh5jam.sh - -include $(top_srcdir)/config/conclude.am diff --git a/tools/h5jam/getub.c b/tools/h5jam/getub.c deleted file mode 100644 index 4e02e6b..0000000 --- a/tools/h5jam/getub.c +++ /dev/null @@ -1,157 +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 files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_utils.h" - -void parse_command_line(int argc, const char *argv[]); - -/* Name of tool */ -#define PROGRAM_NAME "getub" -char *nbytes = NULL; - -static const char *s_opts = "c:"; /* add more later ? */ -static struct long_options l_opts[] = { - {"c", require_arg, 'c'}, /* input file */ - {NULL, 0, '\0'} -}; - -/*------------------------------------------------------------------------- - * Function: usage - * - * Purpose: Print the usage message - * - * Return: void - *------------------------------------------------------------------------- - */ -static void -usage (const char *prog) -{ - HDfflush(stdout); - HDfprintf(stdout, "usage: %s -c nb file] \n", prog); - HDfprintf(stdout, " print first 'nb' byts of file to stdoug.\n"); -} - -/*------------------------------------------------------------------------- - * Function: parse_command_line - * - * Purpose: Parse the command line for the h5dumper. - * - * Return: Success: - * - * Failure: Exits program with EXIT_FAILURE value. - *------------------------------------------------------------------------- - */ -void -parse_command_line(int argc, const char *argv[]) -{ - int opt; - - /* parse command line options */ - while((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'c': - nbytes = HDstrdup(opt_arg); - break; - case '?': - default: - usage(h5tools_getprogname()); - HDexit(EXIT_FAILURE); - } /* end switch */ - } /* end while */ - - if(argc <= opt_ind) { - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - HDexit(EXIT_FAILURE); - } /* end if */ -} /* end parse_command_line() */ - -int -main(int argc, const char *argv[]) -{ - int fd = -1; - unsigned size; - char *filename = NULL; - long res; - char *buf = NULL; - - h5tools_setprogname(PROGRAM_NAME); - h5tools_setstatus(EXIT_SUCCESS); - - /* Initialize h5tools lib */ - h5tools_init(); - - parse_command_line(argc, argv); - - if(NULL == nbytes) { - /* missing arg */ - error_msg("missing size\n"); - usage(h5tools_getprogname()); - goto error; - } /* end if */ - - if(argc <= (opt_ind)) { - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - goto error; - } /* end if */ - - filename = HDstrdup(argv[opt_ind]); - - size = 0; - if(EOF == (res = sscanf(nbytes, "%u", &size))) { - /* fail */ - error_msg("missing file name\n"); - usage(h5tools_getprogname()); - goto error; - } /* end if */ - - if((fd = HDopen(filename, O_RDONLY, 0)) < 0) { - error_msg("can't open file %s\n", filename); - goto error; - } /* end if */ - - if(NULL == (buf = (char *)HDmalloc((unsigned)(size + 1)))) { - error_msg("can't allocate buffer \n"); - goto error; - } /* end if */ - - res = HDread(fd, buf, (unsigned)size); - if(res < (long)size) { - error_msg("Bad read \n"); - goto error; - } /* end if */ - - if(HDwrite(1, buf, (unsigned)size) < 0) { - error_msg("Bad write \n"); - goto error; - } /* end if */ - - /* close things and exit */ - HDfree(buf); - HDclose(fd); - - return EXIT_SUCCESS; - -error: - if(buf) - HDfree(buf); - if(fd > -1) - HDclose(fd); - return EXIT_FAILURE; -} /* end main() */ - diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c deleted file mode 100644 index ae45714..0000000 --- a/tools/h5jam/h5jam.c +++ /dev/null @@ -1,571 +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 files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_utils.h" - -/* Name of tool */ -#define PROGRAMNAME "h5jam" - -herr_t write_pad(int ofile, hsize_t old_where, hsize_t *new_where); -hsize_t compute_user_block_size (hsize_t); -hsize_t copy_some_to_file (int, int, hsize_t, hsize_t, ssize_t); -void parse_command_line (int, const char *[]); - -int do_clobber = FALSE; -char *output_file = NULL; -char *input_file = NULL; -char *ub_file = NULL; - -/* - * Command-line options: The user can specify short or long-named - * parameters. The long-named ones can be partially spelled. When - * adding more, make sure that they don't clash with each other. - */ -static const char *s_opts = "hi:u:o:c:V"; /* add more later ? */ -static struct long_options l_opts[] = { - {"help", no_arg, 'h'}, - {"hel", no_arg, 'h'}, - {"i", require_arg, 'i'}, /* input file */ - {"u", require_arg, 'u'}, /* user block file */ - {"o", require_arg, 'o'}, /* output file */ - {"clobber", no_arg, 'c'}, /* clobber existing UB */ - {"clobbe", no_arg, 'c'}, - {"clobb", no_arg, 'c'}, - {"clob", no_arg, 'c'}, - {"clo", no_arg, 'c'}, - {"cl", no_arg, 'c'}, - {NULL, 0, '\0'} -}; - -/*------------------------------------------------------------------------- - * Function: usage - * - * Purpose: Print the usage message - * - * Return: void - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -usage (const char *prog) -{ - HDfflush (stdout); - HDfprintf (stdout, - "usage: %s -i <in_file.h5> -u <in_user_file> [-o <out_file.h5>] [--clobber]\n", prog); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - "Adds user block to front of an HDF5 file and creates a new concatenated file.\n"); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - "OPTIONS\n"); - HDfprintf (stdout, - " -i in_file.h5 Specifies the input HDF5 file.\n"); - HDfprintf (stdout, - " -u in_user_file Specifies the file to be inserted into the user block.\n"); - HDfprintf (stdout, - " Can be any file format except an HDF5 format.\n"); - HDfprintf (stdout, - " -o out_file.h5 Specifies the output HDF5 file.\n"); - HDfprintf (stdout, - " If not specified, the user block will be concatenated in\n"); - HDfprintf (stdout, - " place to the input HDF5 file.\n"); - HDfprintf (stdout, - " --clobber Wipes out any existing user block before concatenating\n"); - HDfprintf (stdout, - " the given user block.\n"); - HDfprintf (stdout, - " The size of the new user block will be the larger of;\n"); - HDfprintf (stdout, - " - the size of existing user block in the input HDF5 file\n"); - HDfprintf (stdout, - " - the size of user block required by new input user file\n"); - HDfprintf (stdout, - " (size = 512 x 2N, N is positive integer.)\n"); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - " -h Prints a usage message and exits.\n"); - HDfprintf (stdout, - " -V Prints the HDF5 library version and exits.\n"); - HDfprintf (stdout, "\n"); - HDfprintf (stdout, - "Exit Status:\n"); - HDfprintf (stdout, - " 0 Succeeded.\n"); - HDfprintf (stdout, - " >0 An error occurred.\n"); -} - - -/*------------------------------------------------------------------------- - * Function: leave - * - * Purpose: Shutdown and call exit() - * - * Return: Does not return - * - *------------------------------------------------------------------------- - */ -static void -leave(int ret) -{ - if (ub_file) - HDfree (ub_file); - if (input_file) - HDfree (input_file); - if (output_file) - HDfree (output_file); - - h5tools_close(); - - HDexit(ret); -} - -/*------------------------------------------------------------------------- - * Function: parse_command_line - * - * Purpose: Parse the command line for the h5dumper. - * - * Return: Success: - * - * Failure: Exits program with EXIT_FAILURE value. - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -void -parse_command_line (int argc, const char *argv[]) -{ - int opt = FALSE; - - /* parse command line options */ - while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) - { - switch ((char) opt) - { - case 'o': - output_file = HDstrdup (opt_arg); - break; - case 'i': - input_file = HDstrdup (opt_arg); - break; - case 'u': - ub_file = HDstrdup (opt_arg); - break; - case 'c': - do_clobber = TRUE; - break; - case 'h': - usage (h5tools_getprogname()); - leave (EXIT_SUCCESS); - case 'V': - print_version (h5tools_getprogname()); - leave (EXIT_SUCCESS); - case '?': - default: - usage (h5tools_getprogname()); - leave (EXIT_FAILURE); - } - } -} - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: HDF5 user block jammer - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -main (int argc, const char *argv[]) -{ - int ufid = -1; - int h5fid = -1; - int ofid = -1; - void *edata; - H5E_auto2_t func; - hid_t ifile = -1; - hid_t plist = -1; - herr_t status; - htri_t testval; - hsize_t usize; - hsize_t h5fsize; - hsize_t startub; - hsize_t where; - hsize_t newubsize; - off_t fsize; - h5_stat_t sbuf; - h5_stat_t sbuf2; - int res; - - h5tools_setprogname(PROGRAMNAME); - h5tools_setstatus(EXIT_SUCCESS); - - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - - /* Initialize h5tools lib */ - h5tools_init(); - - parse_command_line (argc, argv); - - if (ub_file == NULL) { - /* no user block */ - error_msg("missing arguemnt for -u <user_file>.\n"); - help_ref_msg(stderr); - leave (EXIT_FAILURE); - } - - testval = H5Fis_hdf5 (ub_file); - - if (testval > 0) { - error_msg("-u <user_file> cannot be HDF5 file, but it appears to be an HDF5 file.\n"); - help_ref_msg(stderr); - leave (EXIT_FAILURE); - } - - if (input_file == NULL) { - error_msg("missing arguemnt for -i <HDF5 file>.\n"); - help_ref_msg(stderr); - leave (EXIT_FAILURE); - } - - testval = H5Fis_hdf5 (input_file); - - if (testval <= 0) { - error_msg("Input HDF5 file \"%s\" is not HDF5 format.\n", input_file); - help_ref_msg(stderr); - leave (EXIT_FAILURE); - } - - ifile = H5Fopen (input_file, H5F_ACC_RDONLY, H5P_DEFAULT); - - if (ifile < 0) { - error_msg("Can't open input HDF5 file \"%s\"\n", input_file); - leave (EXIT_FAILURE); - } - - plist = H5Fget_create_plist (ifile); - if (plist < 0) { - error_msg("Can't get file creation plist for file \"%s\"\n", input_file); - H5Fclose(ifile); - leave (EXIT_FAILURE); - } - - status = H5Pget_userblock (plist, &usize); - if (status < 0) { - error_msg("Can't get user block for file \"%s\"\n", input_file); - H5Pclose(plist); - H5Fclose(ifile); - leave (EXIT_FAILURE); - } - - H5Pclose(plist); - H5Fclose(ifile); - - ufid = HDopen(ub_file, O_RDONLY, 0); - if(ufid < 0) { - error_msg("unable to open user block file \"%s\"\n", ub_file); - leave (EXIT_FAILURE); - } - - res = HDfstat(ufid, &sbuf); - if(res < 0) { - error_msg("Can't stat file \"%s\"\n", ub_file); - HDclose (ufid); - leave (EXIT_FAILURE); - } - - fsize = (off_t)sbuf.st_size; - - h5fid = HDopen(input_file, O_RDONLY, 0); - if(h5fid < 0) { - error_msg("unable to open HDF5 file for read \"%s\"\n", input_file); - HDclose (ufid); - leave (EXIT_FAILURE); - } - - res = HDfstat(h5fid, &sbuf2); - if(res < 0) { - error_msg("Can't stat file \"%s\"\n", input_file); - HDclose (h5fid); - HDclose (ufid); - leave (EXIT_FAILURE); - } - - h5fsize = (hsize_t)sbuf2.st_size; - - if (output_file == NULL) { - ofid = HDopen (input_file, O_WRONLY, 0); - - if (ofid < 0) { - error_msg("unable to open output file \"%s\"\n", output_file); - HDclose (h5fid); - HDclose (ufid); - leave (EXIT_FAILURE); - } - } - else { - ofid = HDopen (output_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); - - if (ofid < 0) { - error_msg("unable to create output file \"%s\"\n", output_file); - HDclose (h5fid); - HDclose (ufid); - leave (EXIT_FAILURE); - } - } - - newubsize = compute_user_block_size ((hsize_t) fsize); - - startub = usize; - - if (usize > 0) { - if (do_clobber == TRUE) { - /* where is max of the current size or the new UB */ - if (usize > newubsize) { - newubsize = usize; - } - startub = 0; /*blast the old */ - } - else { - /* add new ub to current ublock, pad to new offset */ - newubsize += usize; - newubsize = compute_user_block_size ((hsize_t) newubsize); - } - } - - /* copy the HDF5 from starting at usize to starting at newubsize: - * makes room at 'from' for new ub */ - /* if no current ub, usize is 0 */ - copy_some_to_file (h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize)); - - /* copy the old ub to the beginning of the new file */ - if (!do_clobber) { - where = copy_some_to_file (h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize); - } - - /* copy the new ub to the end of the ub */ - where = copy_some_to_file (ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); - - /* pad the ub */ - if(write_pad(ofid, where, &where) < 0) { - error_msg("Can't pad file \"%s\"\n", output_file); - HDclose (h5fid); - HDclose (ufid); - HDclose (ofid); - leave (EXIT_FAILURE); - } /* end if */ - - if(ub_file) - HDfree (ub_file); - if(input_file) - HDfree (input_file); - if(output_file) - HDfree (output_file); - - if(ufid >= 0) - HDclose (ufid); - if(h5fid >= 0) - HDclose (h5fid); - if(ofid >= 0) - HDclose (ofid); - - return h5tools_getstatus(); -} - -/*------------------------------------------------------------------------- - * Function: copy_some_to_file - * - * Purpose: Copy part of the input file to output. - * infid: fd of file to read - * outfid: fd of file to write - * startin: offset of where to read from infid - * startout: offset of where to write to outfid - * limit: bytes to read/write - * - * If limit is < 0, the entire input file is copied. - * - * Note: this routine can be used to copy within - * the same file, i.e., infid and outfid can be the - * same file. - * - * Return: Success: last byte written in the output. - * Failure: Exits program with EXIT_FAILURE value. - * - *------------------------------------------------------------------------- - */ -hsize_t -copy_some_to_file(int infid, int outfid, hsize_t startin, hsize_t startout, - ssize_t limit) -{ - char buf[1024]; - h5_stat_t sbuf; - int res; - ssize_t tot = 0; - ssize_t howmuch = 0; - ssize_t nchars = -1; - ssize_t to; - ssize_t from; - ssize_t toend; - ssize_t fromend; - - if(startin > startout) { - /* this case is prohibited */ - error_msg("copy_some_to_file: panic: startin > startout?\n"); - exit (EXIT_FAILURE); - } /* end if */ - - if(limit < 0) { - res = HDfstat(infid, &sbuf); - if(res < 0) { - error_msg("Can't stat file \n"); - HDexit(EXIT_FAILURE); - } /* end if */ - - howmuch = (ssize_t)sbuf.st_size; - } else { - howmuch = limit; - } /* end if */ - - if(0 == howmuch) - return 0; - - toend = (ssize_t) startout + howmuch; - fromend = (ssize_t) startin + howmuch; - - if (howmuch > 512) { - to = toend - 512; - from = fromend - 512; - } else { - to = toend - howmuch; - from = fromend - howmuch; - } /* end if */ - - while (howmuch > 0) { - HDlseek(outfid, (off_t) to, SEEK_SET); - HDlseek(infid, (off_t) from, SEEK_SET); - - if (howmuch > 512) { - nchars = HDread(infid, buf, (unsigned) 512); - } else { - nchars = HDread(infid, buf, (unsigned)howmuch); - } /* end if */ - - if (nchars <= 0) { - error_msg("Read error \n"); - HDexit(EXIT_FAILURE); - } /* end if */ - - if(HDwrite (outfid, buf, (unsigned) nchars) < 0) { - error_msg("Write error \n"); - HDexit(EXIT_FAILURE); - } - - tot += nchars; - howmuch -= nchars; - if(howmuch > 512) { - to -= nchars; - from -= nchars; - } else { - to -= howmuch; - from -= howmuch; - } /* end if */ - } /* end while */ - - return (hsize_t)tot + (hsize_t)startout; -} /* end copy_some_to_file() */ - - -/*------------------------------------------------------------------------- - * Function: compute_user_block_size - * - * Purpose: Find the offset of the HDF5 header after the user block: - * align at 0, 512, 1024, etc. - * ublock_size: the size of the user block (bytes). - * - * Return: Success: the location of the header == the size of the - * padded user block. - * Failure: none - * - * Return: Success: last byte written in the output. - * Failure: Exits program with EXIT_FAILURE value. - *------------------------------------------------------------------------- - */ -H5_ATTR_CONST hsize_t -compute_user_block_size(hsize_t ublock_size) -{ - hsize_t where = 512; - - if(0 == ublock_size) - return 0; - - while(where < ublock_size) - where *= 2; - - return where; -} /* end compute_user_block_size() */ - -/* - * Write zeroes to fill the file from 'where' to 512, 1024, etc. bytes. - * - * Sets new_where to the size of the padded file and - * returns SUCCEED/FAIL. - */ -herr_t -write_pad(int ofile, hsize_t old_where, hsize_t *new_where) -{ - unsigned int i; - char buf[1]; - hsize_t psize; - - HDassert(new_where); - - buf[0] = '\0'; - - HDlseek(ofile, (off_t)old_where, SEEK_SET); - - psize = compute_user_block_size(old_where); - psize -= old_where; - - for(i = 0; i < psize; i++) - if(HDwrite(ofile, buf, 1) < 0) - return FAIL; - - /* Set the new size of the file. */ - *new_where = old_where + psize; - - return SUCCEED; -} /* end write_pad() */ - diff --git a/tools/h5jam/h5jamgentest.c b/tools/h5jam/h5jamgentest.c deleted file mode 100644 index a12b17a..0000000 --- a/tools/h5jam/h5jamgentest.c +++ /dev/null @@ -1,389 +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 files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Generate the binary hdf5 files and user block data for the jam/unjam tests. - * Usage: just execute the program without any arguments will - * generate all the files in the local directory. - * - * If you regenerate the test files (e.g., changing some code, - * trying it on a new platform, ...), you need to verify the correctness - * of the expected output and update the corresponding *.ddl files. - */ -#include <assert.h> -#include <limits.h> - -#include "hdf5.h" -#include "H5private.h" - -/* not used yet -#define UBTXT1 "u0.txt" -*/ -#define UBTXT2 "u10.txt" -#define UBTXT3 "u511.txt" -#define UBTXT4 "u512.txt" -#define UBTXT5 "u513.txt" -/* not used yet -#define UBTXT6 "u1023.txt" -#define UBTXT7 "u1024.txt" -#define UBTXT8 "u1025.txt" -#define UBTXT9 "u2047.txt" -#define UBTXT10 "u2048.txt" -#define UBTXT11 "u2049.txt" -#define UBBIN1 "u0.dat" -#define UBBIN2 "u10.dat" -#define UBBIN3 "u511.dat" -#define UBBIN4 "u512.dat" -#define UBBIN5 "u513.dat" -*/ - -/* not used yet -#define FILE1 "tnull.h5" -#define FILE2 "tnullwithub.h5" -*/ -/* tall is same as dumper test */ -#define FILE7 "tall.h5" -#define FILE8 "twithub.h5" -#define FILE9 "twithub513.h5" - -/* - * This pattern is used to fill text files - */ -char pattern[11] = "abcdefghij"; - -/*------------------------------------------------------------------------- - * prototypes - *------------------------------------------------------------------------- - */ - - -#define BUF_SIZE 1024 - -/* Element selection information */ - -typedef enum{ - RED, - GREEN, - BLUE, - WHITE, - BLACK -} enumtype; - -/* Compound datatype */ -typedef struct s1_t { - unsigned int a; - unsigned int b; - float c; -} s1_t; - - -/* A UD link traversal function. Shouldn't actually be called. */ -static hid_t UD_traverse(const char H5_ATTR_UNUSED * link_name, hid_t H5_ATTR_UNUSED cur_group, - const void H5_ATTR_UNUSED * udata, size_t H5_ATTR_UNUSED udata_size, hid_t H5_ATTR_UNUSED lapl_id) -{ - return -1; -} - -#define MY_LINKCLASS 187 -const H5L_class_t UD_link_class[1] = {{ - H5L_LINK_CLASS_T_VERS, /* H5L_class_t version */ - (H5L_type_t)MY_LINKCLASS, /* Link type id number */ - "UD link class", /* name for debugging */ - NULL, /* Creation callback */ - NULL, /* Move/rename callback */ - NULL, /* Copy callback */ - UD_traverse, /* The actual traversal function */ - NULL, /* Deletion callback */ - NULL /* Query callback */ -}}; - - - -/* gent_ub - with no ub, identical to gent_all from h5dumpgentest.c - - FILENAME is the name of the file to create - UB_SIZE is the size the buffer should be - UB_FILL characters will be set to the PATTERN array, - the rest of the user block will be NULL. - -/ : g1 g2 attr1 attr2 -g1 : g1.1 g1.2 -g1.1 : dset1.1.1(attr1, attr2) dset1.1.2 -g1.2 : g1.2.1 extlink -g1.2.1 : slink -g2 : dset2.1 dset2.2 udlink - -*/ - -static void -gent_ub(const char * filename, size_t ub_size, size_t ub_fill) -{ - hid_t fid, group, attr, dataset, space; - hid_t create_plist; - hsize_t dims[2]; - int data[2][2], dset1[10][10], dset2[20]; - char buf[BUF_SIZE]; - int i, j; - size_t u; - float dset2_1[10], dset2_2[3][5]; - int fd; - char *bp; - - if(ub_size > 0) - { - create_plist = H5Pcreate(H5P_FILE_CREATE); - H5Pset_userblock(create_plist, (hsize_t)ub_size); - fid = H5Fcreate(filename, H5F_ACC_TRUNC, create_plist, H5P_DEFAULT); - } - else - { - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - } - - /* create groups */ - group = H5Gcreate2(fid, "/g1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gcreate2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - /* root attributes */ - group = H5Gopen2(fid, "/", H5P_DEFAULT); - - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(group, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "abcdefghi"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 2; dims[1] = 2; - space = H5Screate_simple(2, dims, NULL); - attr = H5Acreate2(group, "attr2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT); - data[0][0] = 0; data[0][1] = 1; data[1][0] = 2; data[1][1] = 3; - H5Awrite(attr, H5T_NATIVE_INT, data); - H5Sclose(space); - H5Aclose(attr); - - H5Gclose(group); - - group = H5Gopen2(fid, "/g1/g1.1", H5P_DEFAULT); - - /* dset1.1.1 */ - dims[0] = 10; dims[1] = 10; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.1", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 10; i++) - for (j = 0; j < 10; j++) - dset1[i][j] = j*i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset1); - H5Sclose(space); - - /* attributes of dset1.1.1 */ - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr1", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "1st attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - dims[0] = 27; - space = H5Screate_simple(1, dims, NULL); - attr = H5Acreate2(dataset, "attr2", H5T_STD_I8BE, space, H5P_DEFAULT, H5P_DEFAULT); - sprintf(buf, "2nd attribute of dset1.1.1"); - H5Awrite(attr, H5T_NATIVE_SCHAR, buf); - H5Sclose(space); - H5Aclose(attr); - - H5Dclose(dataset); - - /* dset1.1.2 */ - dims[0] = 20; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset1.1.2", H5T_STD_I32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 20; i++) - dset2[i] = i; - H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* external link */ - H5Lcreate_external("somefile", "somepath", fid, "/g1/g1.2/extlink", H5P_DEFAULT, H5P_DEFAULT); - - /* soft link */ - group = H5Gopen2(fid, "/g1/g1.2/g1.2.1", H5P_DEFAULT); - H5Lcreate_soft("somevalue", group, "slink", H5P_DEFAULT, H5P_DEFAULT); - H5Gclose(group); - - group = H5Gopen2(fid, "/g2", H5P_DEFAULT); - - /* dset2.1 */ - dims[0] = 10; - space = H5Screate_simple(1, dims, NULL); - dataset = H5Dcreate2(group, "dset2.1", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 10; i++) - dset2_1[i] = (float)((float)i * 0.1F + 1.0F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_1); - H5Sclose(space); - H5Dclose(dataset); - - /* dset2.2 */ - dims[0] = 3; dims[1] = 5; - space = H5Screate_simple(2, dims, NULL); - dataset = H5Dcreate2(group, "dset2.2", H5T_IEEE_F32BE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - for (i = 0; i < 3; i++) - for (j = 0; j < 5; j++) - dset2_2[i][j] = (float)(((float)i + 1.0F) * (float)j * 0.1F); - H5Dwrite(dataset, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset2_2); - H5Sclose(space); - H5Dclose(dataset); - - H5Gclose(group); - - /* user-defined link */ - H5Lregister(UD_link_class); - H5Lcreate_ud(fid, "/g2/udlink", (H5L_type_t)MY_LINKCLASS, NULL, (size_t)0, H5P_DEFAULT, H5P_DEFAULT); - - H5Fclose(fid); - - /* If a user block is being used, write to it here */ - if(ub_size > 0) - { - ssize_t nbytes; - - HDassert(ub_size <= BUF_SIZE); - - fd = HDopen(filename, O_RDWR, 0); - HDassert(fd >= 0); - - /* fill buf with pattern */ - HDmemset(buf, '\0', ub_size); - bp = buf; - for (u = 0; u < ub_fill; u++) - *bp++ = pattern[u % 10]; - - nbytes = HDwrite(fd, buf, ub_size); - HDassert(nbytes >= 0); - - HDclose(fd); - } -} - -static void -create_textfile(const char *name, size_t size) -{ - char *buf; - int fd; - size_t i; - char *bp; - ssize_t nbytes; - - fd = HDcreat(name,0777); - HDassert(fd >= 0); - buf = (char *)HDcalloc(size, (size_t)1); - HDassert(buf); - - /* fill buf with pattern */ - bp = buf; - for(i = 0; i < size; i++) - *bp++ = pattern[i % 10]; - - nbytes = HDwrite(fd, buf, size); - HDassert(nbytes >= 0); - - HDfree(buf); - - HDclose(fd); -} - -#ifdef notdef -/* not used yet */ -void -create_binfile(char *name, off_t size) -{ - char *buf; - int fd; - int i; - char *bp; - - fd = creat(name,0777); - HDassert(fd >= 0); - - buf = HDcalloc(size,1); - HDassert(buf); - - /* fill buf with pattern */ - bp = buf; - for (i = 0; i < size; i++) - *bp++ = (char) i & 0xff; - - HDwrite(fd,buf,size); - - HDclose(fd); -} -#endif - -/*------------------------------------------------------------------------- - * Function: main - * - *------------------------------------------------------------------------- - */ - - -int main(void) -{ - -/* -create_textfile(UBTXT1, (size_t)0); -*/ -create_textfile(UBTXT2, (size_t)10); -create_textfile(UBTXT3, (size_t)511); -create_textfile(UBTXT4, (size_t)512); -create_textfile(UBTXT5, (size_t)513); -/* -create_textfile(UBTXT6, (size_t)1023); -create_textfile(UBTXT7, (size_t)1024); -create_textfile(UBTXT8, (size_t)1025); -create_textfile(UBTXT9, (size_t)2047); -create_textfile(UBTXT10, (size_t)2048); -create_textfile(UBTXT11, (size_t)2049); - -create_binfile(UBBIN1, (off_t)0); -create_binfile(UBBIN2, (off_t)10); -create_binfile(UBBIN3, (off_t)511); -create_binfile(UBBIN4, (off_t)512); -create_binfile(UBBIN5, (off_t)513); - -*/ - gent_ub(FILE7, (size_t)0, (size_t)0); - gent_ub(FILE8, (size_t)512, HDstrlen(pattern)); - gent_ub(FILE9, (size_t)1024, (size_t)513); - - return 0; -} diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c deleted file mode 100644 index 8f88398..0000000 --- a/tools/h5jam/h5unjam.c +++ /dev/null @@ -1,411 +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 files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_utils.h" - -/* Name of tool */ -#define PROGRAMNAME "h5unjam" - -#define COPY_BUF_SIZE 1024 - -hsize_t write_pad( int , hsize_t ); -hsize_t compute_pad( hsize_t ); -herr_t copy_to_file( FILE *, FILE * , ssize_t, ssize_t ); - -int do_delete = FALSE; -char *output_file = NULL; -char *input_file = NULL; -char *ub_file = NULL; - -/* - * Command-line options: The user can specify short or long-named - * parameters. The long-named ones can be partially spelled. When - * adding more, make sure that they don't clash with each other. - */ -static const char *s_opts = "hu:i:o:d:V"; -static struct long_options l_opts[] = { - { "help", no_arg, 'h' }, - { "hel", no_arg, 'h' }, - {"i", require_arg, 'i'}, /* input file */ - {"u", require_arg, 'u'}, /* user block file */ - {"o", require_arg, 'o'}, /* output file */ - {"delete", no_arg, 'd'}, /* delete ub */ - {"delet", no_arg, 'd'}, - {"dele", no_arg, 'd'}, - {"del", no_arg, 'd'}, - {"de", no_arg, 'd'}, - { NULL, 0, '\0' } -}; - -/*------------------------------------------------------------------------- - * Function: usage - * - * Purpose: Print the usage message - * - * Return: void - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -usage(const char *prog) -{ - HDfflush(stdout); - HDfprintf(stdout, - "usage: %s -i <in_file.h5> [-o <out_file.h5> ] [-u <out_user_file> | --delete]\n", prog); - HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "Splits user file and HDF5 file into two files: user block data and HDF5 data.\n"); - HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "OPTIONS\n"); - HDfprintf(stdout, - " -i in_file.h5 Specifies the HDF5 as input. If the input HDF5 file\n"); - HDfprintf(stdout, - " contains no user block, exit with an error message.\n"); - HDfprintf(stdout, - " -o out_file.h5 Specifies output HDF5 file without a user block.\n"); - HDfprintf(stdout, - " If not specified, the user block will be removed from the\n"); - HDfprintf(stdout, - " input HDF5 file.\n"); - HDfprintf(stdout, - " -u out_user_file\n"); - HDfprintf(stdout, - " Specifies the output file containing the data from the\n"); - HDfprintf(stdout, - " user block.\n"); - HDfprintf(stdout, - " Cannot be used with --delete option.\n"); - HDfprintf(stdout, - " --delete Remove the user block from the input HDF5 file. The content\n"); - HDfprintf(stdout, - " of the user block is discarded.\n"); - HDfprintf(stdout, - " Cannot be used with the -u option.\n"); - HDfprintf(stdout, "\n"); - HDfprintf(stdout, - " -h Prints a usage message and exits.\n"); - HDfprintf(stdout, - " -V Prints the HDF5 library version and exits.\n"); - HDfprintf(stdout, "\n"); - HDfprintf(stdout, - " If neither --delete nor -u is specified, the user block from the input file\n"); - HDfprintf(stdout, - " will be displayed to stdout.\n"); - HDfprintf(stdout, "\n"); - HDfprintf(stdout, - "Exit Status:\n"); - HDfprintf(stdout, - " 0 Succeeded.\n"); - HDfprintf(stdout, - " >0 An error occurred.\n"); -} - -/*------------------------------------------------------------------------- - * Function: parse_command_line - * - * Purpose: Parse the command line for the h5dumper. - * - * Return: Success: EXIT_SUCCESS; - * - * Failure: Exits function with EXIT_FAILURE value. - * - *------------------------------------------------------------------------- - */ -static int -parse_command_line(int argc, const char *argv[]) -{ - int opt = FALSE; - - /* parse command line options */ - while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char)opt) { - case 'o': - output_file = HDstrdup(opt_arg); - if (output_file) - h5tools_set_data_output_file(output_file, 1); - break; - - case 'i': - input_file = HDstrdup(opt_arg); - if (input_file) - h5tools_set_input_file(input_file, 1); - break;; - - case 'u': - ub_file = HDstrdup(opt_arg); - if (ub_file) - h5tools_set_output_file(ub_file, 1); - else - rawoutstream = stdout; - break; - - case 'd': - do_delete = TRUE; - break; - - case 'h': - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto done; - - case 'V': - print_version (h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto done; - - case '?': - default: - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - - return EXIT_SUCCESS; - -done: - if(input_file) - HDfree(input_file); - if(output_file) - HDfree(output_file); - if(ub_file) - HDfree(ub_file); - - return EXIT_FAILURE; -} - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: HDF5 user block unjammer - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -main(int argc, const char *argv[]) -{ - void *edata; - H5E_auto2_t func; - hid_t ifile = -1; - hid_t plist = -1; - off_t fsize; - hsize_t usize; - htri_t testval; - herr_t status; - int res; - h5_stat_t sbuf; - - h5tools_setprogname(PROGRAMNAME); - h5tools_setstatus(EXIT_SUCCESS); - - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - - /* Initialize h5tools lib */ - h5tools_init(); - - if(EXIT_FAILURE == parse_command_line(argc, argv)) - goto done; - - if (input_file == NULL) { - /* no user block */ - error_msg("missing arguemnt for HDF5 file input.\n"); - help_ref_msg(stderr); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - testval = H5Fis_hdf5(input_file); - - if (testval <= 0) { - error_msg("Input HDF5 file \"%s\" is not HDF\n", input_file); - help_ref_msg (stderr); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - ifile = H5Fopen(input_file, H5F_ACC_RDONLY , H5P_DEFAULT); - - if (ifile < 0) { - error_msg("Can't open input HDF5 file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - plist = H5Fget_create_plist(ifile); - if (plist < 0) { - error_msg("Can't get file creation plist for file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - status = H5Pget_userblock(plist, & usize); - if (status < 0) { - error_msg("Can't get user block for file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - status = H5Pclose(plist); - HDassert(status >= 0); - status = H5Fclose(ifile); - HDassert(status >= 0); - - if (usize == 0) { - /* no user block to remove: message? */ - error_msg("\"%s\" has no user block: no change to file\n", input_file); - h5tools_setstatus(EXIT_SUCCESS); - goto done; - } - - res = HDfstat(HDfileno(rawinstream), &sbuf); - if(res < 0) { - error_msg("Can't stat file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - fsize = sbuf.st_size; - - if (do_delete && (ub_file != NULL)) { - error_msg("??\"%s\"\n", ub_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - if (output_file == NULL) { - error_msg("unable to open output HDF5 file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - /* copy from 0 to 'usize - 1' into ufid */ - if (!do_delete) { - if(copy_to_file(rawinstream, rawoutstream, 0, (ssize_t) usize) < 0) { - error_msg("unable to copy user block to output file \"%s\"\n", ub_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - - /* copy from usize to end of file into h5fid, - * starting at end of user block if present */ - if(copy_to_file(rawinstream, rawdatastream, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) { - error_msg("unable to copy hdf5 data to output file \"%s\"\n", output_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - -done: - if(input_file) - HDfree(input_file); - - if(output_file) - HDfree(output_file); - - if(ub_file) { - HDfree(ub_file); - } - - h5tools_close(); - - return h5tools_getstatus(); -} - -/* - * Copy 'how_much' bytes from the input file to the output file, - * starting at byte 'where' in the input file. - * - * Returns 0 on success, -1 on failure. - */ -herr_t -copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t show_much ) -{ - static char buf[COPY_BUF_SIZE]; - size_t how_much; - off_t where = (off_t)_where; - off_t to; - off_t from; - herr_t ret_value = 0; - - /* nothing to copy */ - if(show_much <= 0) - goto done; - how_much = (size_t)show_much; - - /* rewind */ - HDfseek(infid, 0L, 0); - - from = where; - to = 0; - while(how_much > 0) { - size_t bytes_in = 0; /* # of bytes to read */ - size_t bytes_read = 0; /* # of bytes actually read */ - size_t bytes_wrote = 0; /* # of bytes written */ - - if (how_much > COPY_BUF_SIZE) - bytes_in = COPY_BUF_SIZE; - else - bytes_in = how_much; - - /* Seek to correct position in input file */ - HDfseek(infid, from, SEEK_SET); - - /* Read data to buffer */ - bytes_read = HDfread(buf, (size_t)1, bytes_in, infid); - if(0 == bytes_read && HDferror(infid)) { - ret_value = -1; - goto done; - } /* end if */ - if(0 == bytes_read && HDfeof(infid)) { - goto done; - } /* end if */ - - /* Seek to correct position in output file */ - HDfseek(ofid, to, SEEK_SET); - - /* Update positions/size */ - how_much -= bytes_read; - from += (off_t)bytes_read; - to += (off_t)bytes_read; - - /* Write nchars bytes to output file */ - bytes_wrote = HDfwrite(buf, (size_t)1, bytes_read, ofid); - if(bytes_wrote != bytes_read || (0 == bytes_wrote && HDferror(ofid))) { /* error */ - ret_value = -1; - goto done; - } /* end if */ - } /* end while */ - -done: - return ret_value; -} /* end copy_to_file */ - diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c deleted file mode 100644 index b4f87af..0000000 --- a/tools/h5jam/tellub.c +++ /dev/null @@ -1,196 +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 files COPYING and Copyright.html. COPYING can be found at the root * - * of the source code distribution tree; Copyright.html can be found at the * - * root level of an installed copy of the electronic HDF5 document set and * - * is linked from the top-level documents page. It can also be found at * - * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * - * access to either file, you may request a copy from help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include <stdio.h> - -#ifdef H5_HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include "hdf5.h" -#include "H5private.h" -#include "h5tools.h" -#include "h5tools_utils.h" - -/* Name of tool */ -#define PROGRAMNAME "tellub" - -/* - * Command-line options: The user can specify short or long-named - * parameters. The long-named ones can be partially spelled. When - * adding more, make sure that they don't clash with each other. - */ -static const char *s_opts = "h"; -static struct long_options l_opts[] = { - {"help", no_arg, 'h'}, - {"hel", no_arg, 'h'}, - {NULL, 0, '\0'} -}; - -/*------------------------------------------------------------------------- - * Function: usage - * - * Purpose: Print the usage message - * - * Return: void - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -static void -usage (const char *prog) -{ - fflush (stdout); - fprintf (stdout, "usage: %s h5_file\n", prog); - fprintf (stdout, - " Check that h5_fil is HDF5 file and print size of user block \n"); - fprintf (stdout, " %s -h\n", prog); - fprintf (stdout, " Print a usage message and exit\n"); -} - -/*------------------------------------------------------------------------- - * Function: parse_command_line - * - * Purpose: Parse the command line for the h5dumper. - * - * Return: Success: - * - * Failure: Exits program with EXIT_FAILURE value. - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ - -static void -parse_command_line (int argc, const char *argv[]) -{ - int opt; - - /* parse command line options */ - while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) - { - switch ((char) opt) - { - case 'h': - usage (h5tools_getprogname()); - exit (EXIT_SUCCESS); - case '?': - default: - usage (h5tools_getprogname()); - exit (EXIT_FAILURE); - } - } - - /* check for file name to be processed */ - if (argc <= opt_ind) - { - error_msg("missing file name\n"); - usage (h5tools_getprogname()); - exit (EXIT_FAILURE); - } -} - -/*------------------------------------------------------------------------- - * Function: main - * - * Purpose: HDF5 user block unjammer - * - * Return: Success: 0 - * Failure: 1 - * - * Programmer: - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -main (int argc, const char *argv[]) -{ - char *ifname; - void *edata; - H5E_auto2_t func; - hid_t ifile; - hsize_t usize; - htri_t testval; - herr_t status; - hid_t plist; - - h5tools_setprogname(PROGRAMNAME); - h5tools_setstatus(EXIT_SUCCESS); - - /* Initialize h5tools lib */ - h5tools_init(); - - /* Disable error reporting */ - H5Eget_auto2(H5E_DEFAULT, &func, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - - parse_command_line (argc, argv); - - if (argc <= (opt_ind)) - { - error_msg("missing file name\n"); - usage (h5tools_getprogname()); - return (EXIT_FAILURE); - } - - ifname = HDstrdup (argv[opt_ind]); - - testval = H5Fis_hdf5 (ifname); - - if (testval <= 0) - { - error_msg("Input HDF5 file is not HDF \"%s\"\n", ifname); - return (EXIT_FAILURE); - } - - ifile = H5Fopen (ifname, H5F_ACC_RDONLY, H5P_DEFAULT); - - if (ifile < 0) - { - error_msg("Can't open input HDF5 file \"%s\"\n", ifname); - return (EXIT_FAILURE); - } - - plist = H5Fget_create_plist (ifile); - if (plist < 0) - { - error_msg("Can't get file creation plist for file \"%s\"\n", - ifname); - return (EXIT_FAILURE); - } - - status = H5Pget_userblock (plist, &usize); - if (status < 0) - { - error_msg("Can't get user block for file \"%s\"\n", ifname); - return (EXIT_FAILURE); - } - - printf ("%ld\n", (long) usize); - - H5Pclose (plist); - H5Fclose (ifile); - - return (EXIT_SUCCESS); -} - diff --git a/tools/h5jam/testfiles/h5jam-help.txt b/tools/h5jam/testfiles/h5jam-help.txt deleted file mode 100644 index ce97c22..0000000 --- a/tools/h5jam/testfiles/h5jam-help.txt +++ /dev/null @@ -1,24 +0,0 @@ -usage: h5jam -i <in_file.h5> -u <in_user_file> [-o <out_file.h5>] [--clobber] - -Adds user block to front of an HDF5 file and creates a new concatenated file. - -OPTIONS - -i in_file.h5 Specifies the input HDF5 file. - -u in_user_file Specifies the file to be inserted into the user block. - Can be any file format except an HDF5 format. - -o out_file.h5 Specifies the output HDF5 file. - If not specified, the user block will be concatenated in - place to the input HDF5 file. - --clobber Wipes out any existing user block before concatenating - the given user block. - The size of the new user block will be the larger of; - - the size of existing user block in the input HDF5 file - - the size of user block required by new input user file - (size = 512 x 2N, N is positive integer.) - - -h Prints a usage message and exits. - -V Prints the HDF5 library version and exits. - -Exit Status: - 0 Succeeded. - >0 An error occurred. diff --git a/tools/h5jam/testfiles/h5jam-ub-nohdf5.txt b/tools/h5jam/testfiles/h5jam-ub-nohdf5.txt deleted file mode 100644 index 72c0b17..0000000 --- a/tools/h5jam/testfiles/h5jam-ub-nohdf5.txt +++ /dev/null @@ -1,2 +0,0 @@ -h5jam error: -u <user_file> cannot be HDF5 file, but it appears to be an HDF5 file. -Try '-h' or '--help' for more information or see the <h5jam> entry in the 'HDF5 Reference Manual'. diff --git a/tools/h5jam/testfiles/h5unjam-help.txt b/tools/h5jam/testfiles/h5unjam-help.txt deleted file mode 100644 index f0d92e9..0000000 --- a/tools/h5jam/testfiles/h5unjam-help.txt +++ /dev/null @@ -1,27 +0,0 @@ -usage: h5unjam -i <in_file.h5> [-o <out_file.h5> ] [-u <out_user_file> | --delete] - -Splits user file and HDF5 file into two files: user block data and HDF5 data. - -OPTIONS - -i in_file.h5 Specifies the HDF5 as input. If the input HDF5 file - contains no user block, exit with an error message. - -o out_file.h5 Specifies output HDF5 file without a user block. - If not specified, the user block will be removed from the - input HDF5 file. - -u out_user_file - Specifies the output file containing the data from the - user block. - Cannot be used with --delete option. - --delete Remove the user block from the input HDF5 file. The content - of the user block is discarded. - Cannot be used with the -u option. - - -h Prints a usage message and exits. - -V Prints the HDF5 library version and exits. - - If neither --delete nor -u is specified, the user block from the input file - will be displayed to stdout. - -Exit Status: - 0 Succeeded. - >0 An error occurred. diff --git a/tools/h5jam/testfiles/tall.h5 b/tools/h5jam/testfiles/tall.h5 Binary files differdeleted file mode 100644 index 918aeee..0000000 --- a/tools/h5jam/testfiles/tall.h5 +++ /dev/null diff --git a/tools/h5jam/testfiles/twithub.h5 b/tools/h5jam/testfiles/twithub.h5 Binary files differdeleted file mode 100644 index 4bc1833..0000000 --- a/tools/h5jam/testfiles/twithub.h5 +++ /dev/null diff --git a/tools/h5jam/testfiles/twithub513.h5 b/tools/h5jam/testfiles/twithub513.h5 Binary files differdeleted file mode 100644 index 0eac208..0000000 --- a/tools/h5jam/testfiles/twithub513.h5 +++ /dev/null diff --git a/tools/h5jam/testfiles/u10.txt b/tools/h5jam/testfiles/u10.txt deleted file mode 100644 index c76a964..0000000 --- a/tools/h5jam/testfiles/u10.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghij
\ No newline at end of file diff --git a/tools/h5jam/testfiles/u511.txt b/tools/h5jam/testfiles/u511.txt deleted file mode 100644 index bff1736..0000000 --- a/tools/h5jam/testfiles/u511.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghija
\ No newline at end of file diff --git a/tools/h5jam/testfiles/u512.txt b/tools/h5jam/testfiles/u512.txt deleted file mode 100644 index 33a36c9..0000000 --- a/tools/h5jam/testfiles/u512.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijab
\ No newline at end of file diff --git a/tools/h5jam/testfiles/u513.txt b/tools/h5jam/testfiles/u513.txt deleted file mode 100644 index 6b46ebf..0000000 --- a/tools/h5jam/testfiles/u513.txt +++ /dev/null @@ -1 +0,0 @@ -abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabc
\ No newline at end of file diff --git a/tools/h5jam/testh5jam.sh.in b/tools/h5jam/testh5jam.sh.in deleted file mode 100644 index d8c9274..0000000 --- a/tools/h5jam/testh5jam.sh.in +++ /dev/null @@ -1,699 +0,0 @@ -#! /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 files COPYING and Copyright.html. COPYING can be found at the root -# of the source code distribution tree; Copyright.html can be found at the -# root level of an installed copy of the electronic HDF5 document set and -# is linked from the top-level documents page. It can also be found at -# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have -# access to either file, you may request a copy from help@hdfgroup.org. -# -# Tests for the h5jam/h5unjam tools - -srcdir=@srcdir@ - -# Determine which filters are available -USE_FILTER_SZIP="@USE_FILTER_SZIP@" -USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" - -TESTNAME=h5jam/h5unjam -EXIT_SUCCESS=0 -EXIT_FAILURE=1 - -DUMPER=h5dump # The dumper to use -DUMPER_BIN=`pwd`/../$DUMPER # The path of the dumper binary -JAM=h5jam # Tool to test -UNJAM=h5unjam # Tool to test -JAM_BIN="$RUNSERIAL "`pwd` # The path of the jam binary -UNJAM_BIN=`pwd` # The path of the jam binary - -RM='rm -rf' -CMP='cmp -s' -DIFF='diff -c' -AWK='awk' -CP='cp' -DIRNAME='dirname' -LS='ls' -AWK='awk' - -nerrors=0 -verbose=yes - -# source dirs -SRC_TOOLS="$srcdir/.." -SRC_TOOLS_TESTFILES="$SRC_TOOLS/testfiles" - -# testfiles source dirs for tools -SRC_H5LS_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DUMP_TESTFILES="$SRC_TOOLS_TESTFILES" -SRC_H5DIFF_TESTFILES="$SRC_TOOLS/h5diff/testfiles" -SRC_H5COPY_TESTFILES="$SRC_TOOLS/h5copy/testfiles" -SRC_H5REPACK_TESTFILES="$SRC_TOOLS/h5repack/testfiles" -SRC_H5JAM_TESTFILES="$SRC_TOOLS/h5jam/testfiles" -SRC_H5STAT_TESTFILES="$SRC_TOOLS/h5stat/testfiles" -SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/h5import/testfiles" - -TESTDIR=./testfiles -test -d $TESTDIR || mkdir $TESTDIR - -###################################################################### -# test files -# -------------------------------------------------------------------- -# All the test files copy from source directory to test directory -# NOTE: Keep this framework to add/remove test files. -# Any test files from other tools can be used in this framework. -# This list are also used for checking exist. -# Comment '#' without space can be used. -# -------------------------------------------------------------------- -LIST_HDF5_TEST_FILES=" -$SRC_H5JAM_TESTFILES/tall.h5 -$SRC_H5JAM_TESTFILES/twithub.h5 -$SRC_H5JAM_TESTFILES/twithub513.h5 -" -LIST_OTHER_TEST_FILES=" -$SRC_H5JAM_TESTFILES/u10.txt -$SRC_H5JAM_TESTFILES/u511.txt -$SRC_H5JAM_TESTFILES/u512.txt -$SRC_H5JAM_TESTFILES/u513.txt -$SRC_H5JAM_TESTFILES/h5jam-help.txt -$SRC_H5JAM_TESTFILES/h5unjam-help.txt -$SRC_H5JAM_TESTFILES/h5jam-ub-nohdf5.txt -" - -# Source in the output filter function definitions. -. $srcdir/../../bin/output_filter.sh - -# -# copy test files and expected output files from source dirs to test dir -# -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES" - -COPY_TESTFILES_TO_TESTDIR() -{ - # copy test files. Used -f to make sure get a new copy - for tstfile in $COPY_TESTFILES - do - # ignore '#' comment - echo $tstfile | tr -d ' ' | grep '^#' > /dev/null - RET=$? - if [ $RET -eq 1 ]; then - # skip cp if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=`$DIRNAME $tstfile` - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $CP -f $tstfile $TESTDIR - if [ $? -ne 0 ]; then - echo "Error: FAILED to copy $tstfile ." - - # Comment out this to CREATE expected file - exit $EXIT_FAILURE - fi - fi - fi - done -} - -CLEAN_TESTFILES_AND_TESTDIR() -{ - # skip rm if srcdir is same as destdir - # this occurs when build/test performed in source dir and - # make cp fail - SDIR=$SRC_H5JAM_TESTFILES - INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` - INODE_DDIR=`$LS -i -d $TESTDIR | $AWK -F' ' '{print $1}'` - if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then - $RM $TESTDIR - fi -} - -# 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' -} - -# Print a line-line message left justified in a field of 70 characters -# beginning with the word "Compare". -# -COMPARE() { - SPACES=" " - echo "Compare $* $SPACES" | cut -c1-70 | tr -d '\012' -} - -# Print a "SKIP" message -SKIP() { - TESTING $JAM $@ - echo " -SKIP-" -} - -# -# COMPARE_FILES a.h5 b.h5 -# Compare two files, skipping the first line. This is used to -# compare the output of the dumper, skipping the file name which -# is different. -# The result is stored in 'compval'. -# -cmpval=0; -COMPARE_FILES() { - $AWK 'NR > 1' $1 > $1.cmp - $AWK 'NR > 1' $2 > $2.cmp - $CMP $1.cmp $2.cmp - cmpval=$? - rm -f $1.cmp $2.cmp -} - -# CLEANUP files -# Clean up named files. -CLEANUP() { - if test -z "$HDF5_NOCLEANUP"; then - for i in $* - do - rm -f $i - done - fi -} - -# SETUP file tocopy -# Clone a standard input file in the test directory -# Modification: -# Was using "cp" command which means file $2 will inherit the permission -# setting of file $1. If $1 is read-only, so will $2. That will cause -# failure when the test attempts to write it later on. Changed to use -# the "cat" command. -# -SETUP() { - cat < $1 > $2 -} - -# -# CHECKFILE orig.h5 compar.h5 -# Check that the test file is the same as an original. -# The two files are dumped with the dumper, and the output -# compared with COMPARE_FILES. -# If the files are the same, the test reports " PASSED", -# otherwise, it reports "*FAILED*" -CHECKFILE() { - expected="`dirname $2`/`basename $2 .h5`.out" - expected_err="`dirname $2`/`basename $2 .h5`.err" - actual="`basename $1 .h5`.out" - actual_err="`basename $1 .h5`.err" - - $RUNSERIAL $DUMPER_BIN/$DUMPER $1 >$expected 2>$expected_err - cat $expected_err >> $expected - - # dump the test file - COMPARE $2 to $1 - $RUNSERIAL $DUMPER_BIN/$DUMPER $2 >$actual 2>$actual_err - cat $actual_err >> $actual - - # compare the two files (ignore line 1) - COMPARE_FILES $actual $expected - if [ "$cmpval" = 0 ] ; then - echo " PASSED" - else - echo "*FAILED*" - echo " Expected result (*.ddl) differs from actual result (*.out)" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expected $actual |sed 's/^/ /' - fi - - # Clean up output files - if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err - rm -f $expected $expected_err - fi -} - -# -# CHECK_UB file.h5 user_block_file origfile.h5 -# -# Check the user block in 'file.h5' is the same as -# 'user_block' (allowing for padding). -# -# If the original file had a user block before the test -# then 'compare.h5' is passed. The user block must be extracted -# and the test file compared to: -# cat compare_ub user_block_file. -# -# This test uses './getub' to extract the user block from -# 'file.h5', which is compared to the file described above. -# -# The result is set in variable 'result1'. -# -result1=0; -CHECK_UB_1() { - hfile="$1" - ufile="$2" - - # check for third argument (the original file) - origfile=""; - if [ -n "$3" ]; - then - origfile="$3" - fi - - # find the length of the user block to check - s1=`cat $ufile | wc -c | sed -e 's/ //g'` - if [ "$s1" = "0" ]; - then - echo "File "$ufile" is empty" - result1=1; - fi - - # Get the size of the original user block, if any. - if [ -n "$origfile" ]; - then - # 'tellub' calls H5Fget_user_block to get the size - # of the user block - s2=`$JAM_BIN/tellub $origfile` - if [ "$s2" = "0" ]; - then - size=$s1; - cmpfile=$ufile - else - cmpfile="tt2" - size=`expr $s2 + $s1` - $JAM_BIN/getub -c $s2 $origfile > $cmpfile - cat $ufile >> $cmpfile - fi - else - # assume no user block - s2="0" - size=$s1; - cmpfile=$ufile - fi - - # Extract 'size' bytes from the front of 'hfile' - # Compare to 'cmpfile', result is set in result1 - tfile="tt1" - $JAM_BIN/getub -c $size $hfile > $tfile - res=`cmp $cmpfile $tfile` - if [ "$?" != "0" ]; - then - echo $res - result1=1; - else - result1=0; - fi - - # clean up - rm -f $tfile - if [ "$s2" != "0" ] ; - then - rm -f $cmpfile - fi -} - - -# CHECK_NOUB file.h5 -# -# Check that 'file.h5' has no user block. -# Setst result2 to 1 if there is a user block (fail), 0 if none (pass) - -result2=0; - -CHECK_NOUB() { - hfile="$1" - - # call 'ubsize' to get the size of the user block - ubsize=`$JAM_BIN/tellub $hfile` - - if [ "$?" != "0" ]; - then - # error - result2=1; - else - if [ "$ubsize" = "0" ]; - then - # pass - result2=0; - else - # fail - result2=1; - fi - fi -} - -# JAMTEST user_block file.h5 [--clobber] [ofile.h5] -# -# Test the 'jam' tool: -# 1. figure out the input and output, and the comparision -# that will be done. -# 2. call 'jam' with the appropriate arguments -# 3. check the user block is correct in the output (Check_UB) -# If the user block is correct, print "PASSED", else "*FAILED*" -JAMTEST() { - ufile="$1" - ifile="$2" - compare_test="" # the file to test - compare_orig="" # the comparison to test against - cleanup="" - - # sort out the arguments for the test and the check - do_clobber="no" - if [ "$3" = "--clobber" ]; - then - # clobber overwrites any existing user block - do_clobber="yes" - clobber="--clobber" - compare_orig="" - if [ -z "$4" ]; - then - # output goes to infile, compare ubfile to infile - ofile="" - compare_test="$ifile" - else - # output goes to $4, compare ofile to ubfile - ofile="$4" - compare_test="$ofile" - fi - else - clobber="" - # add user block to existing ub, if any - if [ -z "$3" ]; - then - # output goes to infile, compare ubfile to infile - ofile="" - compare_test="$ifile" - cp $ifile xxofile.h5 - compare_orig="xxofile.h5" - cleanup="$cleanup $compare_orig" - else - # output goes to $3, compare ofile to ubfile - ofile="$3" - compare_test="$ofile" - compare_orig="$ifile" - fi - fi - - # call 'jam' with the appropriate arguments - if [ -n "$ofile" ]; - then - TESTING h5jam -u `basename $ufile` -i `basename $ifile` -o `basename $ofile` $clobber - $JAM_BIN/$JAM -u $ufile -i $ifile -o $ofile $clobber - else - TESTING jam -u `basename $ufile` -i `basename $ifile` $clobber - $JAM_BIN/$JAM -u $ufile -i $ifile $clobber - fi - - #echo "CHECK_UB_1 $compare_test $ufile $compare_orig" - CHECK_UB_1 $compare_test $ufile $compare_orig - - if [ "$result1" = "0" ] ; - then - echo " PASSED" - else - echo " *FAILED*" - nerrors="`expr $nerrors + 1`" - fi - CLEANUP $cleanup -} - -# UNJAMTEST file.h5 [- | --delete] ofile -# -# Test the 'unjam' tool -# -###fix the working directory here and in jamtest -UNJAMTEST () { - infile="$1" - ofile="$3" - if [ "$2" = "-" ]; - then - uofile="uofile" - TESTING h5unjam -i `basename $infile` -o `basename $ofile` "> "`basename $uofile` - $JAM_BIN/$UNJAM -i $infile -o $ofile > $uofile - else - if [ "$2" = "--delete" ]; - then - uofile="none" - TESTING h5unjam -i `basename $infile` -o `basename $ofile` --delete - $JAM_BIN/$UNJAM -i $infile -o $ofile --delete - - else - uofile="$2" - TESTING h5unjam -i `basename $infile` -u `basename $uofile` -o `basename $ofile` - $JAM_BIN/$UNJAM -i $infile -u $uofile -o $ofile - fi - fi - - result1=0 - result2=0 - cleanup="" - if [ "$uofile" != "none" ]; - then - # sets result1 - CHECK_UB_1 $infile $uofile - CLEANUP $uofile - fi - - # sets result2 - CHECK_NOUB $ofile - - if [ "$result1" = "0" -a "$result2" = "0" ]; - then - echo " PASSED" - else - echo " *FAILED*" - nerrors="`expr $nerrors + 1`" - fi -} - - -# -# TOOLTEST_OUTPUT < JAM | UNJAM > expect-output.txt exit-code options -# -# Only verify stdout/stderr output from h5jam and j5unjam -# - -TOOLTEST_OUTPUT() { - if [ "$1" == "JAM" ]; then - TOOLCMD=$JAM_BIN/$JAM - elif [ "$1" == "UNJAM" ]; then - TOOLCMD=$JAM_BIN/$UNJAM - fi - shift - expect="$TESTDIR/$1" - actual="$TESTDIR/`basename $1 .ls`.out" - actual_err="$TESTDIR/`basename $1 .ls`.err" - actual_sav=${actual}-sav - actual_err_sav=${actual_err}-sav - shift - retvalexpect=$1 - shift - - TESTING h5jam $@ - ( - cd $TESTDIR - $TOOLCMD "$@" - ) >$actual 2>$actual_err - - # save actual and actual_err in case they are needed later. - cp $actual $actual_sav - STDOUT_FILTER $actual - cp $actual_err $actual_err_sav - STDERR_FILTER $actual_err - # combine stderr to stdout for output compare - cat $actual_err >> $actual - - if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - rm -f $actual $actual_sav $actual_err $actual_err_sav - elif $CMP $expect $actual; then - echo " PASSED" - rm -f $actual $actual_sav $actual_err $actual_err_sav - else - echo "*FAILED*" - echo " Expected result differs from actual result" - nerrors="`expr $nerrors + 1`" - test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' - fi -} - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## -# prepare for test -COPY_TESTFILES_TO_TESTDIR - -#------------------------------- -# Testing h5jam -#------------------------------- -# help page -TOOLTEST_OUTPUT JAM h5jam-help.txt 0 -h - -# don't allow HDF5 format file as an user block file -TOOLTEST_OUTPUT JAM h5jam-ub-nohdf5.txt 1 -i tall.h5 -u tall.h5 -o tall-tmp.h5 - -JAMTEST $TESTDIR/u10.txt $TESTDIR/tall.h5 ta2.h5 -CHECKFILE $TESTDIR/tall.h5 ta2.h5 -CLEANUP ta2.h5 -JAMTEST $TESTDIR/u511.txt $TESTDIR/tall.h5 ta3.h5 -CHECKFILE $TESTDIR/tall.h5 ta3.h5 -CLEANUP ta3.h5 -JAMTEST $TESTDIR/u512.txt $TESTDIR/tall.h5 ta4.h5 -CHECKFILE $TESTDIR/tall.h5 ta4.h5 -CLEANUP ta4.h5 -JAMTEST $TESTDIR/u513.txt $TESTDIR/tall.h5 ta5.h5 -CHECKFILE $TESTDIR/tall.h5 ta5.h5 -CLEANUP ta5.h5 - -SETUP $TESTDIR/tall.h5 ta6.h5 -JAMTEST $TESTDIR/u10.txt ta6.h5 -CHECKFILE $TESTDIR/tall.h5 ta6.h5 -CLEANUP ta6.h5 -SETUP $TESTDIR/tall.h5 ta7.h5 -JAMTEST $TESTDIR/u511.txt ta7.h5 -CHECKFILE $TESTDIR/tall.h5 ta7.h5 -CLEANUP ta7.h5 -SETUP $TESTDIR/tall.h5 ta8.h5 -JAMTEST $TESTDIR/u512.txt ta8.h5 -CHECKFILE $TESTDIR/tall.h5 ta8.h5 -CLEANUP ta8.h5 -SETUP $TESTDIR/tall.h5 ta9.h5 -JAMTEST $TESTDIR/u513.txt ta9.h5 -CHECKFILE $TESTDIR/tall.h5 ta9.h5 -CLEANUP ta9.h5 - -JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub.h5 tax2.h5 -CHECKFILE $TESTDIR/tall.h5 tax2.h5 -CLEANUP tax2.h5 -JAMTEST $TESTDIR/u511.txt $TESTDIR/twithub.h5 tax3.h5 -CHECKFILE $TESTDIR/tall.h5 tax3.h5 -CLEANUP tax3.h5 -JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub.h5 tax4.h5 -CHECKFILE $TESTDIR/tall.h5 tax4.h5 -CLEANUP tax4.h5 -JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub.h5 tax5.h5 -CHECKFILE $TESTDIR/tall.h5 tax5.h5 -CLEANUP tax5.h5 - -JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub513.h5 tax6.h5 -CHECKFILE $TESTDIR/tall.h5 tax6.h5 -CLEANUP tax6.h5 -JAMTEST $TESTDIR/u511.txt $TESTDIR/twithub513.h5 tax7.h5 -CHECKFILE $TESTDIR/tall.h5 tax7.h5 -CLEANUP tax7.h5 -JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub513.h5 tax8.h5 -CHECKFILE $TESTDIR/tall.h5 tax8.h5 -CLEANUP tax8.h5 -JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub513.h5 tax9.h5 -CHECKFILE $TESTDIR/tall.h5 tax9.h5 -CLEANUP tax9.h5 - -JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub.h5 --clobber taz2.h5 -CHECKFILE $TESTDIR/tall.h5 taz2.h5 -CLEANUP taz2.h5 -JAMTEST $TESTDIR/u511.txt $TESTDIR/twithub.h5 --clobber taz3.h5 -CHECKFILE $TESTDIR/tall.h5 taz3.h5 -CLEANUP taz3.h5 -JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub.h5 --clobber taz4.h5 -CHECKFILE $TESTDIR/tall.h5 taz4.h5 -CLEANUP taz4.h5 -JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub.h5 --clobber taz5.h5 -CHECKFILE $TESTDIR/tall.h5 taz5.h5 -CLEANUP taz5.h5 - -JAMTEST $TESTDIR/u10.txt $TESTDIR/twithub513.h5 --clobber taz6.h5 -CHECKFILE $TESTDIR/tall.h5 taz6.h5 -CLEANUP taz6.h5 -JAMTEST $TESTDIR/u511.txt $TESTDIR/twithub513.h5 --clobber taz7.h5 -CHECKFILE $TESTDIR/tall.h5 taz7.h5 -CLEANUP taz7.h5 -JAMTEST $TESTDIR/u512.txt $TESTDIR/twithub513.h5 --clobber taz8.h5 -CHECKFILE $TESTDIR/tall.h5 taz8.h5 -CLEANUP taz8.h5 -JAMTEST $TESTDIR/u513.txt $TESTDIR/twithub513.h5 --clobber taz9.h5 -CHECKFILE $TESTDIR/tall.h5 taz9.h5 -CLEANUP taz9.h5 - -SETUP $TESTDIR/twithub.h5 tay2.h5 -JAMTEST $TESTDIR/u10.txt tay2.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay2.h5 -CLEANUP tay2.h5 -SETUP $TESTDIR/twithub.h5 tay3.h5 -JAMTEST $TESTDIR/u511.txt tay3.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay3.h5 -CLEANUP tay3.h5 -SETUP $TESTDIR/twithub.h5 tay4.h5 -JAMTEST $TESTDIR/u512.txt tay4.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay4.h5 -CLEANUP tay4.h5 -SETUP $TESTDIR/twithub.h5 tay5.h5 -JAMTEST $TESTDIR/u513.txt tay5.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay5.h5 -CLEANUP tay5.h5 - -SETUP $TESTDIR/twithub513.h5 tay6.h5 -JAMTEST $TESTDIR/u10.txt tay6.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay6.h5 -CLEANUP tay6.h5 -SETUP $TESTDIR/twithub513.h5 tay7.h5 -JAMTEST $TESTDIR/u511.txt tay7.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay7.h5 -CLEANUP tay7.h5 -SETUP $TESTDIR/twithub513.h5 tay8.h5 -JAMTEST $TESTDIR/u512.txt tay8.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay8.h5 -CLEANUP tay8.h5 -SETUP $TESTDIR/twithub513.h5 tay9.h5 -JAMTEST $TESTDIR/u513.txt tay9.h5 --clobber -CHECKFILE $TESTDIR/tall.h5 tay9.h5 -CLEANUP tay9.h5 - -#--------------------------------- -# Testing h5unjam -#--------------------------------- -# help page -TOOLTEST_OUTPUT UNJAM h5unjam-help.txt 0 -h - -SETUP $TESTDIR/twithub.h5 tai1.h5 -UNJAMTEST tai1.h5 o10.txt taa1.h5 -CHECKFILE $TESTDIR/tall.h5 taa1.h5 -CLEANUP taa1.h5 tai1.h5 o10.txt -SETUP $TESTDIR/twithub513.h5 tai2.h5 -UNJAMTEST tai2.h5 o512.txt taa2.h5 -CHECKFILE $TESTDIR/tall.h5 taa2.h5 -CLEANUP taa2.h5 tai2.h5 o512.txt - -SETUP $TESTDIR/twithub.h5 tai3.h5 -UNJAMTEST tai3.h5 - taa3.h5 -CHECKFILE $TESTDIR/tall.h5 taa3.h5 -CLEANUP taa3.h5 tai3.h5 -SETUP $TESTDIR/twithub513.h5 tai4.h5 -UNJAMTEST tai4.h5 - taa4.h5 -CHECKFILE $TESTDIR/tall.h5 taa4.h5 -CLEANUP taa4.h5 tai4.h5 - -SETUP $TESTDIR/twithub.h5 taj2.h5 -UNJAMTEST taj2.h5 --delete tac2.h5 -CHECKFILE $TESTDIR/tall.h5 tac2.h5 -CLEANUP tac2.h5 taj2.h5 -SETUP $TESTDIR/twithub513.h5 taj3.h5 -UNJAMTEST taj3.h5 --delete tac3.h5 -CHECKFILE $TESTDIR/tall.h5 tac3.h5 -CLEANUP tac3.h5 taj3.h5 - -# Clean up temporary files/directories -CLEAN_TESTFILES_AND_TESTDIR - -if test $nerrors -eq 0 ; then - echo "All $TESTNAME tests passed." - exit $EXIT_SUCCESS -else - echo "$TESTNAME tests failed with $nerrors errors." - exit $EXIT_FAILURE -fi |