blob: 805f75ad5506750926159eefcf81d82afe5a0869 [file] [log] [blame]
Denis Vlasenko119b9952007-05-11 12:57:35 +00001#!/bin/sh
2
Denis Vlasenko05743d72008-02-10 12:10:08 +00003test -x hush || {
4 echo "No ./hush?! Perhaps you want to run 'ln -s ../../busybox hush'"
5 exit
6}
Denis Vlasenko119b9952007-05-11 12:57:35 +00007
8PATH="$PWD:$PATH" # for hush and recho/zecho/printenv
9export PATH
10
11THIS_SH="$PWD/hush"
12export THIS_SH
13
14do_test()
15{
16 test -d "$1" || return 0
Denis Vlasenkocccdc4e2007-11-23 21:08:38 +000017# echo Running tests in directory "$1"
Denis Vlasenko119b9952007-05-11 12:57:35 +000018 (
19 cd "$1" || { echo "cannot cd $1!"; exit 1; }
20 for x in run-*; do
21 test -f "$x" || continue
22 case "$x" in
23 "$0"|run-minimal|run-gprof) ;;
24 *.orig|*~) ;;
25 #*) echo $x ; sh $x ;;
26 *)
27 sh "$x" >"../$1-$x.fail" 2>&1 && \
28 { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
29 ;;
30 esac
31 done
32 # Many bash run-XXX scripts just do this,
33 # no point in duplication it all over the place
34 for x in *.tests; do
35 test -x "$x" || continue
36 name="${x%%.tests}"
37 test -f "$name.right" || continue
Denis Vlasenkof962a032007-11-23 12:50:54 +000038# echo Running test: "$name.right"
Denis Vlasenko119b9952007-05-11 12:57:35 +000039 {
40 "$THIS_SH" "./$x" >"$name.xx" 2>&1
41 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
42 } && echo "$1/$x: ok" || echo "$1/$x: fail"
43 done
44 )
45}
46
47# Main part of this script
48# Usage: run-all [directories]
49
50if [ $# -lt 1 ]; then
51 # All sub directories
52 modules=`ls -d hush-*`
53
54 for module in $modules; do
55 do_test $module
56 done
57else
58 while [ $# -ge 1 ]; do
59 if [ -d $1 ]; then
60 do_test $1
61 fi
62 shift
63 done
64fi