Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 3 | TOPDIR=`pwd` |
Denis Vlasenko | 66d56c5 | 2008-06-05 09:07:02 +0000 | [diff] [blame] | 4 | |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 5 | test -x ash || { |
Denis Vlasenko | 5a86731 | 2008-07-24 19:46:38 +0000 | [diff] [blame] | 6 | echo "No ./ash - creating a link to ../../busybox" |
| 7 | ln -s ../../busybox ash |
Denis Vlasenko | 81887e2 | 2008-02-13 18:09:56 +0000 | [diff] [blame] | 8 | } |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 9 | test -x printenv || gcc -O2 -o printenv printenv.c || exit $? |
| 10 | test -x recho || gcc -O2 -o recho recho.c || exit $? |
| 11 | test -x zecho || gcc -O2 -o zecho zecho.c || exit $? |
| 12 | |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 13 | PATH="`pwd`:$PATH" # for ash and recho/zecho/printenv |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 14 | export PATH |
| 15 | |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 16 | THIS_SH="`pwd`/ash" |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 17 | export THIS_SH |
| 18 | |
| 19 | do_test() |
| 20 | { |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 21 | test -d "$1" || return 0 |
| 22 | d=${d%/} |
| 23 | # echo Running tests in directory "$1" |
| 24 | # $1 but with / replaced by # so that it can be used as filename part |
| 25 | noslash=`echo "$1" | sed 's:/:#:g'` |
| 26 | ( |
| 27 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
| 28 | for x in run-*; do |
| 29 | test -f "$x" || continue |
| 30 | case "$x" in |
| 31 | "$0"|run-minimal|run-gprof) ;; |
| 32 | *.orig|*~) ;; |
| 33 | #*) echo $x ; sh $x ;; |
| 34 | *) |
| 35 | echo -n "$1/$x:" |
| 36 | sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \ |
| 37 | { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; } |
| 38 | ;; |
| 39 | esac |
| 40 | done |
| 41 | # Many bash run-XXX scripts just do this, |
| 42 | # no point in duplication it all over the place |
| 43 | for x in *.tests; do |
| 44 | test -x "$x" || continue |
| 45 | name="${x%%.tests}" |
| 46 | test -f "$name.right" || continue |
| 47 | # echo Running test: "$x" |
| 48 | echo -n "$1/$x:" |
| 49 | { |
| 50 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 |
| 51 | diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \ |
| 52 | && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail" |
| 53 | } && echo " ok" || echo " fail" |
| 54 | done |
| 55 | ) |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 56 | } |
| 57 | |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 58 | # Main part of this script |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 59 | # Usage: run-all [directories] |
| 60 | |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 61 | ret=0 |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 62 | |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 63 | if [ $# -lt 1 ]; then |
| 64 | # All sub directories |
| 65 | modules=`ls -d ash-*` |
| 66 | # If you want to test ash against hush testsuite |
| 67 | # (have to copy hush_test dir to current dir first): |
| 68 | #modules=`ls -d ash-* hush_test/hush-*` |
| 69 | |
| 70 | for module in $modules; do |
| 71 | do_test $module || ret=1 |
| 72 | done |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 73 | else |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 74 | while [ $# -ge 1 ]; do |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 75 | if [ -d $1 ]; then |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 76 | do_test $1 || ret=1 |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 77 | fi |
| 78 | shift |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 79 | done |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 80 | fi |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 81 | |
| 82 | exit ${ret} |