diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2011-03-31 20:39:18 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2011-03-31 20:39:18 (GMT) |
commit | f4e7559bd2d8bbd59535cbcafab78e162a6bffb6 (patch) | |
tree | b4339300a7d08fe64266ad183213da8a38fb986e /tools/h5copy | |
parent | 9c0a2b214519c6f0508964981be19bf2e3054e35 (diff) | |
download | hdf5-f4e7559bd2d8bbd59535cbcafab78e162a6bffb6.zip hdf5-f4e7559bd2d8bbd59535cbcafab78e162a6bffb6.tar.gz hdf5-f4e7559bd2d8bbd59535cbcafab78e162a6bffb6.tar.bz2 |
[svn-r20383] Description:
Bring r19714:20382 from trunk to revise_chunks branch
Tested:
Linux 2.6/64 (chicago)
Diffstat (limited to 'tools/h5copy')
-rw-r--r-- | tools/h5copy/CMakeLists.txt | 126 | ||||
-rw-r--r-- | tools/h5copy/h5copy.c | 14 | ||||
-rw-r--r-- | tools/h5copy/h5copygentest.c | 13 | ||||
-rw-r--r-- | tools/h5copy/testh5copy.sh | 13 |
4 files changed, 115 insertions, 51 deletions
diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index 2f39282..8a6ca11 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -11,7 +11,7 @@ INCLUDE_DIRECTORIES (${HDF5_PROJECT_DIR}/test) # Add the h5copy and test executables # -------------------------------------------------------------------- ADD_EXECUTABLE (h5copy ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/h5copy.c) -H5_NAMING (h5copy ${LIB_TYPE}) +TARGET_NAMING (h5copy ${LIB_TYPE}) TARGET_LINK_LIBRARIES (h5copy ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) SET (H5_DEP_EXECUTABLES h5copy) @@ -25,7 +25,7 @@ SET (H5_DEP_EXECUTABLES h5copy) IF (BUILD_TESTING) IF (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) ADD_EXECUTABLE (h5copygentest ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/h5copygentest.c) - H5_NAMING (h5copygentest ${LIB_TYPE}) + TARGET_NAMING (h5copygentest ${LIB_TYPE}) TARGET_LINK_LIBRARIES (h5copygentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) #ADD_TEST (NAME h5copygentest COMMAND $<TARGET_FILE:h5copygentest>) @@ -76,67 +76,100 @@ IF (BUILD_TESTING) ############################################################################## ############################################################################## - MACRO (ADD_H5_TEST testname resultcode testfile vparam srcname dstname) + # + # Perform h5copy according to passing parmeters + # + MACRO (ADD_H5COPY_TEST testname resultcode infile outfile vparam srcname dstname) IF (NOT "${ARGN}" STREQUAL "") ADD_TEST ( NAME H5COPY-${testname} - COMMAND $<TARGET_FILE:h5copy> -f ${ARGN} -i ./testfiles/${testfile}.h5 -o ./testfiles/${testfile}.out.h5 -${vparam} -s ${srcname} -d ${dstname} + COMMAND $<TARGET_FILE:h5copy> -f ${ARGN} -i ./testfiles/${infile} -o ./testfiles/${outfile} -${vparam} -s ${srcname} -d ${dstname} ) ELSE (NOT "${ARGN}" STREQUAL "") ADD_TEST ( NAME H5COPY-${testname} - COMMAND $<TARGET_FILE:h5copy> -i ./testfiles/${testfile}.h5 -o ./testfiles/${testfile}.out.h5 -${vparam} -s ${srcname} -d ${dstname} + COMMAND $<TARGET_FILE:h5copy> -i ./testfiles/${infile} -o ./testfiles/${outfile} -${vparam} -s ${srcname} -d ${dstname} ) ENDIF (NOT "${ARGN}" STREQUAL "") + IF (NOT "${last_test}" STREQUAL "") + SET_TESTS_PROPERTIES (H5COPY-${testname} PROPERTIES DEPENDS ${last_test}) + ENDIF (NOT "${last_test}" STREQUAL "") + SET (last_test "H5COPY-${testname}") + # resultcode=2 will cause the test to skip the diff test IF (NOT ${resultcode} STREQUAL "2") ADD_TEST ( NAME H5COPY-DIFF_${testname} - COMMAND $<TARGET_FILE:h5diff> -q ./testfiles/${testfile}.h5 ./testfiles/${testfile}.out.h5 ${srcname} ${dstname} + COMMAND $<TARGET_FILE:h5diff> -q ./testfiles/${infile} ./testfiles/${outfile} ${srcname} ${dstname} ) SET_TESTS_PROPERTIES(H5COPY-DIFF_${testname} PROPERTIES DEPENDS H5COPY-${testname}) + SET (last_test "H5COPY-DIFF_${testname}") IF (${resultcode} STREQUAL "1") SET_TESTS_PROPERTIES (H5COPY-DIFF_${testname} PROPERTIES WILL_FAIL "true") ENDIF (${resultcode} STREQUAL "1") ENDIF (NOT ${resultcode} STREQUAL "2") - IF (NOT "${last_test}" STREQUAL "") - SET_TESTS_PROPERTIES (H5COPY-${testname} PROPERTIES DEPENDS ${last_test}) - ENDIF (NOT "${last_test}" STREQUAL "") - SET (last_test "H5COPY-DIFF_${testname}") + ENDMACRO (ADD_H5COPY_TEST) + + # + # call ADD_H5COPY_TEST macro with assumption that source and target file + # is different + # + MACRO (ADD_H5_TEST testname resultcode testfile vparam srcname dstname) + ADD_H5COPY_TEST (${testname} ${resultcode} ${testfile}.h5 ${testfile}.out.h5 ${vparam} ${srcname} ${dstname} ${ARGN}) ENDMACRO (ADD_H5_TEST testname resultcode testfile vparam srcname dstname) + # + # Test result with h5ls + # MACRO (ADD_H5LS_TEST file filetest) - ADD_TEST ( - NAME H5COPY-H5LS_${file}-${filetest} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5ls>" - -D "TEST_ARGS=-Svr;./testfiles/${file}.out.h5" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=./testfiles/${file}.out.out" - -D "TEST_EXPECT=0" - -D "TEST_REFERENCE=./testfiles/${file}.out.ls" - -D "TEST_MASK=true" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" - ) + # If using memchecker add tests without using scripts + IF (HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST (NAME H5COPY-H5LS_${file}-${filetest} COMMAND $<TARGET_FILE:h5ls> -Svr ./testfiles/${file}.out.h5) + ELSE (HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST ( + NAME H5COPY-H5LS_${file}-${filetest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls>" + -D "TEST_ARGS=-Svr;./testfiles/${file}.out.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${file}.out.out" + -D "TEST_EXPECT=0" + -D "TEST_REFERENCE=./testfiles/${file}.out.ls" + -D "TEST_MASK=true" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDIF (HDF5_ENABLE_USING_MEMCHECKER) IF (NOT "${last_test}" STREQUAL "") SET_TESTS_PROPERTIES (H5COPY-H5LS_${file}-${filetest} PROPERTIES DEPENDS ${last_test}) ENDIF (NOT "${last_test}" STREQUAL "") SET (last_test "H5COPY-H5LS_${file}-${filetest}") ENDMACRO (ADD_H5LS_TEST file filetest) + # + # Similiar to ADD_H5_TEST macro. Compare to outputs from source & target + # files instead of checking with h5ls. + # MACRO (ADD_H5_CMP_TEST testname resultcode testfile vparam srcname dstname) - ADD_TEST ( - NAME H5COPY-CMP-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5copy>" - -D "TEST_ARGS=-i;${testfile}.h5;-o;./testfiles/${testfile}.out.h5;-${vparam};-s;${srcname};-d;${dstname}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -D "TEST_OUTPUT=./testfiles/${testname}.out.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=./testfiles/${testname}.out" - -D "TEST_MASK=true" - -P "${HDF5_RESOURCES_DIR}/runTest.cmake" - ) + # If using memchecker add tests without using scripts + IF (HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST (NAME H5COPY-CMP-${testname} COMMAND $<TARGET_FILE:h5copy> -i ${testfile}.h5 -o ./testfiles/${testfile}.out.h5 -${vparam} -s ${srcname} -d ${dstname}) + IF (${resultcode} STREQUAL "1") + SET_TESTS_PROPERTIES (H5COPY-CMP-${testname} PROPERTIES WILL_FAIL "true") + ENDIF (${resultcode} STREQUAL "1") + ELSE (HDF5_ENABLE_USING_MEMCHECKER) + ADD_TEST ( + NAME H5COPY-CMP-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5copy>" + -D "TEST_ARGS=-i;${testfile}.h5;-o;./testfiles/${testfile}.out.h5;-${vparam};-s;${srcname};-d;${dstname}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=./testfiles/${testname}.out.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=./testfiles/${testname}.out" + -D "TEST_MASK=true" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDIF (HDF5_ENABLE_USING_MEMCHECKER) IF (NOT "${last_test}" STREQUAL "") SET_TESTS_PROPERTIES (H5COPY-CMP-${testname} PROPERTIES DEPENDS ${last_test}) ENDIF (NOT "${last_test}" STREQUAL "") @@ -156,6 +189,7 @@ IF (BUILD_TESTING) SET (HDF_FILE2 h5copy_ref) SET (HDF_EXT_SRC_FILE h5copy_extlinks_src) SET (HDF_EXT_TRG_FILE h5copy_extlinks_trg) + SET (HDF_FILE1_TMP h5copytst_tmp) # Remove any output file left over from previous test run ADD_TEST ( @@ -261,13 +295,13 @@ IF (BUILD_TESTING) ADD_H5_TEST (ext_link_f 2 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_dset /copy2_dset ext) # "Test copying dangling external link (no obj) directly without -f ext" - ADD_H5_TEST (ext_dangle_noobj 0 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_notyet1 /copy_dangle1_1) + ADD_H5_TEST (ext_dangle_noobj 2 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_notyet1 /copy_dangle1_1) # "Test copying dangling external link (no obj) directly with -f ext" ADD_H5_TEST (ext_dangle_noobj_f 2 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_notyet1 /copy_dangle1_2 ext) # "Test copying dangling external link (no file) directly without -f ext" - ADD_H5_TEST (ext_dangle_nofile 0 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_notyet2 /copy_dangle2_1) + ADD_H5_TEST (ext_dangle_nofile 2 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_notyet2 /copy_dangle2_1) # "Test copying dangling external link (no file) directly with -f ext" ADD_H5_TEST (ext_dangle_nofile_f 2 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_notyet2 /copy_dangle2_2 ext) @@ -295,18 +329,32 @@ IF (BUILD_TESTING) NAME H5COPY-clear-misc COMMAND ${CMAKE_COMMAND} -E remove - ./testfiles/${HDF_FILE1}.out.h5 - ./testfiles/${HDF_FILE1}.out.out - ./testfiles/${HDF_FILE1}.out.out.err + ./testfiles/h5copy_misc1.out.out + ./testfiles/h5copy_misc1.out.out.err + ./testfiles/${HDF_FILE1_TMP}.h5 + ./testfiles/h5copy_misc1.out.h5 ) IF (NOT "${last_test}" STREQUAL "") SET_TESTS_PROPERTIES (H5COPY-clear-misc PROPERTIES DEPENDS ${last_test}) ENDIF (NOT "${last_test}" STREQUAL "") SET (last_test "H5COPY-clear-misc") + #----------------------------------------------------------------- # "Test copying object into group which doesn't exist, without -p" + # ADD_H5_CMP_TEST (h5copy_misc1 1 ${HDF_FILE1} v /simple /g1/g2/simple) + #------------------------------------------- + # "Test copying objects to the same file " + # + # create temporary test file with some objects + ADD_H5COPY_TEST (samefile1_pre 0 ${HDF_FILE1}.h5 ${HDF_FILE1_TMP}.h5 v /simple /simple) + ADD_H5COPY_TEST (samefile2_pre 0 ${HDF_FILE1}.h5 ${HDF_FILE1_TMP}.h5 v /grp_dsets /grp_dsets) + # actual test cases + # - dataset + ADD_H5COPY_TEST (samefile1 0 ${HDF_FILE1_TMP}.h5 ${HDF_FILE1_TMP}.h5 v /simple /simple_cp) + # - group with some datasets + ADD_H5COPY_TEST (samefile2 0 ${HDF_FILE1_TMP}.h5 ${HDF_FILE1_TMP}.h5 v /grp_dsets /grp_dsets_cp) ENDIF (BUILD_TESTING) ############################################################################## diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index 3760d6f..fb8bb81 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -319,6 +319,14 @@ main (int argc, const char *argv[]) leave(EXIT_FAILURE); } + /*------------------------------------------------------------------------- + * open output file + *-------------------------------------------------------------------------*/ + + /* Attempt to open an existing HDF5 file first. Need to open the dst file + before the src file just in case that the dst and src are the same file + */ + fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0); /*------------------------------------------------------------------------- * open input file @@ -337,13 +345,11 @@ main (int argc, const char *argv[]) leave(EXIT_FAILURE); } + /*------------------------------------------------------------------------- - * open output file + * create an output file when failed to open it *-------------------------------------------------------------------------*/ - /* Attempt to open an existing HDF5 file first */ - fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0); - /* If we couldn't open an existing file, try creating file */ /* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */ if(fid_dst < 0) diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c index 26a2588..f655c39 100644 --- a/tools/h5copy/h5copygentest.c +++ b/tools/h5copy/h5copygentest.c @@ -231,7 +231,7 @@ static void gent_compressed(hid_t loc_id) /*------------------------------------------------------------------------- * Function: gent_named_vl * - * Purpose: Generate a variable lenght named datatype for a dataset in + * Purpose: Generate a variable lenght named datatype for a dataset in LOC_ID * *------------------------------------------------------------------------- @@ -423,6 +423,7 @@ static herr_t gen_obj_ref(hid_t loc_id) hsize_t dims2[1]={2}; int data[3] = {10,20,30}; int status; + /*--------------------- * create obj references to the previously created objects. * Passing -1 as reference is an object.*/ @@ -645,7 +646,7 @@ out: /*------------------------------------------------------------------------- * Function: Test_Obj_Copy * - * Purpose: Testing with various objects + * Purpose: Testing with various objects * *------------------------------------------------------------------------*/ static void Test_Obj_Copy() @@ -706,14 +707,14 @@ static void Test_Ref_Copy() { hid_t fid=0; herr_t status; - + fid = H5Fcreate (HDF_FILE2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid < 0) { fprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_FILE2); goto out; } - + /* add object reference */ status = gen_obj_ref(fid); if (status < 0) @@ -873,7 +874,7 @@ static void Test_Extlink_Copy() hid_t fid1=0; hid_t fid2=0; herr_t status; - + fid1 = H5Fcreate (HDF_EXT_SRC_FILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if (fid1 < 0) { @@ -887,7 +888,7 @@ static void Test_Extlink_Copy() fprintf(stderr, "Error: %s> H5Fcreate failed.\n", HDF_EXT_TRG_FILE); goto out; } - + /* add links to source external link file */ status = gen_extlink_src(fid1); if (status < 0) diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index 1ce6a31..1c54c8b 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -401,13 +401,13 @@ COPY_EXT_LINKS() TOOLTEST -f ext -i $TESTFILE -o $FILEOUT -v -s /group_ext/extlink_dset -d /copy2_dset echo "Test copying dangling external link (no obj) directly without -f ext" - TOOLTEST -i $TESTFILE -o $FILEOUT -v -s /group_ext/extlink_notyet1 -d /copy_dangle1_1 + TOOLTEST -v -i $TESTFILE -o $FILEOUT -s /group_ext/extlink_notyet1 -d /copy_dangle1_1 echo "Test copying dangling external link (no obj) directly with -f ext" TOOLTEST -f ext -i $TESTFILE -o $FILEOUT -v -s /group_ext/extlink_notyet1 -d /copy_dangle1_2 echo "Test copying dangling external link (no file) directly without -f ext" - TOOLTEST -i $TESTFILE -o $FILEOUT -v -s /group_ext/extlink_notyet2 -d /copy_dangle2_1 + TOOLTEST -v -i $TESTFILE -o $FILEOUT -s /group_ext/extlink_notyet2 -d /copy_dangle2_1 echo "Test copying dangling external link (no file) directly with -f ext" TOOLTEST -f ext -i $TESTFILE -o $FILEOUT -v -s /group_ext/extlink_notyet2 -d /copy_dangle2_2 @@ -443,6 +443,15 @@ TEST_MISC() echo "Test copying object into group which doesn't exist, without -p" TOOLTEST_FAIL h5copy_misc1.out -v -i $TESTFILE -o $FILEOUT -s /simple -d /g1/g2/simple + echo "Test copying objects to the same file " + rm -f $FILEOUT + # create temporary test file ($FILEOUT) with some objects + TOOLTEST -i $TESTFILE -o $FILEOUT -v -s /simple -d /simple + TOOLTEST -i $TESTFILE -o $FILEOUT -v -s /grp_dsets -d /grp_dsets + # actual test cases + TOOLTEST -i $FILEOUT -o $FILEOUT -v -s /simple -d /simple_cp + TOOLTEST -i $FILEOUT -o $FILEOUT -v -s /grp_dsets -d /grp_dsets_cp + # Remove output file created, if the "no cleanup" environment variable is # not defined if test -z "$HDF5_NOCLEANUP"; then |