blob: 64a7abc479ae388c559f888da0e52c930a59b12f [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
67 # filter C library differences
68 sed -i \
69 -e "/: invalid option /s:'::g" \
70 "$name.xx"
71 test $? -eq 77 && rm -f "../$1-$x.fail" && exit 77
72 diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail"
Mike Frysinger20300d02009-04-09 07:49:43 +000073 )
74 case $? in
Denys Vlasenkobcf1fa82011-05-09 01:05:33 +020075 0) echo " ok";;
76 77) echo " skip (feature disabled)";;
77 *) echo " fail"; tret=1;;
Mike Frysinger20300d02009-04-09 07:49:43 +000078 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040079 done
80 exit ${tret}
81 )
Denis Vlasenko119b9952007-05-11 12:57:35 +000082}
83
84# Main part of this script
85# Usage: run-all [directories]
86
Mike Frysinger42ab8652009-03-28 15:43:47 +000087ret=0
88
Denis Vlasenko119b9952007-05-11 12:57:35 +000089if [ $# -lt 1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -040090 # All sub directories
91 modules=`ls -d hush-*`
Denis Vlasenko119b9952007-05-11 12:57:35 +000092
Mike Frysingereab40e52009-06-01 16:33:05 -040093 for module in $modules; do
Mike Frysinger42ab8652009-03-28 15:43:47 +000094 do_test $module || ret=1
Mike Frysingereab40e52009-06-01 16:33:05 -040095 done
Denis Vlasenko119b9952007-05-11 12:57:35 +000096else
Mike Frysingereab40e52009-06-01 16:33:05 -040097 while [ $# -ge 1 ]; do
Denis Vlasenko119b9952007-05-11 12:57:35 +000098 if [ -d $1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -040099 do_test $1 || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +0000100 fi
101 shift
Mike Frysingereab40e52009-06-01 16:33:05 -0400102 done
Denis Vlasenko119b9952007-05-11 12:57:35 +0000103fi
Mike Frysinger42ab8652009-03-28 15:43:47 +0000104
105exit ${ret}