add tests for basic fd open/close/dupe
[oweals/busybox.git] / shell / hush_test / run-all
1 #!/bin/sh
2
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
12 test -x hush || {
13     echo "No ./hush - creating a link to ../../busybox"
14     ln -s ../../busybox hush
15 }
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
26     d=${d%/}
27 #   echo Running tests in directory "$1"
28     (
29     tret=0
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
49 #       echo Running test: "$name.right"
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"
53         } && echo "$1/$x: ok" || { echo "$1/$x: fail"; tret=1; }
54     done
55     exit ${tret}
56     )
57 }
58
59 # Main part of this script
60 # Usage: run-all [directories]
61
62 ret=0
63
64 if [ $# -lt 1 ]; then
65     # All sub directories
66     modules=`ls -d hush-*`
67
68     for module in $modules; do
69         do_test $module || ret=1
70     done
71 else
72     while [ $# -ge 1 ]; do
73         if [ -d $1 ]; then
74             do_test $1 || ret=1
75         fi
76         shift
77     done
78 fi
79
80 exit ${ret}