make test run script produce TAP if desired
. primarily intended for jenkins . see http://testanything.org/ for more info Change-Id: If0e942f75898eed640f9edd89ef8ffd0bab9726e
This commit is contained in:
parent
d1b3ab953e
commit
5120b43334
64
test/run
64
test/run
@ -45,7 +45,7 @@ tests=$alltests
|
|||||||
|
|
||||||
# Are we given any args? If so, we might have to give
|
# Are we given any args? If so, we might have to give
|
||||||
# or change our testlist
|
# or change our testlist
|
||||||
while getopts 'lt:' opt
|
while getopts 'lt:T' opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
l) echo "$alltests"
|
l) echo "$alltests"
|
||||||
@ -53,7 +53,14 @@ do
|
|||||||
;;
|
;;
|
||||||
t) tests="$OPTARG"
|
t) tests="$OPTARG"
|
||||||
;;
|
;;
|
||||||
?) echo "Usage: run [-l] [-t testlist]" >&2; exit 1
|
T) tapmode=yes
|
||||||
|
diagprefix="# "
|
||||||
|
;;
|
||||||
|
?) echo "Usage: run [-l] [-t testlist] [-T]" >&2
|
||||||
|
echo " -l: list tests, exit" >&2
|
||||||
|
echo " -t: execute given set of tests, default: all" >&2
|
||||||
|
echo " -T: produce TAP-format output" >&2
|
||||||
|
exit 1
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -64,24 +71,40 @@ for i in `echo $tests`; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#
|
|
||||||
if [ $tests_no -eq 0 ]
|
if [ $tests_no -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "No test binaries found. did you compile?"
|
echo "No test binaries found. did you compile?"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Print tests list whenever user asks for TAP mode. It is up
|
||||||
|
# to the caller to make sure it makes sense, i.e. he knows what it
|
||||||
|
# represents.
|
||||||
|
if [ "$tapmode" ]
|
||||||
|
then echo "1..$tests_no"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$tests" = "$alltests" ]
|
if [ "$tests" = "$alltests" ]
|
||||||
then # Print test welcome message
|
then # Print test welcome message
|
||||||
clear
|
if [ ! "$tapmode" ]; then clear; fi
|
||||||
echo -n "Running POSIX compliance test suite. "
|
echo -n "${diagprefix}Running POSIX compliance test suite. "
|
||||||
echo "There are $tests_no tests in total."
|
echo "There are $tests_no tests in total."
|
||||||
echo " "
|
echo "${diagprefix}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Provide an argument for test63
|
# Provide an argument for test63
|
||||||
ARGS_63=`pwd`/mod
|
ARGS_63=`pwd`/mod
|
||||||
|
|
||||||
|
runtest() {
|
||||||
|
i=$1
|
||||||
|
ARG=$2
|
||||||
|
if [ "$ROOT" ]
|
||||||
|
then su - bin -c "cd `pwd`; ./test$i $ARG" || return 1
|
||||||
|
else ./test$i $ARG || return 1
|
||||||
|
fi
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
# Run all the tests, keeping track of who failed.
|
# Run all the tests, keeping track of who failed.
|
||||||
for i in `echo $tests`
|
for i in `echo $tests`
|
||||||
do
|
do
|
||||||
@ -92,14 +115,20 @@ do
|
|||||||
unset ARG
|
unset ARG
|
||||||
testid="`echo $i | sed 's/\..*//'`"
|
testid="`echo $i | sed 's/\..*//'`"
|
||||||
ARG=`eval echo "\\${ARGS_$testid}"`
|
ARG=`eval echo "\\${ARGS_$testid}"`
|
||||||
if [ "$ROOT" ]
|
|
||||||
then su - bin -c "cd `pwd`; ./test$i $ARG" || FAIL=1
|
runtest $i $ARG 2>&1 | sed "s/^/$diagprefix/"
|
||||||
else ./test$i $ARG || FAIL=1
|
FAIL=$?
|
||||||
fi
|
|
||||||
if [ $FAIL -eq 0 ]
|
if [ $FAIL -eq 0 ]
|
||||||
then passed=`expr $passed + 1`
|
then if [ "$tapmode" ]
|
||||||
else failed=`expr $failed + 1`
|
then echo "ok test $i"
|
||||||
badones=`echo $badones " " $i`
|
fi
|
||||||
|
passed=`expr $passed + 1`
|
||||||
|
else if [ "$tapmode" ]
|
||||||
|
then echo "not ok test $i"
|
||||||
|
fi
|
||||||
|
failed=`expr $failed + 1`
|
||||||
|
badones=`echo $badones " " $i`
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
skipped=`expr $skipped + 1`
|
skipped=`expr $skipped + 1`
|
||||||
@ -108,12 +137,11 @@ done
|
|||||||
|
|
||||||
# Print results of the tests.
|
# Print results of the tests.
|
||||||
if [ "$tests" = "$alltests" ]
|
if [ "$tests" = "$alltests" ]
|
||||||
then echo " "
|
then echo "${diagprefix}"
|
||||||
if test $total = $passed
|
if test $total = $passed
|
||||||
then echo All $passed tests completed without error \($skipped skipped\).
|
then echo "${diagprefix}All $passed tests completed without error ($skipped skipped)."
|
||||||
else echo Testing completed. Score: $passed passed, $failed failed, \
|
else echo "${diagprefix}Testing completed. Score: $passed passed, $failed failed, skipped $skipped"
|
||||||
skipped $skipped
|
echo "${diagprefix}The following tests failed: $badones"
|
||||||
echo The following tests failed: $badones
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user