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