Initial public busybox upstream commit
[busybox4maemo] / 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     echo do_test "$1"
21     (
22     cd "$1" || { echo "cannot cd $1!"; exit 1; }
23     for x in run-*; do
24         test -f "$x" || continue
25         case "$x" in
26             "$0"|run-minimal|run-gprof) ;;
27             *.orig|*~) ;;
28             #*) echo $x ; sh $x ;;
29             *)
30             sh "$x" >"../$1-$x.fail" 2>&1 && \
31             { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
32             ;;
33         esac
34     done
35     # Many bash run-XXX scripts just do this,
36     # no point in duplication it all over the place
37     for x in *.tests; do
38         test -x "$x" || continue
39         name="${x%%.tests}"
40         test -f "$name.right" || continue
41         {
42             "$THIS_SH" "./$x" >"$name.xx" 2>&1
43             diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
44         } && echo "$1/$x: ok" || echo "$1/$x: fail"
45     done
46     )
47 }
48
49 # main part of this script
50 # Usage: run-all [directories]
51
52 if [ $# -lt 1 ]; then
53     # All sub directories
54     modules=`ls -d ash-*`
55
56     for module in $modules; do
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