diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-02 21:46:30 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-02 21:46:30 +0000 |
commit | 687a26fe0dcf10f227cb0541882d1daa8a21991d (patch) | |
tree | 2bc145dfd405a157cc1448d9f5889373ef773a67 /testsuite/testing.sh | |
parent | 4e79049e109a9651b462c5dcf9559f9fef2b0cc8 (diff) | |
download | busybox-w32-687a26fe0dcf10f227cb0541882d1daa8a21991d.tar.gz busybox-w32-687a26fe0dcf10f227cb0541882d1daa8a21991d.tar.bz2 busybox-w32-687a26fe0dcf10f227cb0541882d1daa8a21991d.zip |
more fixes to testsuite by Cristian and vda
Diffstat (limited to 'testsuite/testing.sh')
-rwxr-xr-x | testsuite/testing.sh | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/testsuite/testing.sh b/testsuite/testing.sh index e9338dbc1..028d09a28 100755 --- a/testsuite/testing.sh +++ b/testsuite/testing.sh | |||
@@ -4,28 +4,29 @@ | |||
4 | # | 4 | # |
5 | # License is GPLv2, see LICENSE in the busybox tarball for full license text. | 5 | # License is GPLv2, see LICENSE in the busybox tarball for full license text. |
6 | 6 | ||
7 | # This file defines two functions, "testing" and "optionflag" | 7 | # This file defines two functions, "testing" and "optional" |
8 | # and a couple more... | ||
8 | 9 | ||
9 | # The following environment variables may be set to enable optional behavior | 10 | # The following environment variables may be set to enable optional behavior |
10 | # in "testing": | 11 | # in "testing": |
11 | # VERBOSE - Print the diff -u of each failed test case. | 12 | # VERBOSE - Print the diff -u of each failed test case. |
12 | # DEBUG - Enable command tracing. | 13 | # DEBUG - Enable command tracing. |
13 | # SKIP - do not perform this test (this is set by "optionflag") | 14 | # SKIP - do not perform this test (this is set by "optional") |
14 | # | 15 | # |
15 | # The "testing" function takes five arguments: | 16 | # The "testing" function takes five arguments: |
16 | # $1) Description to display when running command | 17 | # $1) Test description |
17 | # $2) Command line arguments to command | 18 | # $2) Command(s) to run. May have pipes, redirects, etc |
18 | # $3) Expected result (on stdout) | 19 | # $3) Expected result on stdout |
19 | # $4) Data written to file "input" | 20 | # $4) Data to be written to file "input" |
20 | # $5) Data written to stdin | 21 | # $5) Data to be written to stdin |
21 | # | 22 | # |
22 | # The exit value of testing is the exit value of the command it ran. | 23 | # The exit value of testing is the exit value of $2 it ran. |
23 | # | 24 | # |
24 | # The environment variable "FAILCOUNT" contains a cumulative total of the | 25 | # The environment variable "FAILCOUNT" contains a cumulative total of the |
25 | # number of failed tests. | 26 | # number of failed tests. |
26 | 27 | ||
27 | # The "optional" function is used to skip certain tests, ala: | 28 | # The "optional" function is used to skip certain tests, ala: |
28 | # optionflag CONFIG_FEATURE_THINGY | 29 | # optional CONFIG_FEATURE_THINGY |
29 | # | 30 | # |
30 | # The "optional" function checks the environment variable "OPTIONFLAGS", | 31 | # The "optional" function checks the environment variable "OPTIONFLAGS", |
31 | # which is either empty (in which case it always clears SKIP) or | 32 | # which is either empty (in which case it always clears SKIP) or |
@@ -35,15 +36,28 @@ | |||
35 | export FAILCOUNT=0 | 36 | export FAILCOUNT=0 |
36 | export SKIP= | 37 | export SKIP= |
37 | 38 | ||
39 | # Helper for helpers. Oh my... | ||
40 | test x"$ECHO" = x"" && { | ||
41 | ECHO="echo" | ||
42 | test x"`echo -ne`" = x"" || { | ||
43 | # Compile and use a replacement 'echo' which understands -e -n | ||
44 | ECHO="$PWD/echo-ne" | ||
45 | test -x "$ECHO" || { | ||
46 | gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1 | ||
47 | } | ||
48 | } | ||
49 | export ECHO | ||
50 | } | ||
51 | |||
38 | # Helper functions | 52 | # Helper functions |
39 | 53 | ||
40 | optional() | 54 | optional() |
41 | { | 55 | { |
42 | option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"` | 56 | option=`echo ":$OPTIONFLAGS:" | grep ":$1:"` |
43 | # Not set? | 57 | # Not set? |
44 | if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] | 58 | if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] |
45 | then | 59 | then |
46 | SKIP="" | 60 | SKIP= |
47 | return | 61 | return |
48 | fi | 62 | fi |
49 | SKIP=1 | 63 | SKIP=1 |
@@ -54,7 +68,7 @@ optional() | |||
54 | testing() | 68 | testing() |
55 | { | 69 | { |
56 | NAME="$1" | 70 | NAME="$1" |
57 | [ -z "$1" ] && NAME=$2 | 71 | [ -z "$1" ] && NAME="$2" |
58 | 72 | ||
59 | if [ $# -ne 5 ] | 73 | if [ $# -ne 5 ] |
60 | then | 74 | then |
@@ -70,10 +84,10 @@ testing() | |||
70 | return 0 | 84 | return 0 |
71 | fi | 85 | fi |
72 | 86 | ||
73 | echo -ne "$3" > expected | 87 | $ECHO -ne "$3" > expected |
74 | echo -ne "$4" > input | 88 | $ECHO -ne "$4" > input |
75 | [ -z "$VERBOSE" ] || echo "echo '$5' | $2" | 89 | [ -z "$VERBOSE" ] || echo "echo '$5' | $2" |
76 | echo -ne "$5" | eval "$2" > actual | 90 | $ECHO -ne "$5" | eval "$2" > actual |
77 | RETVAL=$? | 91 | RETVAL=$? |
78 | 92 | ||
79 | cmp expected actual >/dev/null 2>/dev/null | 93 | cmp expected actual >/dev/null 2>/dev/null |
@@ -101,7 +115,7 @@ mkchroot() | |||
101 | { | 115 | { |
102 | [ $# -lt 2 ] && return | 116 | [ $# -lt 2 ] && return |
103 | 117 | ||
104 | echo -n . | 118 | $ECHO -n . |
105 | 119 | ||
106 | dest=$1 | 120 | dest=$1 |
107 | shift | 121 | shift |
@@ -136,7 +150,7 @@ dochroot() | |||
136 | 150 | ||
137 | # Copy utilities from command line arguments | 151 | # Copy utilities from command line arguments |
138 | 152 | ||
139 | echo -n "Setup chroot" | 153 | $ECHO -n "Setup chroot" |
140 | mkchroot tmpdir4chroot $* | 154 | mkchroot tmpdir4chroot $* |
141 | echo | 155 | echo |
142 | 156 | ||
@@ -152,4 +166,3 @@ dochroot() | |||
152 | umount -l tmpdir4chroot | 166 | umount -l tmpdir4chroot |
153 | rmdir tmpdir4chroot | 167 | rmdir tmpdir4chroot |
154 | } | 168 | } |
155 | |||