diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2010-11-04 20:51:05 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2010-11-04 20:51:05 (GMT) |
commit | 1c45b0eeb5c9b92b9a47664f526f62041af090f5 (patch) | |
tree | f72eba2ac66c4c83a7cb03253e3da7565ad81ce7 /tools | |
parent | ac212d18f8b1f717e1850aa0d8b64128b56bdfd7 (diff) | |
download | hdf5-1c45b0eeb5c9b92b9a47664f526f62041af090f5.zip hdf5-1c45b0eeb5c9b92b9a47664f526f62041af090f5.tar.gz hdf5-1c45b0eeb5c9b92b9a47664f526f62041af090f5.tar.bz2 |
[svn-r19726] [BZ2072]Add compare output to expected test for help and version options of mkgrp.
Tested: local linux
Diffstat (limited to 'tools')
-rw-r--r-- | tools/misc/CMakeLists.txt | 30 | ||||
-rw-r--r-- | tools/misc/testfiles/h5mkgrp_help.txt | 7 | ||||
-rw-r--r-- | tools/misc/testfiles/h5mkgrp_version.txt.in | 1 | ||||
-rw-r--r-- | tools/misc/testh5mkgrp.sh | 43 |
4 files changed, 76 insertions, 5 deletions
diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt index 77962ec..2d8ccc8 100644 --- a/tools/misc/CMakeLists.txt +++ b/tools/misc/CMakeLists.txt @@ -91,8 +91,8 @@ IF (BUILD_TESTING) ENDFOREACH (h5_file ${HDF5_REFERENCE_TEST_FILES}) SET (HDF5_MKGRP_TEST_FILES - h5mkgrp_help - h5mkgrp_version + #h5mkgrp_help + #h5mkgrp_version h5mkgrp_single h5mkgrp_single_latest h5mkgrp_several @@ -115,6 +115,14 @@ IF (BUILD_TESTING) ) ENDFOREACH (h5_mkgrp_file ${HDF5_MKGRP_TEST_FILES}) + ADD_CUSTOM_COMMAND ( + TARGET h5mkgrp + POST_BUILD + COMMAND ${XLATE_UTILITY} + ARGS ${PROJECT_SOURCE_DIR}/testfiles/h5mkgrp_help.txt ${PROJECT_BINARY_DIR}/h5mkgrp_help.txt -l0 + ) + CONFIGURE_FILE (${PROJECT_SOURCE_DIR}/testfiles/h5mkgrp_version.txt.in ${PROJECT_BINARY_DIR}/h5mkgrp_version.txt @ONLY) + ############################################################################## ############################################################################## ### T H E T E S T S M A C R O S ### @@ -155,6 +163,20 @@ IF (BUILD_TESTING) ) ENDMACRO (ADD_H5_TEST resultfile resultcode resultoption) + MACRO (ADD_H5_CMP resultfile resultcode) + ADD_TEST ( + NAME H5MKGRP-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5mkgrp>" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.txt" + -P "${HDF5_RESOURCES_DIR}/runTest.cmake" + ) + ENDMACRO (ADD_H5_CMP resultfile resultcode) + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -202,8 +224,8 @@ IF (BUILD_TESTING) ) # Check that help & version is displayed properly - ADD_H5_TEST (h5mkgrp_help 1 "-h") - ADD_H5_TEST (h5mkgrp_version 1 "-V") + ADD_H5_CMP (h5mkgrp_help 0 "-h") + ADD_H5_CMP (h5mkgrp_version 0 "-V") # Create single group at root level ADD_H5_TEST (h5mkgrp_single 0 " " single) diff --git a/tools/misc/testfiles/h5mkgrp_help.txt b/tools/misc/testfiles/h5mkgrp_help.txt new file mode 100644 index 0000000..ba130f6 --- /dev/null +++ b/tools/misc/testfiles/h5mkgrp_help.txt @@ -0,0 +1,7 @@ +usage: h5mkgrp [OPTIONS] FILE GROUP... + OPTIONS + -h, --help Print a usage message and exit + -l, --latest Use latest version of file format to create groups + -p, --parents No error if existing, make parent groups as needed + -v, --verbose Print information about OBJECTS and OPTIONS + -V, --version Print version number and exit diff --git a/tools/misc/testfiles/h5mkgrp_version.txt.in b/tools/misc/testfiles/h5mkgrp_version.txt.in new file mode 100644 index 0000000..75c13a5 --- /dev/null +++ b/tools/misc/testfiles/h5mkgrp_version.txt.in @@ -0,0 +1 @@ +h5mkgrp: Version @HDF5_PACKAGE_VERSION_STRING@ diff --git a/tools/misc/testh5mkgrp.sh b/tools/misc/testh5mkgrp.sh index e6cb96e..7b8dc05 100644 --- a/tools/misc/testh5mkgrp.sh +++ b/tools/misc/testh5mkgrp.sh @@ -158,12 +158,53 @@ echo "FILEOUT=" $FILEOUT fi } +# Single run of tool +# +# Assumed arguments: +# $1 is test expected output file +# $2 is h5mkgrp options +# $* are groups to create +CMPTEST() +{ + FILEOUT=$OUTDIR/$1 + expect="$srcdir/testfiles/`basename $1 .h5`.txt" + actual="./testfiles/`basename $1 .h5`.out" + actual_err="./testfiles/`basename $1 .h5`.err" + shift + + # Stderr is included in stdout so that the diff can detect + # any unexpected output from that stream too. + TESTING $H5MKGRP $@ + ( + $RUNSERIAL $H5MKGRP_BIN $@ + ) >$actual 2>$actual_err + cat $actual_err >> $actual + + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + elif $CMP $expect $actual; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.txt) differs from actual result (*.out)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect $actual |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err + fi +} + ############################################################################## ### T H E T E S T S ### ############################################################################## # Check that help & version is displayed properly -RUNTEST h5mkgrp_help.h5 "-h" +CMPTEST h5mkgrp_help.h5 "-h" RUNTEST h5mkgrp_version.h5 "-V" # Create single group at root level |