blob: 3fbc7c531b3e369c508d001f1b23bd56194ae2c1 [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 Vlasenko9a8ece52017-07-06 17:59:25 +020012TOPDIR=`pwd`
13
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020014if test ! -x hush; then
15 if test ! -x ../../busybox; then
16 echo "Can't run tests. Put hush binary into this directory (`pwd`)"
17 exit 1
18 fi
Mike Frysingereab40e52009-06-01 16:33:05 -040019 echo "No ./hush - creating a link to ../../busybox"
20 ln -s ../../busybox hush
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020021fi
22if test ! -f .config; then
23 if test ! -f ../../.config; then
Denys Vlasenko19679782009-08-12 14:53:44 +020024 echo "Missing .config file"
25 exit 1
26 fi
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020027 cp ../../.config . || exit 1
Mike Frysinger20300d02009-04-09 07:49:43 +000028fi
Denys Vlasenkodbfa45b2009-08-12 21:24:29 +020029
Denys Vlasenko19679782009-08-12 14:53:44 +020030eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
Denis Vlasenko119b9952007-05-11 12:57:35 +000031
Denys Vlasenko19679782009-08-12 14:53:44 +020032PATH="`pwd`:$PATH" # for hush and recho/zecho/printenv
Denis Vlasenko119b9952007-05-11 12:57:35 +000033export PATH
34
Denys Vlasenko19679782009-08-12 14:53:44 +020035THIS_SH="`pwd`/hush"
Denis Vlasenko119b9952007-05-11 12:57:35 +000036export THIS_SH
37
38do_test()
39{
Mike Frysingereab40e52009-06-01 16:33:05 -040040 test -d "$1" || return 0
41 d=${d%/}
42# echo Running tests in directory "$1"
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020043 # $1 but with / replaced by # so that it can be used as filename part
44 noslash=`echo "$1" | sed 's:/:#:g'`
Mike Frysingereab40e52009-06-01 16:33:05 -040045 (
46 tret=0
47 cd "$1" || { echo "cannot cd $1!"; exit 1; }
48 for x in run-*; do
Denys Vlasenkocbfe6ad2009-08-12 19:47:44 +020049 test -f "$x" || continue
50 case "$x" in
51 "$0"|run-minimal|run-gprof) ;;
52 *.orig|*~) ;;
53 #*) echo $x ; sh $x ;;
54 *)
Denys Vlasenkobcf1fa82011-05-09 01:05:33 +020055 echo -n "$1/$x:"
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020056 sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \
57 { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; }
Denys Vlasenkocbfe6ad2009-08-12 19:47:44 +020058 ;;
59 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040060 done
61 # Many bash run-XXX scripts just do this,
62 # no point in duplication it all over the place
63 for x in *.tests; do
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020064 test -x "$x" || continue
65 name="${x%%.tests}"
66 test -f "$name.right" || continue
67# echo Running test: "$x"
68 echo -n "$1/$x:"
69 (
70 "$THIS_SH" "./$x" >"$name.xx" 2>&1
71 r=$?
72 # filter C library differences
73 sed -i \
74 -e "/: invalid option /s:'::g" \
75 "$name.xx"
76 test $r -eq 77 && rm -f "$TOPDIR/$noslash-$x.fail" && exit 77
77 diff -u "$name.xx" "$name.right" >"$TOPDIR/$noslash-$x.fail" \
78 && rm -f "$name.xx" "$TOPDIR/$noslash-$x.fail"
79 )
80 case $? in
81 0) echo " ok";;
82 77) echo " skip (feature disabled)";;
Denys Vlasenko19c9f312017-08-03 19:52:47 +020083 *) echo " fail ($?)"; tret=1;;
Denys Vlasenko9a8ece52017-07-06 17:59:25 +020084 esac
Mike Frysingereab40e52009-06-01 16:33:05 -040085 done
86 exit ${tret}
87 )
Denis Vlasenko119b9952007-05-11 12:57:35 +000088}
89
90# Main part of this script
91# Usage: run-all [directories]
92
Mike Frysinger42ab8652009-03-28 15:43:47 +000093ret=0
94
Denis Vlasenko119b9952007-05-11 12:57:35 +000095if [ $# -lt 1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -040096 # All sub directories
97 modules=`ls -d hush-*`
Denis Vlasenko119b9952007-05-11 12:57:35 +000098
Mike Frysingereab40e52009-06-01 16:33:05 -040099 for module in $modules; do
Denys Vlasenko9a8ece52017-07-06 17:59:25 +0200100 do_test $module || ret=1
Mike Frysingereab40e52009-06-01 16:33:05 -0400101 done
Denis Vlasenko119b9952007-05-11 12:57:35 +0000102else
Mike Frysingereab40e52009-06-01 16:33:05 -0400103 while [ $# -ge 1 ]; do
Denis Vlasenko119b9952007-05-11 12:57:35 +0000104 if [ -d $1 ]; then
Mike Frysingereab40e52009-06-01 16:33:05 -0400105 do_test $1 || ret=1
Denis Vlasenko119b9952007-05-11 12:57:35 +0000106 fi
107 shift
Mike Frysingereab40e52009-06-01 16:33:05 -0400108 done
Denis Vlasenko119b9952007-05-11 12:57:35 +0000109fi
Mike Frysinger42ab8652009-03-28 15:43:47 +0000110
111exit ${ret}