Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test -x ash || { echo "No ./ash?!"; exit; } |
| 4 | test -x printenv || gcc -O2 -o printenv printenv.c || exit $? |
| 5 | test -x recho || gcc -O2 -o recho recho.c || exit $? |
| 6 | test -x zecho || gcc -O2 -o zecho zecho.c || exit $? |
| 7 | |
| 8 | PATH="$PWD:$PATH" # for ash and recho/zecho/printenv |
| 9 | export PATH |
| 10 | |
| 11 | THIS_SH="$PWD/ash" |
| 12 | export THIS_SH |
| 13 | |
| 14 | do_test() |
| 15 | { |
| 16 | test -d "$1" || return 0 |
| 17 | ( |
| 18 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
| 19 | for x in run-*; do |
| 20 | test -f "$x" || continue |
Denis Vlasenko | c86e052 | 2007-03-20 11:30:28 +0000 | [diff] [blame^] | 21 | case "$x" in |
Denis Vlasenko | 1c660b4 | 2007-03-05 00:27:50 +0000 | [diff] [blame] | 22 | "$0"|run-minimal|run-gprof) ;; |
| 23 | *.orig|*~) ;; |
| 24 | #*) echo $x ; sh $x ;; |
| 25 | *) |
| 26 | sh "$x" >"../$1-$x.fail" 2>&1 && \ |
| 27 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; |
| 28 | ;; |
| 29 | esac |
| 30 | done |
| 31 | # Many bash run-XXX scripts just do this, |
| 32 | # no point in duplication it all over the place |
| 33 | for x in *.tests; do |
| 34 | test -x "$x" || continue |
| 35 | name="${x%%.tests}" |
| 36 | test -f "$name.right" || continue |
| 37 | { |
| 38 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 |
| 39 | diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" |
| 40 | } && echo "$1/$x: ok" || echo "$1/$x: fail" |
| 41 | done |
| 42 | ) |
| 43 | } |
| 44 | |
| 45 | # main part of this script |
| 46 | # Usage: run-all [directories] |
| 47 | |
| 48 | if [ $# -lt 1 ]; then |
| 49 | # All sub directories |
| 50 | modules=`ls -d ash-*` |
| 51 | |
| 52 | for module in $modules; do |
| 53 | do_test $module |
| 54 | done |
| 55 | else |
| 56 | while [ $# -ge 1 ]; do |
| 57 | if [ -d $1 ]; then |
| 58 | do_test $1 |
| 59 | fi |
| 60 | shift |
| 61 | done |
| 62 | fi |