mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-04-18 17:40:55 +08:00
[svn-r19726] [BZ2072]Add compare output to expected test for help and version options of mkgrp.
Tested: local linux
This commit is contained in:
parent
ac212d18f8
commit
1c45b0eeb5
@ -165,7 +165,8 @@ SET (HDF5_PACKAGE_NAME "HDF5")
|
||||
SET (HDF5_PACKAGE_VERSION "${H5_VERS_MAJOR}.${H5_VERS_MINOR}.${H5_VERS_RELEASE}")
|
||||
SET (HDF5_PACKAGE_VERSION_MAJOR "${H5_VERS_MAJOR}.${H5_VERS_MINOR}")
|
||||
SET (HDF5_PACKAGE_VERSION_MINOR "${H5_VERS_RELEASE}")
|
||||
SET (HDF5_PACKAGE_STRING "${HDF5_PACKAGE_NAME} ${HDF5_PACKAGE_VERSION}")
|
||||
SET (HDF5_PACKAGE_VERSION_STRING "${HDF5_PACKAGE_VERSION}")
|
||||
SET (HDF5_PACKAGE_STRING "${HDF5_PACKAGE_NAME} ${HDF5_PACKAGE_VERSION_STRING}")
|
||||
SET (HDF5_PACKAGE_TARNAME "hdf5")
|
||||
SET (HDF5_PACKAGE_URL "http://www.hdfgroup.org")
|
||||
SET (HDF5_PACKAGE_BUGREPORT "help@hdfgroup.org")
|
||||
|
2
MANIFEST
2
MANIFEST
@ -1113,6 +1113,8 @@
|
||||
./tools/misc/testh5mkgrp.sh
|
||||
./tools/misc/testh5repart.sh.in
|
||||
./tools/misc/talign.c
|
||||
./tools/misc/testfiles/h5mkgrp_help.txt
|
||||
./tools/misc/testfiles/h5mkgrp_version.txt.in
|
||||
|
||||
# h5stat sources
|
||||
./tools/h5stat/Makefile.am
|
||||
|
@ -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)
|
||||
|
7
tools/misc/testfiles/h5mkgrp_help.txt
Normal file
7
tools/misc/testfiles/h5mkgrp_help.txt
Normal file
@ -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
|
1
tools/misc/testfiles/h5mkgrp_version.txt.in
Normal file
1
tools/misc/testfiles/h5mkgrp_version.txt.in
Normal file
@ -0,0 +1 @@
|
||||
h5mkgrp: Version @HDF5_PACKAGE_VERSION_STRING@
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user