4 # runtest [applet1] [applet2...]
6 # Helper for helpers. Oh my...
7 test x
"$ECHO" != x
"" ||
{
9 test x
"`echo -ne`" = x
"" ||
{
10 # Compile and use a replacement 'echo' which understands -e -n
13 gcc
-Os -o "$ECHO" ..
/scripts
/echo.c ||
exit 1
19 # Run one old-style test.
20 # Tests are stored in applet/testcase shell scripts.
21 # They are run using "sh -x -e applet/testcase".
22 # Option -e will make testcase stop on the first failed command.
29 local uc_applet
=$
(echo "$applet" |
tr a-z A-Z
)
30 local testname
="$testcase"
32 testname
="${testname##*/}" # take basename
33 if grep "^# CONFIG_$uc_applet is not set$" "$bindir/.config" >/dev
/null
; then
34 echo "UNTESTED: $testname"
38 if grep "^# FEATURE: " "$testcase" >/dev
/null
; then
39 local feature
=$
(sed -ne 's/^# FEATURE: //p' "$testcase")
41 if grep "^# $feature is not set$" "$bindir/.config" >/dev
/null
; then
42 echo "UNTESTED: $testname"
47 rm -rf ".tmpdir.$applet"
48 mkdir
-p ".tmpdir.$applet"
49 cd ".tmpdir.$applet" ||
return 1
51 # echo "Running testcase $testcase"
53 sh
-x -e "$testcase" >"$testname.stdout.txt" 2>&1 || status
=$?
54 if [ $status -ne 0 ]; then
55 echo "FAIL: $testname"
56 if [ x
"$VERBOSE" != x
]; then
57 cat "$testname.stdout.txt"
60 echo "PASS: $testname"
64 rm -rf ".tmpdir.$applet"
69 # Run all old-style tests for given applet
70 run_oldstyle_applet_tests
()
75 for testcase
in "$tsdir/$applet"/*; do
76 # switch on basename of $testcase
77 case "${testcase##*/}" in
78 .
*) continue ;; # .svn, .git etc
79 *~
) continue ;; # backup files
81 \
#*) continue ;; # CVS merge residues
82 *.mine
) continue ;; # svn-produced junk
83 *.r
[0-9]*) continue ;; # svn-produced junk
85 run_applet_testcase
"$applet" "$testcase" || status
=1
93 [ x
"$tsdir" != x
] || tsdir
="$lcwd"
94 [ x
"$bindir" != x
] || bindir
="${lcwd%/*}" # one directory up from $lcwd
97 if [ x
"$VERBOSE" = x
]; then
101 if [ x
"$1" = x
"-v" ]; then
107 "$bindir/busybox" 2>&1 |
109 if [ x
"$line" = x
"Currently defined functions:" ]; then
116 applets
="$implemented"
117 if [ $# -ne 0 ]; then
121 # Populate a directory with links to all busybox applets
123 LINKSDIR
="$bindir/runtest-tempdir-links"
124 rm -rf "$LINKSDIR" 2>/dev
/null
126 for i
in $implemented; do
127 ln -s "$bindir/busybox" "$LINKSDIR/$i"
130 # Set up option flags so tests can be selective.
131 export OPTIONFLAGS
=:$
(
132 sed -nr 's/^CONFIG_//p' "$bindir/.config" |
133 sed 's/=.*//' |
xargs |
sed 's/ /:/g'
137 for applet
in $applets; do
138 # Any old-style tests for this applet?
139 if [ -d "$tsdir/$applet" ]; then
140 run_oldstyle_applet_tests
"$applet" || status
=1
143 # Is this a new-style test?
144 if [ -f "$applet.tests" ]; then
145 if [ ! -h "$LINKSDIR/$applet" ]; then
146 # (avoiding bash'ism "${applet:0:4}")
147 if ! echo "$applet" |
grep "^all_" >/dev
/null
; then
148 echo "SKIPPED: $applet (not built)"
152 # echo "Running test $tsdir/$applet.tests"
153 PATH
="$LINKSDIR:$tsdir:$bindir:$PATH" \
154 "$tsdir/$applet.tests" || status
=1
158 # Leaving the dir makes it somewhat easier to run failed test by hand
161 if [ $status -ne 0 ] && [ x
"$VERBOSE" = x
]; then
162 echo "Failures detected, running with -v (verbose) will give more info"