blob: 256f152dc90c5062a9fa7c60c6aa53627f49a209 [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
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020012if test ! -x hush; then
13 if test ! -x ../../busybox; then
14 echo "Can't run tests. Put hush binary into this directory (`pwd`)"
15 exit 1
16 fi
Mike Frysingereab40e52009-06-01 16:33:05 -040017 echo "No ./hush - creating a link to ../../busybox"
18 ln -s ../../busybox hush
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020019fi
20if test ! -f .config; then
21 if test ! -f ../../.config; then
Denys Vlasenko19679782009-08-12 14:53:44 +020022 echo "Missing .config file"
23 exit 1
24 fi
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020025 cp ../../.config . || exit 1
Mike Frysinger20300d02009-04-09 07:49:43 +000026fi
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020027
Denys Vlasenko19679782009-08-12 14:53:44 +020028eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
Denis Vlasenko119b9952007-05-11 12:57:35 +000029
Denys Vlasenko19679782009-08-12 14:53:44 +020030PATH="`pwd`:$PATH" # for hush and recho/zecho/printenv
Denis Vlasenko119b9952007-05-11 12:57:35 +000031export PATH
32
Denys Vlasenko19679782009-08-12 14:53:44 +020033THIS_SH="`pwd`/hush"
Denis Vlasenko119b9952007-05-11 12:57:35 +000034export THIS_SH
35
36do_test()
37{
Mike Frysingereab40e52009-06-01 16:33:05 -040038 test -d "$1" || return 0
39 d=${d%/}
40# echo Running tests in directory "$1"
41 (
42 tret=0
43 cd "$1" || { echo "cannot cd $1!"; exit 1; }
44 for x in run-*; do
Denys Vlasenkocbfe6ad2009-08-12 19:47:44 +020045 test -f "$x" || continue
46 case "$x" in
47 "$0"|run-minimal|run-gprof) ;;
48 *.orig|*~) ;;
49 #*) echo $x ; sh $x ;;
50 *)
51 sh "$x" >"../$1-$x.fail" 2>&1 && \
52 { echo "$1/$x: ok"; rm "../$1-$x.fail"; } || echo "$1/$x: fail";
53 ;;
54 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040055 done
56 # Many bash run-XXX scripts just do this,
57 # no point in duplication it all over the place
58 for x in *.tests; do
Denis Vlasenko119b9952007-05-11 12:57:35 +000059 test -x "$x" || continue
60 name="${x%%.tests}"
61 test -f "$name.right" || continue
Denis Vlasenkocd418a22009-04-06 18:08:35 +000062# echo Running test: "$x"
Mike Frysinger20300d02009-04-09 07:49:43 +000063 (
Mike Frysingereab40e52009-06-01 16:33:05 -040064 "$THIS_SH" "./$x" >"$name.xx" 2>&1
65 # filter C library differences
66 sed -i \
67 -e "/: invalid option /s:'::g" \
68 "$name.xx"
69 test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77
70 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
Mike Frysinger20300d02009-04-09 07:49:43 +000071 )
72 case $? in
73 0) echo "$1/$x: ok";;
74 77) echo "$1/$x: skip (feature disabled)";;
75 *) echo "$1/$x: fail"; tret=1;;
76 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040077 done
78 exit ${tret}
79 )
Denis Vlasenko119b9952007-05-11 12:57:35 +000080}
81
82# Main part of this script
83# Usage: run-all [directories]
84
Mike Frysinger42ab8652009-03-28 15:43:47 +000085ret=0
86
Denis Vlasenko119b9952007-05-11 12:57:35 +000087if [ $# -lt 1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -040088 # All sub directories
89 modules=`ls -d hush-*`
Denis Vlasenko119b9952007-05-11 12:57:35 +000090
Mike Frysingereab40e52009-06-01 16:33:05 -040091 for module in $modules; do
Mike Frysinger42ab8652009-03-28 15:43:47 +000092 do_test $module || ret=1
Mike Frysingereab40e52009-06-01 16:33:05 -040093 done
Denis Vlasenko119b9952007-05-11 12:57:35 +000094else
Mike Frysingereab40e52009-06-01 16:33:05 -040095 while [ $# -ge 1 ]; do
Denis Vlasenko119b9952007-05-11 12:57:35 +000096 if [ -d $1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -040097 do_test $1 || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +000098 fi
99 shift
Mike Frysingereab40e52009-06-01 16:33:05 -0400100 done
Denis Vlasenko119b9952007-05-11 12:57:35 +0000101fi
Mike Frysinger42ab8652009-03-28 15:43:47 +0000102
103exit ${ret}