blob: 57a5c253b16950d6066aa714d20f3b523a97940c [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}
Mike Frysinger20300d02009-04-09 07:49:43 +000016if test -e ../../.config ; then
17 eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' ../../.config)
18fi
Denis Vlasenko119b9952007-05-11 12:57:35 +000019
20PATH="$PWD:$PATH" # for hush and recho/zecho/printenv
21export PATH
22
23THIS_SH="$PWD/hush"
24export THIS_SH
25
26do_test()
27{
28 test -d "$1" || return 0
Mike Frysingera36258f2009-04-02 22:46:52 +000029 d=${d%/}
Denis Vlasenkocccdc4e2007-11-23 21:08:38 +000030# echo Running tests in directory "$1"
Denis Vlasenko119b9952007-05-11 12:57:35 +000031 (
Mike Frysinger42ab8652009-03-28 15:43:47 +000032 tret=0
Denis Vlasenko119b9952007-05-11 12:57:35 +000033 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
Denis Vlasenkocd418a22009-04-06 18:08:35 +000052# echo Running test: "$x"
Mike Frysinger20300d02009-04-09 07:49:43 +000053 (
Denis Vlasenko119b9952007-05-11 12:57:35 +000054 "$THIS_SH" "./$x" >"$name.xx" 2>&1
Mike Frysinger20300d02009-04-09 07:49:43 +000055 test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77
Denis Vlasenko119b9952007-05-11 12:57:35 +000056 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
Mike Frysinger20300d02009-04-09 07:49:43 +000057 )
58 case $? in
59 0) echo "$1/$x: ok";;
60 77) echo "$1/$x: skip (feature disabled)";;
61 *) echo "$1/$x: fail"; tret=1;;
62 esac
Denis Vlasenko119b9952007-05-11 12:57:35 +000063 done
Mike Frysinger42ab8652009-03-28 15:43:47 +000064 exit ${tret}
Denis Vlasenko119b9952007-05-11 12:57:35 +000065 )
66}
67
68# Main part of this script
69# Usage: run-all [directories]
70
Mike Frysinger42ab8652009-03-28 15:43:47 +000071ret=0
72
Denis Vlasenko119b9952007-05-11 12:57:35 +000073if [ $# -lt 1 ]; then
74 # All sub directories
75 modules=`ls -d hush-*`
76
77 for module in $modules; do
Mike Frysinger42ab8652009-03-28 15:43:47 +000078 do_test $module || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +000079 done
80else
81 while [ $# -ge 1 ]; do
82 if [ -d $1 ]; then
Mike Frysinger42ab8652009-03-28 15:43:47 +000083 do_test $1 || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +000084 fi
85 shift
86 done
87fi
Mike Frysinger42ab8652009-03-28 15:43:47 +000088
89exit ${ret}