remove msh_function.patch. msh is deprecated
[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 if test -e ../../.config ; then
17         eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' ../../.config)
18 fi
19
20 PATH="$PWD:$PATH" # for hush and recho/zecho/printenv
21 export PATH
22
23 THIS_SH="$PWD/hush"
24 export THIS_SH
25
26 do_test()
27 {
28         test -d "$1" || return 0
29         d=${d%/}
30 #       echo Running tests in directory "$1"
31         (
32         tret=0
33         cd "$1" || { echo "cannot cd $1!"; exit 1; }
34         for x in run-*; do
35         test -f "$x" || continue
36         case "$x" in
37                 "$0"|run-minimal|run-gprof) ;;
38                 *.orig|*~) ;;
39                 #*) echo $x ; sh $x ;;
40                 *)
41                 sh "$x" >"../$1-$x.fail" 2>&1 && \
42                 { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
43                 ;;
44         esac
45         done
46         # Many bash run-XXX scripts just do this,
47         # no point in duplication it all over the place
48         for x in *.tests; do
49         test -x "$x" || continue
50         name="${x%%.tests}"
51         test -f "$name.right" || continue
52 #       echo Running test: "$x"
53         (
54                 "$THIS_SH" "./$x" >"$name.xx" 2>&1
55                 # filter C library differences
56                 sed -i \
57                         -e "/: invalid option /s:'::g" \
58                         "$name.xx"
59                 test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77
60                 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
61         )
62         case $? in
63                 0)  echo "$1/$x: ok";;
64                 77) echo "$1/$x: skip (feature disabled)";;
65                 *)  echo "$1/$x: fail"; tret=1;;
66         esac
67         done
68         exit ${tret}
69         )
70 }
71
72 # Main part of this script
73 # Usage: run-all [directories]
74
75 ret=0
76
77 if [ $# -lt 1 ]; then
78         # All sub directories
79         modules=`ls -d hush-*`
80
81         for module in $modules; do
82         do_test $module || ret=1
83         done
84 else
85         while [ $# -ge 1 ]; do
86         if [ -d $1 ]; then
87                 do_test $1 || ret=1
88         fi
89         shift
90         done
91 fi
92
93 exit ${ret}