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