diff options
author | Jonathan Kim <jkm@hdfgroup.org> | 2011-06-30 21:36:34 (GMT) |
---|---|---|
committer | Jonathan Kim <jkm@hdfgroup.org> | 2011-06-30 21:36:34 (GMT) |
commit | 11349c2361ff12c0cbe4940c078cb3bf4a16ce90 (patch) | |
tree | 05e58aa06b508ac14875d22c19b342c7e71e76af /tools/h5copy | |
parent | 9b1c14d12711bf9f20e196dd90d23df4b7881797 (diff) | |
download | hdf5-11349c2361ff12c0cbe4940c078cb3bf4a16ce90.zip hdf5-11349c2361ff12c0cbe4940c078cb3bf4a16ce90.tar.gz hdf5-11349c2361ff12c0cbe4940c078cb3bf4a16ce90.tar.bz2 |
[svn-r21057] [hdf5 Trunk ] TODO
Purpose:
Work for HDFFV-7602 - HDF5 command tools: Provide framework for reusable
test files among tools
Description:
Provide framework to share test files among tools for tools test.
Tested:
jam (linux32-LE), koala (linux64-LE), heiwa (linuxppc64-BE)
Diffstat (limited to 'tools/h5copy')
-rw-r--r-- | tools/h5copy/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tools/h5copy/testfiles/h5copy_misc1.out | 2 | ||||
-rw-r--r-- | tools/h5copy/testh5copy.sh | 116 |
3 files changed, 95 insertions, 34 deletions
diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index 489ac90..11cebca 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -70,13 +70,6 @@ IF (BUILD_TESTING) ) ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) - ADD_CUSTOM_COMMAND ( - TARGET h5copy - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/testfiles/h5copytst.h5 ${PROJECT_BINARY_DIR}/h5copytst.h5 - ) - ############################################################################## ############################################################################## ### T H E T E S T S M A C R O S ### @@ -159,7 +152,7 @@ IF (BUILD_TESTING) MACRO (ADD_H5_CMP_TEST testname resultcode infile outfile vparam sparam srcname dparam dstname) # If using memchecker add tests without using scripts IF (HDF5_ENABLE_USING_MEMCHECKER) - ADD_TEST (NAME H5COPY-CMP-${testname} COMMAND $<TARGET_FILE:h5copy> -i ${infile} -o ./testfiles/${outfile} ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) + ADD_TEST (NAME H5COPY-CMP-${testname} COMMAND $<TARGET_FILE:h5copy> -i ./testfiles/${infile} -o ./testfiles/${outfile} ${vparam} ${sparam} ${srcname} ${dparam} ${dstname} ${ARGN}) IF (${resultcode} STREQUAL "1") SET_TESTS_PROPERTIES (H5COPY-CMP-${testname} PROPERTIES WILL_FAIL "true") ENDIF (${resultcode} STREQUAL "1") @@ -168,7 +161,7 @@ IF (BUILD_TESTING) NAME H5COPY-CMP-${testname} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:h5copy>" - -D "TEST_ARGS=-i;${infile};-o;./testfiles/${outfile};${vparam};${sparam};${srcname};${dparam};${dstname}" + -D "TEST_ARGS=-i;./testfiles/${infile};-o;./testfiles/${outfile};${vparam};${sparam};${srcname};${dparam};${dstname}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=./testfiles/${testname}.out.out" -D "TEST_EXPECT=${resultcode}" diff --git a/tools/h5copy/testfiles/h5copy_misc1.out b/tools/h5copy/testfiles/h5copy_misc1.out index 370b1a5..10dd1a6 100644 --- a/tools/h5copy/testfiles/h5copy_misc1.out +++ b/tools/h5copy/testfiles/h5copy_misc1.out @@ -1,3 +1,3 @@ -Copying file <h5copytst.h5> and object </simple> to file <./testfiles/h5copytst.out.h5> and object </g1/g2/simple> +Copying file <./testfiles/h5copytst.h5> and object </simple> to file <./testfiles/h5copytst.out.h5> and object </g1/g2/simple> Error in copy...Exiting h5copy error: group </g1> doesn't exist. Use -p to create parent groups. diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index 1dbb03c..65cd353 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -19,6 +19,24 @@ # Thursday, July 20, 2006 # +# The build (current) directory might be different than the source directory. +if test -z "$srcdir"; then + srcdir=. +fi + +# 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" + TESTNAME=h5copy EXIT_SUCCESS=0 EXIT_FAILURE=1 @@ -29,6 +47,31 @@ HDF_FILE2=h5copy_ref.h5 HDF_EXT_SRC_FILE=h5copy_extlinks_src.h5 HDF_EXT_TRG_FILE=h5copy_extlinks_trg.h5 +###################################################################### +# 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 of files that will be copied over to local test dir +LIST_HDF5_TEST_FILES=" +$SRC_H5COPY_TESTFILES/$HDF_FILE1 +$SRC_H5COPY_TESTFILES/$HDF_FILE2 +$SRC_H5COPY_TESTFILES/$HDF_EXT_SRC_FILE +$SRC_H5COPY_TESTFILES/$HDF_EXT_TRG_FILE +" + +# List of expect files that will be copied over to local test dir +LIST_OTHER_TEST_FILES=" +$SRC_H5COPY_TESTFILES/h5copy_extlinks_src.out.ls +$SRC_H5COPY_TESTFILES/h5copy_ref.out.ls +$SRC_H5COPY_TESTFILES/h5copytst.out.ls +$SRC_H5COPY_TESTFILES/h5copy_misc1.out +" + H5COPY=h5copy # The tool name H5COPY_BIN=`pwd`/$H5COPY # The path of the tool binary H5DIFF=h5diff # The h5diff tool name @@ -38,19 +81,14 @@ H5LS_ARGS=-Svr # Arguments to the h5ls tool H5LS_BIN=`pwd`/../h5ls/$H5LS # The path of the h5ls tool binary CMP='cmp -s' DIFF='diff -c' +CP='cp' 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 - srcdir=. -fi -INDIR=$srcdir/testfiles -OUTDIR=./testfiles - -test -d $OUTDIR || mkdir $OUTDIR +TESTDIR=./testfiles +test -d $TESTDIR || mkdir $TESTDIR # RUNSERIAL is used. Check if it can return exit code from executalbe correctly. if [ -n "$RUNSERIAL_NOEXITCODE" ]; then @@ -59,6 +97,31 @@ if [ -n "$RUNSERIAL_NOEXITCODE" ]; then h5haveexitcode=no fi +# +# 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 + if [ -a $tstfile ]; then + $CP -f $tstfile $TESTDIR + else + echo "Error: FAILED to copy $tstfile." + echo " $tstfile doesn't exist!" + exit $EXIT_FAILURE + fi + fi + done +} + # Print a "SKIP" message SKIP() { TESTING $H5COPY $@ @@ -115,6 +178,8 @@ VERIFY_OUTPUT() TOOLTEST() { + actualout="$TESTDIR/tooltest.actualout" + actualerr="$TESTDIR/tooltest.actualerr" runh5diff=yes if [ "$1" = -i ]; then inputfile=$2 @@ -133,19 +198,19 @@ TOOLTEST() echo " output for '$H5COPY $@'" echo "#############################" $RUNSERIAL $H5COPY_BIN $@ - ) > output.out + ) > $actualout 2> $actualerr RET=$? if [ $RET != 0 ]; then echo "*FAILED*" echo "failed result is:" - cat output.out + cat $actualout nerrors="`expr $nerrors + 1`" else echo " PASSED" # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f output.out + rm -f $actualout $actualerr fi fi @@ -184,9 +249,9 @@ CMP_OUTPUT() TOOLTEST_FAIL() { - expectout="$INDIR/$1" - actualout="$OUTDIR/$1.out" - actualerr="$OUTDIR/$1.err" + expectout="$TESTDIR/$1" + actualout="$TESTDIR/$1.actualout" + actualerr="$TESTDIR/$1.actualerr" actualout_sav=${actualout}-sav actualerr_sav=${actualerr}-sav shift @@ -270,8 +335,8 @@ H5DIFFTEST_FAIL() # H5LSTEST() { - expect="$INDIR/`basename $1 .h5`.ls" - actual="$OUTDIR/`basename $1 .h5`.out" + expect="$TESTDIR/`basename $1 .h5`.ls" + actual="$TESTDIR/`basename $1 .h5`.ls.actualout" # Stderr is included in stdout so that the diff can detect # any unexpected output from that stream too. @@ -313,8 +378,8 @@ H5LSTEST() # <none> COPY_OBJECTS() { - TESTFILE="$INDIR/$HDF_FILE1" - FILEOUT="$OUTDIR/`basename $HDF_FILE1 .h5`.out.h5" + TESTFILE="$TESTDIR/$HDF_FILE1" + FILEOUT="$TESTDIR/`basename $HDF_FILE1 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -373,8 +438,8 @@ COPY_OBJECTS() # <none> COPY_REFERENCES() { - TESTFILE="$INDIR/$HDF_FILE2" - FILEOUT="$OUTDIR/`basename $HDF_FILE2 .h5`.out.h5" + TESTFILE="$TESTDIR/$HDF_FILE2" + FILEOUT="$TESTDIR/`basename $HDF_FILE2 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -399,8 +464,8 @@ COPY_REFERENCES() # <none> COPY_EXT_LINKS() { - TESTFILE="$INDIR/$HDF_EXT_SRC_FILE" - FILEOUT="$OUTDIR/`basename $HDF_EXT_SRC_FILE .h5`.out.h5" + TESTFILE="$TESTDIR/$HDF_EXT_SRC_FILE" + FILEOUT="$TESTDIR/`basename $HDF_EXT_SRC_FILE .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -445,8 +510,8 @@ COPY_EXT_LINKS() # <none> TEST_MISC() { - TESTFILE="$HDF_FILE1" - FILEOUT="$OUTDIR/`basename $HDF_FILE1 .h5`.out.h5" + TESTFILE="$TESTDIR/$HDF_FILE1" + FILEOUT="$TESTDIR/`basename $HDF_FILE1 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -473,7 +538,10 @@ TEST_MISC() ############################################################################## ### T H E T E S T S ### ############################################################################## +# prepare for test +COPY_TESTFILES_TO_TESTDIR +# Start tests COPY_OBJECTS COPY_REFERENCES COPY_EXT_LINKS |