diff options
Diffstat (limited to 'tests/testwrapper.sh')
-rwxr-xr-x | tests/testwrapper.sh | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/tests/testwrapper.sh b/tests/testwrapper.sh index 293f8cc..f07f798 100755 --- a/tests/testwrapper.sh +++ b/tests/testwrapper.sh @@ -13,7 +13,7 @@ INPUT_COUNT=0 USE_REDIRECT=0 DO_COMPARISON=0 -while getopts :d:i:rt1 OPTION ; do +while getopts d:i:r OPTION ; do case $OPTION in d) INPUT_DIRECTORY=$OPTARG ;; i) @@ -22,36 +22,58 @@ while getopts :d:i:rt1 OPTION ; do else INPUT_NAME="$INPUT_NAME $OPTARG" fi - INPUT_COUNT=$(($INPUT_COUNT+1)) + INPUT_COUNT=$((INPUT_COUNT+1)) ;; r) USE_REDIRECT=1 ;; - t) USE_TABLES=1 ;; - 1) DO_COMPARISON=1 ;; + *) echo "Usage: ${0} [-d INPUT_DIRECTORY] [-i INPUT_NAME] [-r] TESTNAME" + exit 1 + ;; esac done -shift $(($OPTIND-1)) +shift $((OPTIND-1)) TESTNAME=$1 -INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/`basename "${TESTNAME%.exe}"`.txt} +# There may be a specific input file for this test +INPUT_NAME=${INPUT_NAME:-$INPUT_DIRECTORY/$(basename "${TESTNAME%.exe}").txt} -if [ $DO_COMPARISON = 1 ] ; then - TEST_OUTPUT=`$TESTNAME < $INPUT_NAME` - REF_OUTPUT=`$TESTNAME 1 < $INPUT_NAME` - test "$TEST_OUTPUT" -eq "$REF_OUTPUT" - exit $? -fi +# If it doesn't exist, try stripping out a backend suffix. +# There might be a generic input for all tests with this stem. +# For this purpose we consider _r and _nr to be back ends. +inputs=$INPUT_NAME +INPUT_NAME= +for input in $inputs; do + if [ ! -f "${input}" ] ; then + input=$(echo "${input}" | sed -e 's/_[a-z0-9]*.txt$/.txt/') + fi + if [ "${INPUT_NAME}" = "" ] ; then + INPUT_NAME="${input}" + else + INPUT_NAME="${INPUT_NAME} ${input}" + fi +done + +# Detect if the test wants a table argument. If it does, the test maker will have generated +# a tables=-file option do that the a table file named afte the test was created when the +# scanner was built. Thus we can assume that it will be looking for the table data at +# the matching path we're about to generate. +case ${TESTNAME} in + *ver|*ser|*_ver_*|*_ser_*) USE_TABLES=1 ;; +esac if [ $INPUT_COUNT -gt 1 ] ; then - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} ${INPUT_NAME} + # INPUT_NAME has multiple filenames, so we do want word expansion + # shellcheck disable=SC2086 + $TESTNAME ${USE_TABLES:+"${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables"} ${INPUT_NAME} exit $? fi -if [ -f ${INPUT_NAME} ] ; then +# Set up input redirection as required +if [ -f "${INPUT_NAME}" ] ; then if [ $USE_REDIRECT = 1 ] ; then - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < $INPUT_NAME + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} < "$INPUT_NAME" else - $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} $INPUT_NAME + $TESTNAME ${USE_TABLES:+${INPUT_DIRECTORY}/${TESTNAME%.exe}.tables} "$INPUT_NAME" fi else $TESTNAME |