blob: 837b3f7da100d64b585ffd1a7cd3e048b578b259 [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 *)
Denys Vlasenkobcf1fa82011-05-09 01:05:33 +020051 echo -n "$1/$x:"
Denys Vlasenkocbfe6ad2009-08-12 19:47:44 +020052 sh "$x" >"../$1-$x.fail" 2>&1 && \
Denys Vlasenkobcf1fa82011-05-09 01:05:33 +020053 { { echo " ok"; rm "../$1-$x.fail"; } || echo " fail"; }
Denys Vlasenkocbfe6ad2009-08-12 19:47:44 +020054 ;;
55 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040056 done
57 # Many bash run-XXX scripts just do this,
58 # no point in duplication it all over the place
59 for x in *.tests; do
Denis Vlasenko119b9952007-05-11 12:57:35 +000060 test -x "$x" || continue
61 name="${x%%.tests}"
62 test -f "$name.right" || continue
Denis Vlasenkocd418a22009-04-06 18:08:35 +000063# echo Running test: "$x"
Denys Vlasenkobcf1fa82011-05-09 01:05:33 +020064 echo -n "$1/$x:"
Mike Frysinger20300d02009-04-09 07:49:43 +000065 (
Mike Frysingereab40e52009-06-01 16:33:05 -040066 "$THIS_SH" "./$x" >"$name.xx" 2>&1
Denys Vlasenko215b0ca2016-08-19 18:23:56 +020067 r=$?
Mike Frysingereab40e52009-06-01 16:33:05 -040068 # filter C library differences
69 sed -i \
70 -e "/: invalid option /s:'::g" \
71 "$name.xx"
Denys Vlasenko215b0ca2016-08-19 18:23:56 +020072 test $r -eq 77 && rm -f "../$1-$x.fail" && exit 77
Mike Frysingereab40e52009-06-01 16:33:05 -040073 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
Mike Frysinger20300d02009-04-09 07:49:43 +000074 )
75 case $? in
Denys Vlasenkobcf1fa82011-05-09 01:05:33 +020076 0) echo " ok";;
77 77) echo " skip (feature disabled)";;
78 *) echo " fail"; tret=1;;
Mike Frysinger20300d02009-04-09 07:49:43 +000079 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040080 done
81 exit ${tret}
82 )
Denis Vlasenko119b9952007-05-11 12:57:35 +000083}
84
85# Main part of this script
86# Usage: run-all [directories]
87
Mike Frysinger42ab8652009-03-28 15:43:47 +000088ret=0
89
Denis Vlasenko119b9952007-05-11 12:57:35 +000090if [ $# -lt 1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -040091 # All sub directories
92 modules=`ls -d hush-*`
Denis Vlasenko119b9952007-05-11 12:57:35 +000093
Mike Frysingereab40e52009-06-01 16:33:05 -040094 for module in $modules; do
Mike Frysinger42ab8652009-03-28 15:43:47 +000095 do_test $module || ret=1
Mike Frysingereab40e52009-06-01 16:33:05 -040096 done
Denis Vlasenko119b9952007-05-11 12:57:35 +000097else
Mike Frysingereab40e52009-06-01 16:33:05 -040098 while [ $# -ge 1 ]; do
Denis Vlasenko119b9952007-05-11 12:57:35 +000099 if [ -d $1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -0400100 do_test $1 || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +0000101 fi
102 shift
Mike Frysingereab40e52009-06-01 16:33:05 -0400103 done
Denis Vlasenko119b9952007-05-11 12:57:35 +0000104fi
Mike Frysinger42ab8652009-03-28 15:43:47 +0000105
106exit ${ret}