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="$testcase"
19 testname="${testname##*/}" # take basename
20 if grep "^# CONFIG_$uc_applet is not set$" "$bindir/.config" >/dev/null; then
21 echo "UNTESTED: $testname"
25 if grep "^# FEATURE: " "$testcase" >/dev/null; then
26 local feature=$(sed -ne 's/^# FEATURE: //p' "$testcase")
28 if grep "^# $feature is not set$" "$bindir/.config" >/dev/null; then
29 echo "UNTESTED: $testname"
34 rm -rf ".tmpdir.$applet"
35 mkdir -p ".tmpdir.$applet"
36 cd ".tmpdir.$applet" || return 1
38 # echo "Running testcase $testcase"
39 d="$tsdir" sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1
41 if [ $status -ne 0 ]; then
42 echo "FAIL: $testname"
43 if [ x"$VERBOSE" != x ]; then
44 cat "$testname.stdout.txt"
47 echo "PASS: $testname"
51 rm -rf ".tmpdir.$applet"
56 # Run all old-style tests for given applet
62 for testcase in "$tsdir/$applet"/*; do
63 # switch on basename of $testcase
64 case "${testcase##*/}" in
72 if [ "$testcase" = "$tsdir/$applet/CVS" ] ||
73 [ "$testcase" = "$tsdir/$applet/.svn" ]; then
76 run_applet_testcase "$applet" "$testcase"
77 test $? -eq 0 || status=1
85 [ x"$tsdir" = x ] || tsdir="$lcwd"
86 [ x"$bindir" = x ] || bindir="${lcwd%/*}" # one directory up from $lcwd
89 if [ x"$VERBOSE" = x ]; then
93 if [ x"$1" = x"-v" ]; then
99 "$bindir/busybox" 2>&1 |
101 if [ x"$line" = x"Currently defined functions:" ]; then
108 applets="$implemented"
109 if [ $# -ne 0 ]; then
113 # Populate a directory with links to all busybox applets
115 LINKSDIR="$bindir/runtest-tempdir-links"
116 rm -rf "$LINKSDIR" 2>/dev/null
118 for i in $implemented; do
119 ln -s "$bindir/busybox" "$LINKSDIR/$i"
122 # Set up option flags so tests can be selective.
123 export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_//p' "$bindir/.config" | sed 's/=.*//' | xargs | sed 's/ /:/g')
126 for applet in $applets; do
127 if [ "$applet" = "links" ]; then
131 # Any old-style tests for this applet?
132 if [ "$applet" != "CVS" -a -d "$tsdir/$applet" ]; then
133 run_applet_tests "$applet"
134 test $? -eq 0 || status=1
137 # Is this a new-style test?
138 if [ -f "$applet.tests" ]; then
139 if [ ! -h "$LINKSDIR/$applet" ]; then
140 # (avoiding bash'ism "${applet:0:4}")
141 if ! echo "$applet" | grep "^all_" >/dev/null; then
142 echo "SKIPPED: $applet (not built)"
146 # echo "Running test ${tsdir:-.}/$applet.tests"
147 PATH="$LINKSDIR:$tsdir:$bindir:$PATH" "${tsdir:-.}/$applet.tests"
148 test $? -eq 0 || status=1
152 # Leaving the dir makes it somewhat easier to run failed test by hand
155 if [ $status -ne 0 -a x"$VERBOSE" = x ]; then
156 echo "Failures detected, running with -v (verbose) will give more info"