blob: e023338880b531ea710a192b55355e1c579e1c9a [file] [log] [blame]
Denis Vlasenko1c660b42007-03-05 00:27:50 +00001#!/bin/sh
2
Denis Vlasenko81887e22008-02-13 18:09:56 +00003test -x ash || {
4 echo "No ./ash?! Perhaps you want to run 'ln -s ../../busybox ash'"
5 exit
6}
Denis Vlasenko1c660b42007-03-05 00:27:50 +00007test -x printenv || gcc -O2 -o printenv printenv.c || exit $?
8test -x recho || gcc -O2 -o recho recho.c || exit $?
9test -x zecho || gcc -O2 -o zecho zecho.c || exit $?
10
11PATH="$PWD:$PATH" # for ash and recho/zecho/printenv
12export PATH
13
14THIS_SH="$PWD/ash"
15export THIS_SH
16
17do_test()
18{
19 test -d "$1" || return 0
Denis Vlasenko0e6f6612008-02-15 15:02:15 +000020 echo do_test "$1"
Denis Vlasenko1c660b42007-03-05 00:27:50 +000021 (
22 cd "$1" || { echo "cannot cd $1!"; exit 1; }
23 for x in run-*; do
24 test -f "$x" || continue
Denis Vlasenkoc86e0522007-03-20 11:30:28 +000025 case "$x" in
Denis Vlasenko1c660b42007-03-05 00:27:50 +000026 "$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
52if [ $# -lt 1 ]; then
53 # All sub directories
54 modules=`ls -d ash-*`
55
56 for module in $modules; do
Denis Vlasenko1c660b42007-03-05 00:27:50 +000057 do_test $module
58 done
59else
60 while [ $# -ge 1 ]; do
61 if [ -d $1 ]; then
62 do_test $1
63 fi
64 shift
65 done
66fi