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 | |
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')
-rwxr-xr-x | testsuite/cpio.tests | 14 | ||||
-rwxr-xr-x | testsuite/testing.sh | 49 |
2 files changed, 43 insertions, 20 deletions
diff --git a/testsuite/cpio.tests b/testsuite/cpio.tests index 408a3fbcf..d42e5145f 100755 --- a/testsuite/cpio.tests +++ b/testsuite/cpio.tests | |||
@@ -4,6 +4,13 @@ | |||
4 | 4 | ||
5 | . testing.sh | 5 | . testing.sh |
6 | 6 | ||
7 | # check if hexdump supports the '-R' option | ||
8 | hexdump -R </dev/null >/dev/null 2>&1 || { | ||
9 | echo "'hexdump -R' is not available" >&2 | ||
10 | SKIP=1 | ||
11 | exit 1 | ||
12 | } | ||
13 | |||
7 | # ls -ln is showing date. Need to remove that, it's variable | 14 | # ls -ln is showing date. Need to remove that, it's variable |
8 | # sed: coalesce spaces | 15 | # sed: coalesce spaces |
9 | # cut: remove date | 16 | # cut: remove date |
@@ -24,6 +31,9 @@ hexdump="\ | |||
24 | 00000090 14 24 19 07 a4 63 00 | 31 | 00000090 14 24 19 07 a4 63 00 |
25 | " | 32 | " |
26 | 33 | ||
34 | user=$(id -u) | ||
35 | group=$(id -g) | ||
36 | |||
27 | rm -rf cpio.testdir | 37 | rm -rf cpio.testdir |
28 | 38 | ||
29 | # testing "test name" "options" "expected result" "file input" "stdin" | 39 | # testing "test name" "options" "expected result" "file input" "stdin" |
@@ -34,8 +44,8 @@ testing "cpio extracts zero-sized hardlinks" \ | |||
34 | "\ | 44 | "\ |
35 | 1 blocks | 45 | 1 blocks |
36 | 0 | 46 | 0 |
37 | -rw-r--r-- 2 0 0 0 x | 47 | -rw-r--r-- 2 $user $group 0 x |
38 | -rw-r--r-- 2 0 0 0 y | 48 | -rw-r--r-- 2 $user $group 0 y |
39 | " \ | 49 | " \ |
40 | "" "" | 50 | "" "" |
41 | 51 | ||
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 | |||