diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-07-06 19:45:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-07-06 19:45:35 (GMT) |
commit | 98754fa9d12090f5e048fdb05cc5e9ce9111676f (patch) | |
tree | 407e611b19ee551d8153779104022dd886a467e5 /tools/h5copy | |
parent | 29321bcafa9f1c6108bb92b5a844a9d4d9c2c8e7 (diff) | |
download | hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.zip hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.tar.gz hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.tar.bz2 |
[svn-r19050] Description:
Bring r18704:19049 from trunk to revise_chunks branch.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'tools/h5copy')
-rw-r--r-- | tools/h5copy/CMakeLists.txt | 249 | ||||
-rw-r--r-- | tools/h5copy/Makefile.in | 2 | ||||
-rw-r--r-- | tools/h5copy/h5copy.c | 30 | ||||
-rw-r--r-- | tools/h5copy/h5copygentest.c | 15 | ||||
-rw-r--r-- | tools/h5copy/testh5copy.sh | 10 |
5 files changed, 285 insertions, 21 deletions
diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt new file mode 100644 index 0000000..61f5ef3 --- /dev/null +++ b/tools/h5copy/CMakeLists.txt @@ -0,0 +1,249 @@ +cmake_minimum_required (VERSION 2.8) +PROJECT (HDF5_TOOLS_H5COPY) + +#----------------------------------------------------------------------------- +# Setup include Directories +#----------------------------------------------------------------------------- +INCLUDE_DIRECTORIES (${HDF5_TOOLS_SOURCE_DIR}/lib) +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) +IF (WIN32) + IF (MSVC) + IF (NOT BUILD_SHARED_LIBS) + SET_TARGET_PROPERTIES (h5copy + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (NOT BUILD_SHARED_LIBS) + ENDIF (MSVC) +ENDIF (WIN32) +TARGET_LINK_LIBRARIES (h5copy ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) + +SET (H5_DEP_EXECUTABLES h5copy) + +IF (BUILD_TESTING) + IF (NOT BUILD_SHARED_LIBS) + ADD_EXECUTABLE (h5copygentest ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/h5copygentest.c) + H5_NAMING (h5copygentest) + IF (WIN32) + IF (MSVC) + SET_TARGET_PROPERTIES (h5copygentest + PROPERTIES + LINK_FLAGS "/NODEFAULTLIB:MSVCRT" + ) + ENDIF (MSVC) + ENDIF (WIN32) + TARGET_LINK_LIBRARIES (h5copygentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) + + #ADD_TEST (NAME h5copygentest COMMAND $<TARGET_FILE:h5copygentest>) + + SET (H5_DEP_EXECUTABLES ${H5_DEP_EXECUTABLES} + #h5copygentest + ) + ENDIF (NOT BUILD_SHARED_LIBS) + + #-- Copy all the HDF5 files from the test directory into the source directory + SET (HDF5_REFERENCE_FILES + h5copy_extlinks_src.out.ls + h5copy_ref.out.ls + h5copytst.out.ls + ) + SET (HDF5_REFERENCE_TEST_FILES + h5copy_extlinks_src.h5 + h5copy_extlinks_trg.h5 + h5copy_ref.h5 + h5copytst.h5 + ) + + FILE (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + FOREACH (ls_file ${HDF5_REFERENCE_FILES}) + SET (lsdest "${PROJECT_BINARY_DIR}/testfiles/${ls_file}") + #MESSAGE (STATUS " Translating ${ls_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5copy + POST_BUILD + COMMAND ${XLATE_UTILITY} + ARGS ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/testfiles/${ls_file} ${lsdest} -l3 + ) + ENDFOREACH (ls_file ${HDF5_REFERENCE_FILES}) + + FOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) + SET (dest "${PROJECT_BINARY_DIR}/testfiles/${h5_file}") + #MESSAGE (STATUS " Copying ${h5_file}") + ADD_CUSTOM_COMMAND ( + TARGET h5copy + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/testfiles/${h5_file} ${dest} + ) + ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) + + # Test files + SET (HDF_FILE1 h5copytst) + SET (HDF_FILE2 h5copy_ref) + SET (HDF_EXT_SRC_FILE h5copy_extlinks_src) + SET (HDF_EXT_TRG_FILE h5copy_extlinks_trg) + + MACRO (ADD_H5_TEST testname resultcode testfile 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} + ) + 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} + ) + ENDIF (NOT "${ARGN}" STREQUAL "") + 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} + ) + IF (${resultcode} STREQUAL "1") + SET_TESTS_PROPERTIES (H5COPY-DIFF_${testname} PROPERTIES WILL_FAIL "true") + ENDIF (${resultcode} STREQUAL "1") + ENDIF (NOT ${resultcode} STREQUAL "2") + ENDMACRO (ADD_H5_TEST testname resultcode testfile vparam srcname dstname) + + + MACRO (ADD_H5LS_TEST file) + ADD_TEST ( + NAME H5COPY-H5LS_${file} + 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" + ) + ENDMACRO (ADD_H5LS_TEST file) + +############# COPY OBJECTS ############## + + # Remove any output file left over from previous test run + ADD_TEST ( + NAME H5COPY-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ./testfiles/${HDF_FILE1}.out.h5 + ./testfiles/${HDF_FILE1}.out.out + ) + + # "Test copying various forms of datasets" + ADD_H5_TEST (simple 0 ${HDF_FILE1} v simple simple) + ADD_H5_TEST (chunk 0 ${HDF_FILE1} v chunk chunk) + ADD_H5_TEST (compact 0 ${HDF_FILE1} v compact compact) + ADD_H5_TEST (compound 0 ${HDF_FILE1} v compound compound) + ADD_H5_TEST (compressed 0 ${HDF_FILE1} v compressed compressed) + ADD_H5_TEST (named_vl 0 ${HDF_FILE1} v named_vl named_vl) + ADD_H5_TEST (nested_vl 0 ${HDF_FILE1} v nested_vl nested_vl) + + # "Test copying dataset within group in source file to root of destination" + ADD_H5_TEST (simple_top 0 ${HDF_FILE1} v grp_dsets/simple simple_top) + + # "Test copying & renaming dataset" + ADD_H5_TEST (rename 0 ${HDF_FILE1} v compound rename) + + # "Test copying empty, 'full' & 'nested' groups" + ADD_H5_TEST (grp_empty 0 ${HDF_FILE1} v grp_empty grp_empty) + ADD_H5_TEST (grp_dsets 0 ${HDF_FILE1} v grp_dsets grp_dsets) + ADD_H5_TEST (grp_nested 0 ${HDF_FILE1} v grp_nested grp_nested) + + # "Test copying dataset within group in source file to group in destination" + ADD_H5_TEST (simple_group 0 ${HDF_FILE1} v /grp_dsets/simple /grp_dsets/simple_group) + + # "Test copying & renaming group" + ADD_H5_TEST (grp_rename 1 ${HDF_FILE1} v grp_dsets grp_rename) + + # "Test copying 'full' group hierarchy into group in destination file" + ADD_H5_TEST (grp_dsets_rename 1 ${HDF_FILE1} v grp_dsets /grp_rename/grp_dsets) + + # "Test copying objects into group hier. that doesn't exist yet in destination file" + ADD_H5_TEST (A_B1_simple 0 ${HDF_FILE1} vp simple /A/B1/simple) + ADD_H5_TEST (A_B2_simple2 0 ${HDF_FILE1} vp simple /A/B2/simple2) + ADD_H5_TEST (C_D_simple 0 ${HDF_FILE1} vp /grp_dsets/simple /C/D/simple) + ADD_H5_TEST (E_F_grp_dsets 1 ${HDF_FILE1} vp /grp_dsets /E/F/grp_dsets) + ADD_H5_TEST (G_H_grp_nested 1 ${HDF_FILE1} vp /grp_nested /G/H/grp_nested) + + # Verify that the file created above is correct + ADD_H5LS_TEST (${HDF_FILE1}) + +############# COPY REFERENCES ############## + + # Remove any output file left over from previous test run + ADD_TEST ( + NAME H5COPY-clear-refs + COMMAND ${CMAKE_COMMAND} + -E remove + ./testfiles/${HDF_FILE2}.out.h5 + ./testfiles/${HDF_FILE2}.out.out + ) + + # "Test copying object and region references" + ADD_H5_TEST (region_ref 2 ${HDF_FILE2} v / /COPY ref) + + # Verify that the file created above is correct + ADD_H5LS_TEST (${HDF_FILE2}) + +############# COPY EXT LINKS ############## + + # Remove any output file left over from previous test run + ADD_TEST ( + NAME H5COPY-clear-ext-links + COMMAND ${CMAKE_COMMAND} + -E remove + ./testfiles/${HDF_EXT_SRC_FILE}.out.h5 + ./testfiles/${HDF_EXT_SRC_FILE}.out.out + ) + + # "Test copying external link directly without -f ext" + ADD_H5_TEST (ext_link 2 ${HDF_EXT_SRC_FILE} v /group_ext/extlink_dset /copy1_dset) + + # "Test copying external link directly with -f ext" + 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) + + # "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) + + # "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) + + # "Test copying a group contains external links without -f ext" + ADD_H5_TEST (ext_link_group 2 ${HDF_EXT_SRC_FILE} v /group_ext /copy1_group) + + # "Test copying a group contains external links with -f ext" + ADD_H5_TEST (ext_link_group_f 2 ${HDF_EXT_SRC_FILE} v /group_ext /copy2_group ext) + + # Verify that the file created above is correct + ADD_H5LS_TEST (${HDF_EXT_SRC_FILE}) + +ENDIF (BUILD_TESTING) + +#-----------------------------------------------------------------------------
+# Rules for Installation of tools using make Install target
+#-----------------------------------------------------------------------------
+INSTALL ( + TARGETS + h5copy + RUNTIME DESTINATION + bin/tools + COMPONENT + toolsapplications +) diff --git a/tools/h5copy/Makefile.in b/tools/h5copy/Makefile.in index 48052b3..0ac4799 100644 --- a/tools/h5copy/Makefile.in +++ b/tools/h5copy/Makefile.in @@ -192,12 +192,12 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTRUMENT = @INSTRUMENT@ INSTRUMENT_LIBRARY = @INSTRUMENT_LIBRARY@ +LARGEFILE = @LARGEFILE@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ -LINUX_LFS = @LINUX_LFS@ LIPO = @LIPO@ LL_PATH = @LL_PATH@ LN_S = @LN_S@ diff --git a/tools/h5copy/h5copy.c b/tools/h5copy/h5copy.c index 0ea8e16..89cb5fb 100644 --- a/tools/h5copy/h5copy.c +++ b/tools/h5copy/h5copy.c @@ -19,8 +19,8 @@ #include <string.h> #include <stdlib.h> -const char *progname="h5copy"; -int d_status; +/* Name of tool */ +#define PROGRAMNAME "h5copy" /* command-line options: short and long-named parameters */ static const char *s_opts = "d:f:hi:o:ps:vV"; @@ -176,7 +176,7 @@ static int parse_flag(const char* str_flag, unsigned *flag) } else { - error_msg(progname, "Error in input flag\n"); + error_msg("Error in input flag\n"); return -1; } @@ -216,7 +216,9 @@ main (int argc, const char *argv[]) int li_ret; h5tool_link_info_t linkinfo; - /* initialize h5tools lib */ + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); +/* initialize h5tools lib */ h5tools_init(); /* Check for no command line parameters */ @@ -266,7 +268,7 @@ main (int argc, const char *argv[]) break; case 'V': - print_version(progname); + print_version(h5tools_getprogname()); leave(EXIT_SUCCESS); break; @@ -286,28 +288,28 @@ main (int argc, const char *argv[]) if (fname_src==NULL) { - error_msg(progname, "Input file name missing\n"); + error_msg("Input file name missing\n"); usage(); leave(EXIT_FAILURE); } if (fname_dst==NULL) { - error_msg(progname, "Output file name missing\n"); + error_msg("Output file name missing\n"); usage(); leave(EXIT_FAILURE); } if (oname_src==NULL) { - error_msg(progname, "Source object name missing\n"); + error_msg("Source object name missing\n"); usage(); leave(EXIT_FAILURE); } if (oname_dst==NULL) { - error_msg(progname, "Destination object name missing\n"); + error_msg("Destination object name missing\n"); usage(); leave(EXIT_FAILURE); } @@ -324,7 +326,7 @@ main (int argc, const char *argv[]) *-------------------------------------------------------------------------*/ if (fid_src==-1) { - error_msg(progname, "Could not open input file <%s>...Exiting\n", fname_src); + error_msg("Could not open input file <%s>...Exiting\n", fname_src); if (fname_src) free(fname_src); leave(EXIT_FAILURE); @@ -347,7 +349,7 @@ main (int argc, const char *argv[]) *-------------------------------------------------------------------------*/ if (fid_dst==-1) { - error_msg(progname, "Could not open output file <%s>...Exiting\n", fname_dst); + error_msg("Could not open output file <%s>...Exiting\n", fname_dst); if (fname_src) free(fname_src); if (fname_dst) @@ -388,7 +390,7 @@ main (int argc, const char *argv[]) /* Create link creation property list */ if((lcpl_id = H5Pcreate(H5P_LINK_CREATE)) < 0) { - error_msg(progname, "Could not create link creation property list\n"); + error_msg("Could not create link creation property list\n"); goto error; } /* end if */ @@ -396,13 +398,13 @@ main (int argc, const char *argv[]) if(parents) { /* Set the intermediate group creation property */ if(H5Pset_create_intermediate_group(lcpl_id, 1) < 0) { - error_msg(progname, "Could not set property for creating parent groups\n"); + error_msg("Could not set property for creating parent groups\n"); goto error; } /* end if */ /* Display some output if requested */ if(verbose) - printf("%s: Creating parent groups\n", progname); + printf("%s: Creating parent groups\n", h5tools_getprogname()); } /* end if */ /*------------------------------------------------------------------------- diff --git a/tools/h5copy/h5copygentest.c b/tools/h5copy/h5copygentest.c index e52b700..26a2588 100644 --- a/tools/h5copy/h5copygentest.c +++ b/tools/h5copy/h5copygentest.c @@ -21,6 +21,9 @@ #include "H5private.h" #include "h5tools.h" +/* Name of tool */ +#define PROGRAMNAME "h5copygentest" + /* HDF file names */ #define HDF_FILE1 "h5copytst.h5" #define HDF_FILE1_NEW "h5copytst_new.h5" @@ -420,6 +423,10 @@ 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.*/ + hobj_ref_t or_data[2]; /* write buffer */ herr_t ret = SUCCEED; /*-------------- @@ -462,11 +469,6 @@ static herr_t gen_obj_ref(hid_t loc_id) } H5Gclose(oid); - /*--------------------- - * create obj references to the previously created objects. - * Passing -1 as reference is an object.*/ - hobj_ref_t or_data[2]; /* write buffer */ - status = H5Rcreate (&or_data[0], loc_id, OBJ_REF_DS, H5R_OBJECT, -1); if (status < 0) { @@ -914,6 +916,9 @@ out: int main(void) { + h5tools_setprogname(PROGRAMNAME); + h5tools_setstatus(EXIT_SUCCESS); + Test_Obj_Copy(); Test_Ref_Copy(); Test_Extlink_Copy(); diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index ad731b6..029caf9 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -41,6 +41,7 @@ DIFF='diff -c' nerrors=0 verbose=yes +h5haveexitcode=yes # default is yes # The build (current) directory might be different than the source directory. if test -z "$srcdir"; then @@ -51,6 +52,13 @@ OUTDIR=./testfiles test -d $OUTDIR || mkdir $OUTDIR +# RUNSERIAL is used. Check if it can return exit code from executalbe correctly. +if [ -n "$RUNSERIAL_NOEXITCODE" ]; then + echo "***Warning*** Serial Exit Code is not passed back to shell corretly." + echo "***Warning*** Exit code checking is skipped." + h5haveexitcode=no +fi + # Print a "SKIP" message SKIP() { TESTING $H5COPY $@ @@ -200,7 +208,7 @@ H5DIFFTEST_FAIL() $RUNSERIAL $H5DIFF_BIN -q "$@" RET=$? - if [ $RET != 1 ] ; then + if [ $h5haveexitcode = 'yes' -a $RET != 1 ] ; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" else |