diff options
Diffstat (limited to 'tools/h5copy/testh5copy.sh')
-rw-r--r-- | tools/h5copy/testh5copy.sh | 138 |
1 files changed, 103 insertions, 35 deletions
diff --git a/tools/h5copy/testh5copy.sh b/tools/h5copy/testh5copy.sh index 3816def..4501e29 100644 --- a/tools/h5copy/testh5copy.sh +++ b/tools/h5copy/testh5copy.sh @@ -19,15 +19,52 @@ # 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 -# Test files -HDF_FILE1=h5copytst.h5 -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/h5copytst.h5 +$SRC_H5COPY_TESTFILES/h5copy_ref.h5 +$SRC_H5COPY_TESTFILES/h5copy_extlinks_src.h5 +$SRC_H5COPY_TESTFILES/h5copy_extlinks_trg.h5 +" + +# 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 @@ -38,19 +75,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 +91,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 $@ @@ -100,6 +157,9 @@ VERIFY_OUTPUT() echo "Verifying output files $* $SPACES" | cut -c1-70 | tr -d '\012' } +# Source in the output filter function definitions. +. $srcdir/../../bin/output_filter.sh + # Run a test and print PASS or *FAIL*. If h5copy can complete # with exit status 0, consider it pass. If a test fails then increment # the `nerrors' global variable. @@ -112,6 +172,8 @@ VERIFY_OUTPUT() TOOLTEST() { + actualout="$TESTDIR/tooltest.actualout" + actualerr="$TESTDIR/tooltest.actualerr" runh5diff=yes if [ "$1" = -i ]; then inputfile=$2 @@ -130,19 +192,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 @@ -181,9 +243,11 @@ 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 if [ "$1" = -i ]; then inputfile=$2 @@ -199,7 +263,13 @@ TOOLTEST_FAIL() #echo "#############################" $RUNSERIAL $H5COPY_BIN $@ ) > $actualout 2> $actualerr + RET=$? + # save actualout and actualerr in case they are needed later. + cp $actualout $actualout_sav + STDOUT_FILTER $actualout + cp $actualerr $actualerr_sav + STDERR_FILTER $actualerr if [ $RET != 0 ]; then echo " PASSED" # Verifying output text from h5copy @@ -219,7 +289,7 @@ TOOLTEST_FAIL() # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actualout $actualerr + rm -f $actualout $actualerr $actualout_sav $actualerr_sav fi } @@ -259,8 +329,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. @@ -269,9 +339,6 @@ H5LSTEST() # so that the output is more portable VERIFY_H5LS $@ ( - echo "#############################" - echo "Expected output for '$H5LS $@'" - echo "#############################" $RUNSERIAL $H5LS_BIN $H5LS_ARGS $@ ) 2>&1 |sed 's/Modified:.*/Modified: XXXX-XX-XX XX:XX:XX XXX/' |sed 's/Storage:.*/Storage: <details removed for portability>/' >$actual @@ -302,8 +369,8 @@ H5LSTEST() # <none> COPY_OBJECTS() { - TESTFILE="$INDIR/$HDF_FILE1" - FILEOUT="$OUTDIR/`basename $HDF_FILE1 .h5`.out.h5" + TESTFILE="$TESTDIR/h5copytst.h5" + FILEOUT="$TESTDIR/`basename h5copytst.h5 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -362,8 +429,8 @@ COPY_OBJECTS() # <none> COPY_REFERENCES() { - TESTFILE="$INDIR/$HDF_FILE2" - FILEOUT="$OUTDIR/`basename $HDF_FILE2 .h5`.out.h5" + TESTFILE="$TESTDIR/h5copy_ref.h5" + FILEOUT="$TESTDIR/`basename h5copy_ref.h5 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -388,8 +455,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/h5copy_extlinks_src.h5" + FILEOUT="$TESTDIR/`basename h5copy_extlinks_src.h5 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -434,8 +501,8 @@ COPY_EXT_LINKS() # <none> TEST_MISC() { - TESTFILE="$HDF_FILE1" - FILEOUT="$OUTDIR/`basename $HDF_FILE1 .h5`.out.h5" + TESTFILE="$TESTDIR/h5copytst.h5" + FILEOUT="$TESTDIR/`basename h5copytst.h5 .h5`.out.h5" # Remove any output file left over from previous test run rm -f $FILEOUT @@ -462,7 +529,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 @@ -471,8 +541,6 @@ TEST_MISC # Add newline for nicer formatting echo " " -COPYOBJECTS h5copytst_new.h5 - if test $nerrors -eq 0 ; then echo "All $TESTNAME tests passed." exit $EXIT_SUCCESS |