diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-02 01:44:42 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-12-02 01:44:42 +0000 |
commit | e2532ab5f2446ec736b10b24f57a36456deb197f (patch) | |
tree | 8d982e42b7e48d9c6949fddd312b08a36dedbcba /testsuite | |
parent | 1796e2c49507e701e18b09281478cc33131dbbd8 (diff) | |
download | busybox-w32-e2532ab5f2446ec736b10b24f57a36456deb197f.tar.gz busybox-w32-e2532ab5f2446ec736b10b24f57a36456deb197f.tar.bz2 busybox-w32-e2532ab5f2446ec736b10b24f57a36456deb197f.zip |
dd: fix a bug where we don't report write errors
testsuite: small cleanup
full_write_or_warn 38 40 +2
write_and_stats 66 67 +1
dd_main 1358 1335 -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 3/-23) Total: -20 bytes
Diffstat (limited to 'testsuite')
-rwxr-xr-x | testsuite/runtest | 92 |
1 files changed, 41 insertions, 51 deletions
diff --git a/testsuite/runtest b/testsuite/runtest index 92cbfdf4e..93d5ed6e1 100755 --- a/testsuite/runtest +++ b/testsuite/runtest | |||
@@ -1,20 +1,20 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | # Run old-style test. | 3 | # Run one old-style test. |
4 | 4 | # Tests are stored in applet/testcase shell scripts. | |
5 | # They are run using "sh -x -e applet/testcase". | ||
6 | # Option -e will make testcase stop on the first failed command. | ||
5 | run_applet_testcase() | 7 | run_applet_testcase() |
6 | { | 8 | { |
7 | local applet=$1 | 9 | local applet=$1 |
8 | local testcase=$2 | 10 | local testcase=$2 |
9 | 11 | ||
10 | local status=0 | 12 | local status |
11 | local RES= | ||
12 | |||
13 | local uc_applet=$(echo $applet | tr a-z A-Z) | 13 | local uc_applet=$(echo $applet | tr a-z A-Z) |
14 | local testname=$(basename $testcase) | 14 | local testname=$(basename $testcase) |
15 | 15 | ||
16 | if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then | 16 | if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then |
17 | echo UNTESTED: $testname | 17 | echo "UNTESTED: $testname" |
18 | return 0 | 18 | return 0 |
19 | fi | 19 | fi |
20 | 20 | ||
@@ -22,72 +22,67 @@ run_applet_testcase() | |||
22 | local feature=`sed -ne 's/^# FEATURE: //p' $testcase` | 22 | local feature=`sed -ne 's/^# FEATURE: //p' $testcase` |
23 | 23 | ||
24 | if grep -q "^# ${feature} is not set$" $bindir/.config; then | 24 | if grep -q "^# ${feature} is not set$" $bindir/.config; then |
25 | echo UNTESTED: $testname | 25 | echo "UNTESTED: $testname" |
26 | return 0 | 26 | return 0 |
27 | fi | 27 | fi |
28 | fi | 28 | fi |
29 | 29 | ||
30 | rm -rf tmp | 30 | rm -rf ".tmpdir.$applet" |
31 | mkdir -p tmp | 31 | mkdir -p ".tmpdir.$applet" |
32 | pushd tmp > /dev/null | 32 | cd ".tmpdir.$applet" || return 1 |
33 | 33 | ||
34 | # echo Running testcase $testcase | 34 | # echo "Running testcase $testcase" |
35 | d=$tsdir sh -x -e $testcase >.logfile.txt 2>&1 || status=$? | 35 | d="$tsdir" sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1 |
36 | 36 | status=$? | |
37 | if [ $status -ne 0 ]; then | 37 | if [ $status != 0 ]; then |
38 | echo FAIL: $testname | 38 | echo "FAIL: $testname" |
39 | if [ $verbose -gt 0 ]; then | 39 | if [ x"$VERBOSE" != x ]; then |
40 | cat .logfile.txt | 40 | cat "$testname.stdout.txt" |
41 | fi | 41 | fi |
42 | status=$? | ||
43 | else | 42 | else |
44 | echo PASS: $testname | 43 | echo "PASS: $testname" |
45 | rm -f .logfile.txt | ||
46 | status=$? | ||
47 | fi | 44 | fi |
48 | 45 | ||
49 | popd > /dev/null | 46 | cd .. |
50 | rm -rf tmp | 47 | rm -rf ".tmpdir.$applet" |
51 | 48 | ||
52 | return $status | 49 | return $status |
53 | } | 50 | } |
54 | 51 | ||
52 | # Run all old-style tests for given applet | ||
55 | run_applet_tests() | 53 | run_applet_tests() |
56 | { | 54 | { |
57 | local applet=$1 | 55 | local applet=$1 |
58 | |||
59 | local status=0 | 56 | local status=0 |
60 | |||
61 | for testcase in $tsdir/$applet/*; do | 57 | for testcase in $tsdir/$applet/*; do |
62 | if [ "$testcase" = "$tsdir/$applet/CVS" ]; then | 58 | if [ "$testcase" = "$tsdir/$applet/CVS" ]; then |
63 | continue | 59 | continue |
64 | fi | 60 | fi |
65 | if ! run_applet_testcase $applet $testcase; then | 61 | run_applet_testcase $applet $testcase |
66 | status=1 | 62 | test $? = 0 || status=1 |
67 | fi | ||
68 | done | 63 | done |
69 | |||
70 | return $status | 64 | return $status |
71 | } | 65 | } |
72 | 66 | ||
73 | 67 | ||
74 | status=0 | ||
75 | verbose=0 | ||
76 | 68 | ||
77 | [ -n "$tsdir" ] || tsdir=$(pwd) | 69 | [ -n "$tsdir" ] || tsdir=$(pwd) |
78 | [ -n "$bindir" ] || bindir=$(dirname $(pwd)) | 70 | [ -n "$bindir" ] || bindir=$(dirname $(pwd)) |
79 | PATH="$bindir:$PATH" | 71 | PATH="$bindir:$PATH" |
80 | 72 | ||
73 | if [ x"$VERBOSE" = x ]; then | ||
74 | export VERBOSE= | ||
75 | fi | ||
76 | |||
81 | if [ x"$1" = x"-v" ]; then | 77 | if [ x"$1" = x"-v" ]; then |
82 | verbose=1 | 78 | export VERBOSE=1 |
83 | export VERBOSE=$verbose | ||
84 | shift | 79 | shift |
85 | fi | 80 | fi |
86 | 81 | ||
87 | implemented=$( | 82 | implemented=$( |
88 | $bindir/busybox 2>&1 | | 83 | $bindir/busybox 2>&1 | |
89 | while read line; do | 84 | while read line; do |
90 | if test x"$line" = x"Currently defined functions:"; then | 85 | if [ x"$line" = x"Currently defined functions:" ]; then |
91 | xargs | sed 's/,//g' | 86 | xargs | sed 's/,//g' |
92 | break | 87 | break |
93 | fi | 88 | fi |
@@ -109,39 +104,34 @@ for i in $implemented; do | |||
109 | done | 104 | done |
110 | 105 | ||
111 | # Set up option flags so tests can be selective. | 106 | # Set up option flags so tests can be selective. |
107 | export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_//p' $bindir/.config | sed 's/=.*//' | xargs | sed 's/ /:/g') | ||
112 | 108 | ||
113 | configfile=${bindir}/.config | 109 | status=0 |
114 | export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_(.*)=.*/\1/p' $configfile | xargs | sed 's/ /:/g') | ||
115 | |||
116 | for applet in $applets; do | 110 | for applet in $applets; do |
117 | if [ "$applet" = "links" ]; then continue; fi | 111 | if [ "$applet" = "links" ]; then continue; fi |
112 | |||
113 | # Any old-style tests for this applet? | ||
118 | if [ "$applet" != "CVS" -a -d "$tsdir/$applet" ]; then | 114 | if [ "$applet" != "CVS" -a -d "$tsdir/$applet" ]; then |
119 | if ! run_applet_tests $applet; then | 115 | run_applet_tests "$applet" |
120 | status=1 | 116 | test $? = 0 || status=1 |
121 | fi | ||
122 | fi | 117 | fi |
123 | 118 | ||
124 | # Is this a new-style test? | 119 | # Is this a new-style test? |
125 | if [ -f ${applet}.tests ]; then | 120 | if [ -f "${applet}.tests" ]; then |
126 | if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ]; then | 121 | if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ]; then |
127 | echo "SKIPPED: $applet (not built)" | 122 | echo "SKIPPED: $applet (not built)" |
128 | continue | 123 | continue |
129 | fi | 124 | fi |
130 | if PATH="$LINKSDIR:$tsdir:$bindir:$PATH" \ | 125 | # echo "Running test ${tsdir:-.}/${applet}.tests" |
131 | "${tsdir:-.}/$applet".tests | 126 | PATH="$LINKSDIR:$tsdir:$bindir:$PATH" "${tsdir:-.}/${applet}.tests" |
132 | then | 127 | test $? = 0 || status=1 |
133 | : | ||
134 | else | ||
135 | status=1 | ||
136 | fi | ||
137 | fi | 128 | fi |
138 | |||
139 | done | 129 | done |
140 | 130 | ||
141 | # Leaving the dir makes it somewhat easier to run failed test by hand | 131 | # Leaving the dir makes it somewhat easier to run failed test by hand |
142 | #rm -rf "$LINKSDIR" | 132 | #rm -rf "$LINKSDIR" |
143 | 133 | ||
144 | if [ $status != 0 -a x"$VERBOSE" = x ]; then | 134 | if [ $status != 0 -a x"$VERBOSE" = x ]; then |
145 | echo "Failures detected, running with VERBOSE=1 will give more info" | 135 | echo "Failures detected, running with -v (verbose) will give more info" |
146 | fi | 136 | fi |
147 | exit $status | 137 | exit $status |