diff options
author | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-05-25 13:24:02 +0000 |
---|---|---|
committer | aldot <aldot@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-05-25 13:24:02 +0000 |
commit | 22e8fa87319bfaef72ac7edb6b18138f3dbcdf50 (patch) | |
tree | 9e4a37c51407dd9da2808f5642043b3382fd75fd | |
parent | 103e705ffab8dab5fd99e625b88d610979e6f13e (diff) | |
download | busybox-w32-22e8fa87319bfaef72ac7edb6b18138f3dbcdf50.tar.gz busybox-w32-22e8fa87319bfaef72ac7edb6b18138f3dbcdf50.tar.bz2 busybox-w32-22e8fa87319bfaef72ac7edb6b18138f3dbcdf50.zip |
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.
git-svn-id: svn://busybox.net/trunk/busybox@15167 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rwxr-xr-x | testsuite/runtest | 21 | ||||
-rwxr-xr-x | testsuite/testing.sh | 16 |
2 files changed, 22 insertions, 15 deletions
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 | |||
33 | 33 | ||
34 | rm -rf tmp | 34 | rm -rf tmp |
35 | mkdir -p tmp | 35 | mkdir -p tmp |
36 | pushd tmp >/dev/null | 36 | pushd tmp > /dev/null |
37 | 37 | ||
38 | d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1 | 38 | d=$srcdir sh -x -e $testcase >.logfile.txt 2>&1 || status=$? |
39 | 39 | ||
40 | if [ $? != 0 ] ; then | 40 | if [ $status -ne 0 ] ; then |
41 | echo FAIL: $testname | 41 | echo FAIL: $testname |
42 | if [ $verbose -gt 0 ]; then | 42 | if [ $verbose -gt 0 ]; then |
43 | cat .logfile.txt | 43 | cat .logfile.txt |
44 | #exit 1; | 44 | fi |
45 | fi; | ||
46 | status=$? | 45 | status=$? |
47 | else | 46 | else |
48 | echo PASS: $testname | 47 | echo PASS: $testname |
@@ -50,7 +49,7 @@ function run_applet_testcase | |||
50 | status=$? | 49 | status=$? |
51 | fi | 50 | fi |
52 | 51 | ||
53 | popd >/dev/null | 52 | popd > /dev/null |
54 | rm -rf tmp | 53 | rm -rf tmp |
55 | 54 | ||
56 | return $status | 55 | return $status |
@@ -122,14 +121,18 @@ for applet in $applets; do | |||
122 | applet=$(echo "$applet" | sed -n 's/\.tests$//p') | 121 | applet=$(echo "$applet" | sed -n 's/\.tests$//p') |
123 | if [ ${#applet} -ne 0 ] | 122 | if [ ${#applet} -ne 0 ] |
124 | then | 123 | then |
125 | if [ ! -h "$LINKSDIR/$applet" ] && [ ${applet:0:4} != "all_" ] | 124 | if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ] |
126 | then | 125 | then |
127 | echo "SKIPPED: $applet (not built)" | 126 | echo "SKIPPED: $applet (not built)" |
128 | continue | 127 | continue |
129 | fi | 128 | fi |
130 | PATH="$LINKSDIR":$srcdir:$bindir:$PATH \ | 129 | if PATH="$LINKSDIR":$srcdir:$bindir:$PATH \ |
131 | "${srcdir:-.}/$applet".tests | 130 | "${srcdir:-.}/$applet".tests |
132 | if [ $? -ne 0 ]; then status=1; fi | 131 | then |
132 | : | ||
133 | else | ||
134 | status=1 | ||
135 | fi | ||
133 | fi | 136 | fi |
134 | 137 | ||
135 | done | 138 | done |
diff --git a/testsuite/testing.sh b/testsuite/testing.sh index e253e1aa6..7897c1622 100755 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh | |||
@@ -37,7 +37,7 @@ export SKIP= | |||
37 | 37 | ||
38 | # Helper functions | 38 | # Helper functions |
39 | 39 | ||
40 | optional() | 40 | optional () |
41 | { | 41 | { |
42 | option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"` | 42 | option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"` |
43 | # Not set? | 43 | # Not set? |
@@ -55,6 +55,7 @@ testing () | |||
55 | { | 55 | { |
56 | NAME="$1" | 56 | NAME="$1" |
57 | [ -z "$1" ] && NAME=$2 | 57 | [ -z "$1" ] && NAME=$2 |
58 | ret=0 | ||
58 | 59 | ||
59 | if [ $# -ne 5 ] | 60 | if [ $# -ne 5 ] |
60 | then | 61 | then |
@@ -76,12 +77,15 @@ testing () | |||
76 | echo -ne "$5" | eval "$2" > actual | 77 | echo -ne "$5" | eval "$2" > actual |
77 | RETVAL=$? | 78 | RETVAL=$? |
78 | 79 | ||
79 | cmp expected actual > /dev/null | 80 | cmp expected actual > /dev/null || ret=$? |
80 | if [ $? -ne 0 ] | 81 | if [ $ret -ne 0 ] |
81 | then | 82 | then |
82 | FAILCOUNT=$[$FAILCOUNT+1] | 83 | FAILCOUNT=$[$FAILCOUNT+1] |
83 | echo "FAIL: $NAME" | 84 | echo "FAIL: $NAME" |
84 | [ -n "$VERBOSE" ] && diff -u expected actual | 85 | if [ -n "$VERBOSE" ] |
86 | then | ||
87 | diff -u expected actual || /bin/true | ||
88 | fi | ||
85 | else | 89 | else |
86 | echo "PASS: $NAME" | 90 | echo "PASS: $NAME" |
87 | fi | 91 | fi |
@@ -97,7 +101,7 @@ testing () | |||
97 | # the file is assumed to already be there and only its library dependencies | 101 | # the file is assumed to already be there and only its library dependencies |
98 | # are copied. | 102 | # are copied. |
99 | 103 | ||
100 | function mkchroot | 104 | mkchroot () |
101 | { | 105 | { |
102 | [ $# -lt 2 ] && return | 106 | [ $# -lt 2 ] && return |
103 | 107 | ||
@@ -126,7 +130,7 @@ function mkchroot | |||
126 | # Needed commands listed on command line | 130 | # Needed commands listed on command line |
127 | # Script fed to stdin. | 131 | # Script fed to stdin. |
128 | 132 | ||
129 | function dochroot | 133 | dochroot () |
130 | { | 134 | { |
131 | mkdir tmpdir4chroot | 135 | mkdir tmpdir4chroot |
132 | mount -t ramfs tmpdir4chroot tmpdir4chroot | 136 | mount -t ramfs tmpdir4chroot tmpdir4chroot |