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