123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- #!/bin/sh
- . ./testing.sh
- total_failed=0
- run_applet_testcase()
- {
- applet="$1"
- testcase="$2"
- status=0
- uc_applet=$(echo "$applet" | tr a-z A-Z)
- testname="$testcase"
- testname="${testname##*/}"
- if grep "^# CONFIG_$uc_applet is not set$" "$bindir/.config" >/dev/null; then
- echo "UNTESTED: $testname"
- return 0
- fi
- if grep "^# FEATURE: " "$testcase" >/dev/null; then
- local feature=$(sed -ne 's/^# FEATURE: //p' "$testcase")
- for f in $feature; do
- if grep "^# $f is not set$" "$bindir/.config" >/dev/null; then
- echo "UNTESTED: $testname"
- return 0
- fi
- done
- fi
- rm -rf ".tmpdir.$applet"
- mkdir -p ".tmpdir.$applet"
- cd ".tmpdir.$applet" || return 1
- d="$tsdir" \
- sh -x -e "$testcase" >"$testname.stdout.txt" 2>&1 || status=$?
- if [ $status -ne 0 ]; then
- echo "FAIL: $testname"
- if [ x"$VERBOSE" != x ]; then
- cat "$testname.stdout.txt"
- fi
- else
- echo "PASS: $testname"
- fi
- cd ..
- rm -rf ".tmpdir.$applet"
- return $status
- }
- run_oldstyle_applet_tests()
- {
- local applet="$1"
- local status=0
- for testcase in "$tsdir/$applet"/*; do
-
- case "${testcase##*/}" in
- .*) continue ;;
- *~) continue ;;
- "CVS") continue ;;
- \
- *.mine) continue ;;
- *.r[0-9]*) continue ;;
- esac
- run_applet_testcase "$applet" "$testcase" || {
- status=1
- total_failed=$((total_failed + 1))
- }
- done
- return $status
- }
- lcwd=$(pwd)
- [ x"$tsdir" != x"" ] || tsdir="$lcwd"
- [ x"$bindir" != x"" ] || bindir="${lcwd%/*}"
- PATH="$bindir:$PATH"
- export bindir
- if [ x"$VERBOSE" = x ]; then
- export VERBOSE=
- fi
- if [ x"$1" = x"-v" ]; then
- export VERBOSE=1
- shift
- fi
- implemented=$(
- printf "busybox "
- "$bindir/busybox" 2>&1 |
- while read line; do
- if [ x"$line" = x"Currently defined functions:" ]; then
- xargs | sed 's/,//g'
- break
- fi
- done
- )
- applets="$implemented"
- if [ $# -ne 0 ]; then
- applets="$@"
- fi
- LINKSDIR="$bindir/runtest-tempdir-links"
- rm -rf "$LINKSDIR" 2>/dev/null
- mkdir "$LINKSDIR" 2>/dev/null
- for i in $implemented; do
-
-
-
- ln -s "$bindir/busybox" "$LINKSDIR/$i" 2>/dev/null
- done
- export OPTIONFLAGS=:$(
- sed -nr 's/^CONFIG_//p' "$bindir/.config" |
- sed 's/=.*//' | xargs | sed 's/ /:/g'
- ):
- status=0
- for applet in $applets; do
-
- if [ -d "$tsdir/$applet" ]; then
- run_oldstyle_applet_tests "$applet" || status=1
- fi
-
- if [ -f "$applet.tests" ]; then
- if [ ! -e "$LINKSDIR/$applet" ]; then
-
- if ! echo "$applet" | grep "^all_" >/dev/null; then
- echo "SKIPPED: $applet (not built)"
- continue
- fi
- fi
- PATH="$LINKSDIR:$tsdir:$bindir:$PATH" \
- "$tsdir/$applet.tests"
- rc=$?
- total_failed=$((total_failed + rc))
- test $rc -ne 0 && status=1
- fi
- done
- if [ $status -ne 0 ] && [ x"$VERBOSE" = x ]; then
- echo "$total_failed failure(s) detected; running with -v (verbose) will give more info"
- fi
- exit $status
|