Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denis Vlasenko | 30c9cc5 | 2008-06-17 07:24:29 +0000 | [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 | |
Denis Vlasenko | 05743d7 | 2008-02-10 12:10:08 +0000 | [diff] [blame] | 12 | test -x hush || { |
Denis Vlasenko | a844200 | 2008-06-14 11:00:17 +0000 | [diff] [blame] | 13 | echo "No ./hush - creating a link to ../../busybox" |
| 14 | ln -s ../../busybox hush |
Denis Vlasenko | 05743d7 | 2008-02-10 12:10:08 +0000 | [diff] [blame] | 15 | } |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 16 | if test -e ../../.config ; then |
| 17 | eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' ../../.config) |
| 18 | fi |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 19 | |
| 20 | PATH="$PWD:$PATH" # for hush and recho/zecho/printenv |
| 21 | export PATH |
| 22 | |
| 23 | THIS_SH="$PWD/hush" |
| 24 | export THIS_SH |
| 25 | |
| 26 | do_test() |
| 27 | { |
| 28 | test -d "$1" || return 0 |
Mike Frysinger | a36258f | 2009-04-02 22:46:52 +0000 | [diff] [blame] | 29 | d=${d%/} |
Denis Vlasenko | cccdc4e | 2007-11-23 21:08:38 +0000 | [diff] [blame] | 30 | # echo Running tests in directory "$1" |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 31 | ( |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 32 | tret=0 |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 33 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
| 34 | for x in run-*; do |
| 35 | test -f "$x" || continue |
| 36 | case "$x" in |
| 37 | "$0"|run-minimal|run-gprof) ;; |
| 38 | *.orig|*~) ;; |
| 39 | #*) echo $x ; sh $x ;; |
| 40 | *) |
| 41 | sh "$x" >"../$1-$x.fail" 2>&1 && \ |
| 42 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; |
| 43 | ;; |
| 44 | esac |
| 45 | done |
| 46 | # Many bash run-XXX scripts just do this, |
| 47 | # no point in duplication it all over the place |
| 48 | for x in *.tests; do |
| 49 | test -x "$x" || continue |
| 50 | name="${x%%.tests}" |
| 51 | test -f "$name.right" || continue |
Denis Vlasenko | cd418a2 | 2009-04-06 18:08:35 +0000 | [diff] [blame] | 52 | # echo Running test: "$x" |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 53 | ( |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 54 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 55 | test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77 |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 56 | diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 57 | ) |
| 58 | case $? in |
| 59 | 0) echo "$1/$x: ok";; |
| 60 | 77) echo "$1/$x: skip (feature disabled)";; |
| 61 | *) echo "$1/$x: fail"; tret=1;; |
| 62 | esac |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 63 | done |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 64 | exit ${tret} |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 65 | ) |
| 66 | } |
| 67 | |
| 68 | # Main part of this script |
| 69 | # Usage: run-all [directories] |
| 70 | |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 71 | ret=0 |
| 72 | |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 73 | if [ $# -lt 1 ]; then |
| 74 | # All sub directories |
| 75 | modules=`ls -d hush-*` |
| 76 | |
| 77 | for module in $modules; do |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 78 | do_test $module || ret=1 |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 79 | done |
| 80 | else |
| 81 | while [ $# -ge 1 ]; do |
| 82 | if [ -d $1 ]; then |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 83 | do_test $1 || ret=1 |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 84 | fi |
| 85 | shift |
| 86 | done |
| 87 | fi |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 88 | |
| 89 | exit ${ret} |