From 89a22ea5d9edfd3bf68316343b3f78a200703466 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Thu, 25 May 2006 13:24:02 +0000 Subject: 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. --- testsuite/runtest | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'testsuite/runtest') diff --git a/testsuite/runtest b/testsuite/runtest index c7f353690..84cd6a7f3 100755 --- a/testsuite/runtest +++ b/testsuite/runtest @@ -33,16 +33,15 @@ function run_applet_testcase rm -rf 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 if [ $verbose -gt 0 ]; then cat .logfile.txt - #exit 1; - fi; + fi status=$? else echo PASS: $testname @@ -50,7 +49,7 @@ function run_applet_testcase status=$? fi - popd >/dev/null + popd > /dev/null rm -rf tmp return $status @@ -122,14 +121,18 @@ for applet in $applets; do applet=$(echo "$applet" | sed -n 's/\.tests$//p') if [ ${#applet} -ne 0 ] then - if [ ! -h "$LINKSDIR/$applet" ] && [ ${applet:0:4} != "all_" ] + if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ] then echo "SKIPPED: $applet (not built)" continue fi - PATH="$LINKSDIR":$srcdir:$bindir:$PATH \ + if PATH="$LINKSDIR":$srcdir:$bindir:$PATH \ "${srcdir:-.}/$applet".tests - if [ $? -ne 0 ]; then status=1; fi + then + : + else + status=1 + fi fi done -- cgit v1.2.3