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