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