summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfig/cmake/CTestCustom.cmake4
-rw-r--r--release_docs/RELEASE.txt3
-rw-r--r--tools/h5copy/CMakeLists.txt39
-rw-r--r--tools/h5copy/h5copy.c14
-rw-r--r--tools/h5copy/testh5copy.sh9
5 files changed, 60 insertions, 9 deletions
diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake
index 085c36c..c431c17 100755
--- a/config/cmake/CTestCustom.cmake
+++ b/config/cmake/CTestCustom.cmake
@@ -42,6 +42,10 @@ SET (CTEST_CUSTOM_MEMCHECK_IGNORE
H5COPY-H5LS_h5copy_extlinks_src-links #uses runTest.cmake
H5COPY-clear-misc
H5COPY-CMP-h5copy_misc1 #uses runTest.cmake
+ H5COPY-samefile1_pre #needs clear-ext-links
+ H5COPY-samefile2_pre #needs clear-ext-links
+ H5COPY-samefile1 #needs clear-ext-links
+ H5COPY-samefile2 #needs clear-ext-links
######### tools/h5diff #########
H5DIFF-clearall-objects
H5DIFF-h5diff_10 #uses runTest.cmake
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index 91a92e7..0f0269a 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -500,6 +500,9 @@ Bug Fixes since HDF5-1.8.0 release
Tools
-----
+ - Fixed h5copy to be able to copy any object into the same HDF5 file.
+ Previously h5copy displayed error message when target file is same
+ as source file. (XCAO 2011/3/8)
- Fixed h5dump for skipping some values for long array type dataset on
Windows. This issue only occurred on Windows due to the different
return behavior from _vsnprintf() funtion. Bug#2161 (JKM 2011/3/3)
diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt
index 180dc9d..4d279b6 100644
--- a/tools/h5copy/CMakeLists.txt
+++ b/tools/h5copy/CMakeLists.txt
@@ -76,10 +76,9 @@ IF (BUILD_TESTING)
##############################################################################
##############################################################################
- 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)
-
+ #
+ # Perform h5copy according to passing parmeters
+ #
MACRO (ADD_H5COPY_TEST testname resultcode infile outfile vparam srcname dstname)
IF (NOT "${ARGN}" STREQUAL "")
@@ -107,8 +106,19 @@ IF (BUILD_TESTING)
SET_TESTS_PROPERTIES (H5COPY-${testname} PROPERTIES DEPENDS ${last_test})
ENDIF (NOT "${last_test}" STREQUAL "")
SET (last_test "H5COPY-DIFF_${testname}")
- ENDMACRO (ADD_H5COPY_TEST testname resultcode testfile vparam srcname dstname)
+ 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)
# If using memchecker add tests without using scripts
IF (HDF5_ENABLE_USING_MEMCHECKER)
@@ -133,6 +143,10 @@ IF (BUILD_TESTING)
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)
# If using memchecker add tests without using scripts
IF (HDF5_ENABLE_USING_MEMCHECKER)
@@ -170,6 +184,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 (
@@ -312,15 +327,29 @@ IF (BUILD_TESTING)
./testfiles/${HDF_FILE1}.out.h5
./testfiles/${HDF_FILE1}.out.out
./testfiles/${HDF_FILE1}.out.out.err
+ ./testfiles/${HDF_FILE1_TMP}.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/testh5copy.sh b/tools/h5copy/testh5copy.sh
index 7d26b3b..d8838b0 100644
--- a/tools/h5copy/testh5copy.sh
+++ b/tools/h5copy/testh5copy.sh
@@ -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