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 |
Denis Vlasenko | cccdc4e | 2007-11-23 21:08:38 +0000 | [diff] [blame] | 26 | # echo Running tests in directory "$1" |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 27 | ( |
| 28 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
| 29 | for x in run-*; do |
| 30 | test -f "$x" || continue |
| 31 | case "$x" in |
| 32 | "$0"|run-minimal|run-gprof) ;; |
| 33 | *.orig|*~) ;; |
| 34 | #*) echo $x ; sh $x ;; |
| 35 | *) |
| 36 | sh "$x" >"../$1-$x.fail" 2>&1 && \ |
| 37 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; |
| 38 | ;; |
| 39 | esac |
| 40 | done |
| 41 | # Many bash run-XXX scripts just do this, |
| 42 | # no point in duplication it all over the place |
| 43 | for x in *.tests; do |
| 44 | test -x "$x" || continue |
| 45 | name="${x%%.tests}" |
| 46 | test -f "$name.right" || continue |
Denis Vlasenko | f962a03 | 2007-11-23 12:50:54 +0000 | [diff] [blame] | 47 | # echo Running test: "$name.right" |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 48 | { |
| 49 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 |
| 50 | diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" |
| 51 | } && echo "$1/$x: ok" || echo "$1/$x: fail" |
| 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 hush-*` |
| 62 | |
| 63 | for module in $modules; do |
| 64 | do_test $module |
| 65 | done |
| 66 | else |
| 67 | while [ $# -ge 1 ]; do |
| 68 | if [ -d $1 ]; then |
| 69 | do_test $1 |
| 70 | fi |
| 71 | shift |
| 72 | done |
| 73 | fi |