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