diff options
author | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-08-21 15:44:35 (GMT) |
---|---|---|
committer | Mohamad Chaarawi <chaarawi@hdfgroup.org> | 2013-08-21 15:44:35 (GMT) |
commit | 78d8f8d7d12e779f640cf037bc52fd7e8a07061c (patch) | |
tree | f6a2bb20a4a34804b0253c18c205c5f77103d843 /tools/h5jam | |
parent | ff14409081fe6a5826b25658577aaf59f8fbb78f (diff) | |
parent | 482a9c28e71b0c1b3767bcf30be3c534bbc65ed9 (diff) | |
download | hdf5-78d8f8d7d12e779f640cf037bc52fd7e8a07061c.zip hdf5-78d8f8d7d12e779f640cf037bc52fd7e8a07061c.tar.gz hdf5-78d8f8d7d12e779f640cf037bc52fd7e8a07061c.tar.bz2 |
[svn-r24044] Merging r23833 through r24043 from trunk.
Diffstat (limited to 'tools/h5jam')
-rw-r--r-- | tools/h5jam/CMakeLists.txt | 428 | ||||
-rw-r--r-- | tools/h5jam/CMakeTests.cmake | 428 | ||||
-rw-r--r-- | tools/h5jam/h5unjam.c | 149 |
3 files changed, 487 insertions, 518 deletions
diff --git a/tools/h5jam/CMakeLists.txt b/tools/h5jam/CMakeLists.txt index af9639d..49d1b0c 100644 --- a/tools/h5jam/CMakeLists.txt +++ b/tools/h5jam/CMakeLists.txt @@ -40,12 +40,6 @@ SET (H5_DEP_EXECUTABLES h5unjam ) -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - IF (BUILD_TESTING) # -------------------------------------------------------------------- # Add the h5jam test executables @@ -60,427 +54,7 @@ IF (BUILD_TESTING) #ADD_TEST (NAME h5jamgentest COMMAND $<TARGET_FILE:h5jamgentest>) ENDIF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) - 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}) - SET (dest "${PROJECT_BINARY_DIR}/testfiles/${h5_file}") - #MESSAGE (STATUS " Copying ${h5_file}") - ADD_CUSTOM_COMMAND ( - TARGET h5jam - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${h5_file} ${dest} - ) - ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) - - FOREACH (txt_file ${HDF5_REFERENCE_TXT_FILES}) - SET (dest "${PROJECT_BINARY_DIR}/testfiles/${txt_file}") - #MESSAGE (STATUS " Copying ${txt_file}") - ADD_CUSTOM_COMMAND ( - TARGET h5jam - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${txt_file} ${dest} - ) - ENDFOREACH (txt_file ${HDF5_REFERENCE_TXT_FILES}) - -############################################################################## -############################################################################## -### 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}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${expectfile}.out - ${expectfile}.out.err - ) - 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" - ) - SET_TESTS_PROPERTIES (H5JAM-${expectfile} PROPERTIES DEPENDS H5JAM-${expectfile}-clear-objects) - 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}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${expectfile}.out - ${expectfile}.out.err - ) - 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" - ) - SET_TESTS_PROPERTIES (H5JAM-UNJAM-${expectfile} PROPERTIES DEPENDS H5JAM-UNJAM-${expectfile}-clear-objects) - 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-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - ${actual}.new - ${actual}.new.err - ${actual}.out - ${actual}.out.err - ) - SET_TESTS_PROPERTIES (H5JAM-${testname}-CHECKFILE-clear-objects PROPERTIES DEPENDS ${testdepends}) - 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" - ) - SET_TESTS_PROPERTIES (H5JAM-${testname}-CHECKFILE-H5DMP PROPERTIES DEPENDS H5JAM-${testname}-CHECKFILE-clear-objects) - 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 "${HDF5_RESOURCES_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_D-clear-objects - COMMAND ${CMAKE_COMMAND} -E remove ${outfile}.ufile.txt ${outfile}.ufile.txt.err - ) - SET_TESTS_PROPERTIES (H5JAM-${testname}-UNJAM_D-clear-objects PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) - 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" - ) - SET_TESTS_PROPERTIES (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM_D-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 "${HDF5_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 "${HDF5_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 "${HDF5_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 "${HDF5_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) + INCLUDE (CMakeTests.cmake) ENDIF (BUILD_TESTING) diff --git a/tools/h5jam/CMakeTests.cmake b/tools/h5jam/CMakeTests.cmake new file mode 100644 index 0000000..3816e85 --- /dev/null +++ b/tools/h5jam/CMakeTests.cmake @@ -0,0 +1,428 @@ + +############################################################################## +############################################################################## +### 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}) + SET (dest "${PROJECT_BINARY_DIR}/testfiles/${h5_file}") + #MESSAGE (STATUS " Copying ${h5_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5jam + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${h5_file} ${dest} + ) + ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) + + FOREACH (txt_file ${HDF5_REFERENCE_TXT_FILES}) + SET (dest "${PROJECT_BINARY_DIR}/testfiles/${txt_file}") + #MESSAGE (STATUS " Copying ${txt_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5jam + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/testfiles/${txt_file} ${dest} + ) + ENDFOREACH (txt_file ${HDF5_REFERENCE_TXT_FILES}) + +############################################################################## +############################################################################## +### 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}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${expectfile}.out + ${expectfile}.out.err + ) + 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + SET_TESTS_PROPERTIES (H5JAM-${expectfile} PROPERTIES DEPENDS H5JAM-${expectfile}-clear-objects) + 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}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${expectfile}.out + ${expectfile}.out.err + ) + 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + SET_TESTS_PROPERTIES (H5JAM-UNJAM-${expectfile} PROPERTIES DEPENDS H5JAM-UNJAM-${expectfile}-clear-objects) + 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-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${actual}.new + ${actual}.new.err + ${actual}.out + ${actual}.out.err + ) + SET_TESTS_PROPERTIES (H5JAM-${testname}-CHECKFILE-clear-objects PROPERTIES DEPENDS ${testdepends}) + 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + SET_TESTS_PROPERTIES (H5JAM-${testname}-CHECKFILE-H5DMP PROPERTIES DEPENDS H5JAM-${testname}-CHECKFILE-clear-objects) + 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 "${HDF5_RESOURCES_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_D-clear-objects + COMMAND ${CMAKE_COMMAND} -E remove ${outfile}.ufile.txt ${outfile}.ufile.txt.err + ) + SET_TESTS_PROPERTIES (H5JAM-${testname}-UNJAM_D-clear-objects PROPERTIES DEPENDS H5JAM-${testname}-UNJAM-clear-objects) + 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 "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + SET_TESTS_PROPERTIES (H5JAM-${testname}-UNJAM PROPERTIES DEPENDS H5JAM-${testname}-UNJAM_D-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 "${HDF5_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 "${HDF5_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 "${HDF5_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 "${HDF5_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/h5unjam.c b/tools/h5jam/h5unjam.c index 9641378..7b4dc91 100644 --- a/tools/h5jam/h5unjam.c +++ b/tools/h5jam/h5unjam.c @@ -27,7 +27,7 @@ hsize_t write_pad( int , hsize_t ); hsize_t compute_pad( hsize_t ); -herr_t copy_to_file( int , int , ssize_t, ssize_t ); +herr_t copy_to_file( FILE *, FILE * , ssize_t, ssize_t ); int do_delete = FALSE; char *output_file = NULL; @@ -137,20 +137,28 @@ static int parse_command_line(int argc, const char *argv[]) { int opt = FALSE; - - /* parse command line options */ + + /* 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; + if (output_file) + h5tools_set_data_output_file(output_file, 1); + break; case 'i': input_file = HDstrdup(opt_arg); - break; + 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': @@ -205,9 +213,6 @@ done: int main(int argc, const char *argv[]) { - int ifid = -1; - int ufid = -1; - int h5fid = -1; void *edata; H5E_auto2_t func; hid_t ifile = -1; @@ -222,24 +227,24 @@ main(int argc, const char *argv[]) h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); - /* Disable error reporting */ + /* Disable error reporting */ H5Eget_auto2(H5E_DEFAULT, &func, &edata); H5Eset_auto2(H5E_DEFAULT, NULL, NULL); - /* Initialize h5tools lib */ + /* Initialize h5tools lib */ h5tools_init(); if(EXIT_FAILURE == parse_command_line(argc, argv)) goto done; if (input_file == NULL) { - /* no user block */ + /* no user block */ error_msg("missing arguemnt for HDF5 file input.\n"); help_ref_msg(stderr); h5tools_setstatus(EXIT_FAILURE); goto done; } - + testval = H5Fis_accessible(input_file, H5P_DEFAULT); if (testval <= 0) { @@ -283,14 +288,7 @@ main(int argc, const char *argv[]) goto done; } - ifid = HDopen(input_file,O_RDONLY,0); - if(ifid < 0) { - error_msg("unable to open input HDF5 file \"%s\"\n", input_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - - res = HDfstat(ifid, &sbuf); + res = HDfstat(HDfileno(rawinstream), &sbuf); if(res < 0) { error_msg("Can't stat file \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); @@ -305,43 +303,15 @@ main(int argc, const char *argv[]) goto done; } - if (ub_file == NULL) { - /* write to sdtout */ - ufid = HDdup(1); - } - else { - ufid = HDopen(ub_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 ); - - if (ufid < 0) { - error_msg("unable to open user block file for output\"%s\"\n", ub_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - if (output_file == NULL) { - h5fid = HDopen(input_file,O_WRONLY, 0); - - if (h5fid < 0) { error_msg("unable to open output HDF5 file \"%s\"\n", input_file); h5tools_setstatus(EXIT_FAILURE); goto done; - } } - else { - h5fid = HDopen(output_file,O_WRONLY|O_CREAT|O_TRUNC, 0644 ); - - if (h5fid < 0) { - error_msg("unable to open output HDF5 file \"%s\"\n", output_file); - h5tools_setstatus(EXIT_FAILURE); - goto done; - } - } - - /* copy from 0 to 'usize - 1' into ufid */ + /* copy from 0 to 'usize - 1' into ufid */ if (!do_delete) { - if(copy_to_file(ifid, ufid, 0, (ssize_t) usize) < 0) { + 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; @@ -349,34 +319,25 @@ main(int argc, const char *argv[]) } /* copy from usize to end of file into h5fid, - * starting at end of user block if present - */ - if(copy_to_file(ifid, h5fid, (ssize_t) usize, (ssize_t)(fsize - (ssize_t)usize)) < 0) { + * 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); - if(ufid >= 0) - status = HDclose(ufid); - HDassert(status >= 0); - } - - if(h5fid >= 0) { - status = HDclose(h5fid); - HDassert(status >= 0); - } - if(ifid >= 0) { - status = HDclose(ifid); - HDassert(status >= 0); } + + h5tools_close(); return h5tools_getstatus(); } @@ -388,54 +349,60 @@ done: * Returns 0 on success, -1 on failure. */ herr_t -copy_to_file( int infid, int ofid, ssize_t where, ssize_t how_much ) +copy_to_file( FILE *infid, FILE *ofid, ssize_t _where, ssize_t how_much ) { static char buf[COPY_BUF_SIZE]; + off_t where = (off_t)_where; off_t to; off_t from; - ssize_t nchars = -1; - ssize_t wnchars = -1; herr_t ret_value = 0; /* nothing to copy */ if(how_much <= 0) goto done; + /* rewind */ + HDfseek(infid, 0L, 0); + from = where; to = 0; - while(how_much > 0) { - /* Seek to correct position in input file */ - HDlseek(infid,from,SEEK_SET); + 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 */ - /* Read data to buffer */ if (how_much > COPY_BUF_SIZE) - nchars = HDread(infid,buf,(unsigned)COPY_BUF_SIZE); + bytes_in = COPY_BUF_SIZE; else - nchars = HDread(infid,buf,(unsigned)how_much); - if(nchars < 0) { + 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 */ - HDlseek(ofid,to,SEEK_SET); + HDfseek(ofid, to, SEEK_SET); /* Update positions/size */ - how_much -= nchars; - from += nchars; - to += nchars; - - /* Write nchars bytes to output file */ - wnchars = nchars; - while(nchars > 0) { - wnchars = HDwrite(ofid,buf,(unsigned)nchars); - if(wnchars < 0) { - ret_value = -1; - goto done; - } /* end if */ - nchars -= wnchars; - } /* end while */ + how_much -= bytes_read; + from += bytes_read; + to += 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: |