make the testsuite a little less brittle:
- 'function fn_name\n{' breaks on older FreeBSD default shells, so use the more widely supported 'fn_name () {'. This needs more fixing.. - test for integers ought to use the proper operators - test for strings ought to use quoting of the strings to be fair to strange implementations of test(1) - make sure not to ignore return-codes != 0 from commands; Some shells exit immediately on this (much like explicitely requesting set -e in e.g. bash) TODO: *) Some older shells do not allow a space after the test-condition in an "if" statement. This doesn't work: if [ $status -ne 0 ] ; then as opposed to this: if [ $status -ne 0 ]; then or this if [ $status -ne 0 ] then *) strict spacing between commands. In some shells you have to say: foo ; bar ; baz The affected shells barf on stuff like ommitting the space, so this doesn't work: foo; bar ;baz *) $() vs. `` The former isn't really portable as opposed to the latter. *) fix frong assumption that the testsuite is run from the source-dir. This is a complete misconception and renders the testsuite completely useless. That said, i note that IMO a test-harness ought to do it's best to work in a wide variety of environments, everything else defeats it's purpose.
This commit is contained in:
@@ -33,16 +33,15 @@ function run_applet_testcase
|
|||||||
|
|
||||||
rm -rf tmp
|
rm -rf tmp
|
||||||
mkdir -p tmp
|
mkdir -p tmp
|
||||||
pushd tmp >/dev/null
|
pushd tmp > /dev/null
|
||||||
|
|
||||||
d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1
|
d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1 || status=$?
|
||||||
|
|
||||||
if [ $? != 0 ] ; then
|
if [ $status -ne 0 ] ; then
|
||||||
echo FAIL: $testname
|
echo FAIL: $testname
|
||||||
if [ $verbose -gt 0 ]; then
|
if [ $verbose -gt 0 ]; then
|
||||||
cat .logfile.txt
|
cat .logfile.txt
|
||||||
#exit 1;
|
fi
|
||||||
fi;
|
|
||||||
status=$?
|
status=$?
|
||||||
else
|
else
|
||||||
echo PASS: $testname
|
echo PASS: $testname
|
||||||
@@ -50,7 +49,7 @@ function run_applet_testcase
|
|||||||
status=$?
|
status=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
popd >/dev/null
|
popd > /dev/null
|
||||||
rm -rf tmp
|
rm -rf tmp
|
||||||
|
|
||||||
return $status
|
return $status
|
||||||
@@ -122,14 +121,18 @@ for applet in $applets; do
|
|||||||
applet=$(echo "$applet" | sed -n 's/\.tests$//p')
|
applet=$(echo "$applet" | sed -n 's/\.tests$//p')
|
||||||
if [ ${#applet} -ne 0 ]
|
if [ ${#applet} -ne 0 ]
|
||||||
then
|
then
|
||||||
if [ ! -h "$LINKSDIR/$applet" ] && [ ${applet:0:4} != "all_" ]
|
if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ]
|
||||||
then
|
then
|
||||||
echo "SKIPPED: $applet (not built)"
|
echo "SKIPPED: $applet (not built)"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
PATH="$LINKSDIR":$srcdir:$bindir:$PATH \
|
if PATH="$LINKSDIR":$srcdir:$bindir:$PATH \
|
||||||
"${srcdir:-.}/$applet".tests
|
"${srcdir:-.}/$applet".tests
|
||||||
if [ $? -ne 0 ]; then status=1; fi
|
then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
status=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
@@ -37,7 +37,7 @@ export SKIP=
|
|||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
|
||||||
optional()
|
optional ()
|
||||||
{
|
{
|
||||||
option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"`
|
option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"`
|
||||||
# Not set?
|
# Not set?
|
||||||
@@ -55,6 +55,7 @@ testing ()
|
|||||||
{
|
{
|
||||||
NAME="$1"
|
NAME="$1"
|
||||||
[ -z "$1" ] && NAME=$2
|
[ -z "$1" ] && NAME=$2
|
||||||
|
ret=0
|
||||||
|
|
||||||
if [ $# -ne 5 ]
|
if [ $# -ne 5 ]
|
||||||
then
|
then
|
||||||
@@ -76,12 +77,15 @@ testing ()
|
|||||||
echo -ne "$5" | eval "$2" > actual
|
echo -ne "$5" | eval "$2" > actual
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
|
|
||||||
cmp expected actual > /dev/null
|
cmp expected actual > /dev/null || ret=$?
|
||||||
if [ $? -ne 0 ]
|
if [ $ret -ne 0 ]
|
||||||
then
|
then
|
||||||
FAILCOUNT=$[$FAILCOUNT+1]
|
FAILCOUNT=$[$FAILCOUNT+1]
|
||||||
echo "FAIL: $NAME"
|
echo "FAIL: $NAME"
|
||||||
[ -n "$VERBOSE" ] && diff -u expected actual
|
if [ -n "$VERBOSE" ]
|
||||||
|
then
|
||||||
|
diff -u expected actual || /bin/true
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo "PASS: $NAME"
|
echo "PASS: $NAME"
|
||||||
fi
|
fi
|
||||||
@@ -97,7 +101,7 @@ testing ()
|
|||||||
# the file is assumed to already be there and only its library dependencies
|
# the file is assumed to already be there and only its library dependencies
|
||||||
# are copied.
|
# are copied.
|
||||||
|
|
||||||
function mkchroot
|
mkchroot ()
|
||||||
{
|
{
|
||||||
[ $# -lt 2 ] && return
|
[ $# -lt 2 ] && return
|
||||||
|
|
||||||
@@ -126,7 +130,7 @@ function mkchroot
|
|||||||
# Needed commands listed on command line
|
# Needed commands listed on command line
|
||||||
# Script fed to stdin.
|
# Script fed to stdin.
|
||||||
|
|
||||||
function dochroot
|
dochroot ()
|
||||||
{
|
{
|
||||||
mkdir tmpdir4chroot
|
mkdir tmpdir4chroot
|
||||||
mount -t ramfs tmpdir4chroot tmpdir4chroot
|
mount -t ramfs tmpdir4chroot tmpdir4chroot
|
||||||
|
Reference in New Issue
Block a user