4 # runtest [applet1] [applet2...]
6 # Run one old-style test.
7 # Tests are stored in applet/testcase shell scripts.
8 # They are run using "sh -x -e applet/testcase".
9 # Option -e will make testcase stop on the first failed command.
16 local uc_applet=$(echo $applet | tr a-z A-Z)
17 local testname=$(basename $testcase)
19 if grep -q "^# CONFIG_${uc_applet} is not set$" $bindir/.config; then
20 echo "UNTESTED: $testname"
24 if grep -q "^# FEATURE: " $testcase; then
25 local feature=`sed -ne 's/^# FEATURE: //p' $testcase`
27 if grep -q "^# ${feature} is not set$" $bindir/.config; then
28 echo "UNTESTED: $testname"
33 rm -rf ".tmpdir.$applet"
34 mkdir -p ".tmpdir.$applet"
35 cd ".tmpdir.$applet" || return 1
37 # echo "Running testcase $testcase"
38 d="$tsdir" sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1
40 if [ $status != 0 ]; then
41 echo "FAIL: $testname"
42 if [ x"$VERBOSE" != x ]; then
43 cat "$testname.stdout.txt"
46 echo "PASS: $testname"
50 rm -rf ".tmpdir.$applet"
55 # Run all old-style tests for given applet
60 for testcase in $tsdir/$applet/*; do
61 if [ "$testcase" = "$tsdir/$applet/CVS" ]; then
64 run_applet_testcase $applet $testcase
65 test $? = 0 || status=1
72 [ -n "$tsdir" ] || tsdir=$(pwd)
73 [ -n "$bindir" ] || bindir=$(dirname $(pwd))
76 if [ x"$VERBOSE" = x ]; then
80 if [ x"$1" = x"-v" ]; then
86 $bindir/busybox 2>&1 |
88 if [ x"$line" = x"Currently defined functions:" ]; then
95 applets="$implemented"
100 # Populate a directory with links to all busybox applets
102 LINKSDIR="$bindir/runtest-tempdir-links"
103 rm -rf "$LINKSDIR" 2>/dev/null
105 for i in $implemented; do
106 ln -s $bindir/busybox "$LINKSDIR"/$i
109 # Set up option flags so tests can be selective.
110 export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_//p' $bindir/.config | sed 's/=.*//' | xargs | sed 's/ /:/g')
113 for applet in $applets; do
114 if [ "$applet" = "links" ]; then continue; fi
116 # Any old-style tests for this applet?
117 if [ "$applet" != "CVS" -a -d "$tsdir/$applet" ]; then
118 run_applet_tests "$applet"
119 test $? = 0 || status=1
122 # Is this a new-style test?
123 if [ -f "${applet}.tests" ]; then
124 if [ ! -h "$LINKSDIR/$applet" ] && [ "${applet:0:4}" != "all_" ]; then
125 echo "SKIPPED: $applet (not built)"
128 # echo "Running test ${tsdir:-.}/${applet}.tests"
129 PATH="$LINKSDIR:$tsdir:$bindir:$PATH" "${tsdir:-.}/${applet}.tests"
130 test $? = 0 || status=1
134 # Leaving the dir makes it somewhat easier to run failed test by hand
137 if [ $status != 0 -a x"$VERBOSE" = x ]; then
138 echo "Failures detected, running with -v (verbose) will give more info"