blob: 3fe3ba51db3a1c6119b0b3dddb9eb470aba1cc09 [file] [log] [blame]
Denis Vlasenko119b9952007-05-11 12:57:35 +00001#!/bin/sh
2
Denis Vlasenko30c9cc52008-06-17 07:24:29 +00003unset LANG LANGUAGE
4unset LC_COLLATE
5unset LC_CTYPE
6unset LC_MONETARY
7unset LC_MESSAGES
8unset LC_NUMERIC
9unset LC_TIME
10unset LC_ALL
11
Denis Vlasenko05743d72008-02-10 12:10:08 +000012test -x hush || {
Denis Vlasenkoa8442002008-06-14 11:00:17 +000013 echo "No ./hush - creating a link to ../../busybox"
14 ln -s ../../busybox hush
Denis Vlasenko05743d72008-02-10 12:10:08 +000015}
Denis Vlasenko119b9952007-05-11 12:57:35 +000016
17PATH="$PWD:$PATH" # for hush and recho/zecho/printenv
18export PATH
19
20THIS_SH="$PWD/hush"
21export THIS_SH
22
23do_test()
24{
25 test -d "$1" || return 0
Mike Frysingera36258f2009-04-02 22:46:52 +000026 d=${d%/}
Denis Vlasenkocccdc4e2007-11-23 21:08:38 +000027# echo Running tests in directory "$1"
Denis Vlasenko119b9952007-05-11 12:57:35 +000028 (
Mike Frysinger42ab8652009-03-28 15:43:47 +000029 tret=0
Denis Vlasenko119b9952007-05-11 12:57:35 +000030 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
Denis Vlasenkof962a032007-11-23 12:50:54 +000049# echo Running test: "$name.right"
Denis Vlasenko119b9952007-05-11 12:57:35 +000050 {
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"
Denis Vlasenkoe61f07f2009-03-28 19:31:34 +000053 } && echo "$1/$x: ok" || { echo "$1/$x: fail"; tret=1; }
Denis Vlasenko119b9952007-05-11 12:57:35 +000054 done
Mike Frysinger42ab8652009-03-28 15:43:47 +000055 exit ${tret}
Denis Vlasenko119b9952007-05-11 12:57:35 +000056 )
57}
58
59# Main part of this script
60# Usage: run-all [directories]
61
Mike Frysinger42ab8652009-03-28 15:43:47 +000062ret=0
63
Denis Vlasenko119b9952007-05-11 12:57:35 +000064if [ $# -lt 1 ]; then
65 # All sub directories
66 modules=`ls -d hush-*`
67
68 for module in $modules; do
Mike Frysinger42ab8652009-03-28 15:43:47 +000069 do_test $module || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +000070 done
71else
72 while [ $# -ge 1 ]; do
73 if [ -d $1 ]; then
Mike Frysinger42ab8652009-03-28 15:43:47 +000074 do_test $1 || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +000075 fi
76 shift
77 done
78fi
Mike Frysinger42ab8652009-03-28 15:43:47 +000079
80exit ${ret}