Denis Vlasenko | a43dba7 | 2008-03-02 19:57:53 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | test -x msh || { |
Denis Vlasenko | ccff0b9 | 2009-03-21 19:58:58 +0000 | [diff] [blame] | 4 | echo "No ./msh - creating a link to ../../busybox" |
| 5 | ln -s ../../busybox msh |
Denis Vlasenko | a43dba7 | 2008-03-02 19:57:53 +0000 | [diff] [blame] | 6 | } |
| 7 | |
| 8 | PATH="$PWD:$PATH" # for msh |
| 9 | export PATH |
| 10 | |
| 11 | THIS_SH="$PWD/msh" |
| 12 | export THIS_SH |
| 13 | |
| 14 | do_test() |
| 15 | { |
| 16 | test -d "$1" || return 0 |
| 17 | # echo Running tests in directory "$1" |
| 18 | ( |
| 19 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
| 20 | for x in run-*; do |
| 21 | test -f "$x" || continue |
| 22 | case "$x" in |
| 23 | "$0"|run-minimal|run-gprof) ;; |
| 24 | *.orig|*~) ;; |
| 25 | #*) echo $x ; sh $x ;; |
| 26 | *) |
| 27 | sh "$x" >"../$1-$x.fail" 2>&1 && \ |
| 28 | { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail"; |
| 29 | ;; |
| 30 | esac |
| 31 | done |
| 32 | # Many bash run-XXX scripts just do this, |
| 33 | # no point in duplication it all over the place |
| 34 | for x in *.tests; do |
| 35 | test -x "$x" || continue |
| 36 | name="${x%%.tests}" |
| 37 | test -f "$name.right" || continue |
| 38 | # echo Running test: "$name.right" |
| 39 | { |
| 40 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 |
| 41 | diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" |
| 42 | } && echo "$1/$x: ok" || echo "$1/$x: fail" |
| 43 | done |
| 44 | ) |
| 45 | } |
| 46 | |
| 47 | # Main part of this script |
| 48 | # Usage: run-all [directories] |
| 49 | |
| 50 | if [ $# -lt 1 ]; then |
| 51 | # All sub directories |
| 52 | modules=`ls -d msh-*` |
| 53 | |
| 54 | for module in $modules; do |
| 55 | do_test $module |
| 56 | done |
| 57 | else |
| 58 | while [ $# -ge 1 ]; do |
| 59 | if [ -d $1 ]; then |
| 60 | do_test $1 |
| 61 | fi |
| 62 | shift |
| 63 | done |
| 64 | fi |