Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
Denis Vlasenko | 30c9cc5 | 2008-06-17 07:24:29 +0000 | [diff] [blame] | 3 | unset LANG LANGUAGE |
| 4 | unset LC_COLLATE |
| 5 | unset LC_CTYPE |
| 6 | unset LC_MONETARY |
| 7 | unset LC_MESSAGES |
| 8 | unset LC_NUMERIC |
| 9 | unset LC_TIME |
| 10 | unset LC_ALL |
| 11 | |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 12 | if 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 Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 17 | echo "No ./hush - creating a link to ../../busybox" |
| 18 | ln -s ../../busybox hush |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 19 | fi |
| 20 | if test ! -f .config; then |
| 21 | if test ! -f ../../.config; then |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 22 | echo "Missing .config file" |
| 23 | exit 1 |
| 24 | fi |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 25 | cp ../../.config . || exit 1 |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 26 | fi |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 27 | |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 28 | eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config) |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 29 | |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 30 | PATH="`pwd`:$PATH" # for hush and recho/zecho/printenv |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 31 | export PATH |
| 32 | |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 33 | THIS_SH="`pwd`/hush" |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 34 | export THIS_SH |
| 35 | |
| 36 | do_test() |
| 37 | { |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 38 | 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 Vlasenko | cbfe6ad | 2009-08-12 19:47:44 +0200 | [diff] [blame] | 45 | test -f "$x" || continue |
| 46 | case "$x" in |
| 47 | "$0"|run-minimal|run-gprof) ;; |
| 48 | *.orig|*~) ;; |
| 49 | #*) echo $x ; sh $x ;; |
| 50 | *) |
Denys Vlasenko | bcf1fa8 | 2011-05-09 01:05:33 +0200 | [diff] [blame] | 51 | echo -n "$1/$x:" |
Denys Vlasenko | cbfe6ad | 2009-08-12 19:47:44 +0200 | [diff] [blame] | 52 | sh "$x" >"../$1-$x.fail" 2>&1 && \ |
Denys Vlasenko | bcf1fa8 | 2011-05-09 01:05:33 +0200 | [diff] [blame] | 53 | { { echo " ok"; rm "../$1-$x.fail"; } || echo " fail"; } |
Denys Vlasenko | cbfe6ad | 2009-08-12 19:47:44 +0200 | [diff] [blame] | 54 | ;; |
| 55 | esac |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 56 | 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 Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 60 | test -x "$x" || continue |
| 61 | name="${x%%.tests}" |
| 62 | test -f "$name.right" || continue |
Denis Vlasenko | cd418a2 | 2009-04-06 18:08:35 +0000 | [diff] [blame] | 63 | # echo Running test: "$x" |
Denys Vlasenko | bcf1fa8 | 2011-05-09 01:05:33 +0200 | [diff] [blame] | 64 | echo -n "$1/$x:" |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 65 | ( |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 66 | "$THIS_SH" "./$x" >"$name.xx" 2>&1 |
Denys Vlasenko | 215b0ca | 2016-08-19 18:23:56 +0200 | [diff] [blame] | 67 | r=$? |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 68 | # filter C library differences |
| 69 | sed -i \ |
| 70 | -e "/: invalid option /s:'::g" \ |
| 71 | "$name.xx" |
Denys Vlasenko | 215b0ca | 2016-08-19 18:23:56 +0200 | [diff] [blame] | 72 | test $r -eq 77 && rm -f "../$1-$x.fail" && exit 77 |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 73 | diff -u "$name.xx" "$name.right" >"../$1-$x.fail" && rm -f "$name.xx" "../$1-$x.fail" |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 74 | ) |
| 75 | case $? in |
Denys Vlasenko | bcf1fa8 | 2011-05-09 01:05:33 +0200 | [diff] [blame] | 76 | 0) echo " ok";; |
| 77 | 77) echo " skip (feature disabled)";; |
| 78 | *) echo " fail"; tret=1;; |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 79 | esac |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 80 | done |
| 81 | exit ${tret} |
| 82 | ) |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | # Main part of this script |
| 86 | # Usage: run-all [directories] |
| 87 | |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 88 | ret=0 |
| 89 | |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 90 | if [ $# -lt 1 ]; then |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 91 | # All sub directories |
| 92 | modules=`ls -d hush-*` |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 93 | |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 94 | for module in $modules; do |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 95 | do_test $module || ret=1 |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 96 | done |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 97 | else |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 98 | while [ $# -ge 1 ]; do |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 99 | if [ -d $1 ]; then |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 100 | do_test $1 || ret=1 |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 101 | fi |
| 102 | shift |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 103 | done |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 104 | fi |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 105 | |
| 106 | exit ${ret} |