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 | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 12 | TOPDIR=`pwd` |
| 13 | |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 14 | if 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 Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 19 | echo "No ./hush - creating a link to ../../busybox" |
| 20 | ln -s ../../busybox hush |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 21 | fi |
| 22 | if test ! -f .config; then |
| 23 | if test ! -f ../../.config; then |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 24 | echo "Missing .config file" |
| 25 | exit 1 |
| 26 | fi |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 27 | cp ../../.config . || exit 1 |
Mike Frysinger | 20300d0 | 2009-04-09 07:49:43 +0000 | [diff] [blame] | 28 | fi |
Denys Vlasenko | dbfa45b | 2009-08-12 21:24:29 +0200 | [diff] [blame] | 29 | |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 30 | eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config) |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 31 | |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 32 | PATH="`pwd`:$PATH" # for hush and recho/zecho/printenv |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 33 | export PATH |
| 34 | |
Denys Vlasenko | 1967978 | 2009-08-12 14:53:44 +0200 | [diff] [blame] | 35 | THIS_SH="`pwd`/hush" |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 36 | export THIS_SH |
| 37 | |
| 38 | do_test() |
| 39 | { |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 40 | test -d "$1" || return 0 |
| 41 | d=${d%/} |
| 42 | # echo Running tests in directory "$1" |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 43 | # $1 but with / replaced by # so that it can be used as filename part |
| 44 | noslash=`echo "$1" | sed 's:/:#:g'` |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 45 | ( |
| 46 | tret=0 |
| 47 | cd "$1" || { echo "cannot cd $1!"; exit 1; } |
| 48 | for x in run-*; do |
Denys Vlasenko | cbfe6ad | 2009-08-12 19:47:44 +0200 | [diff] [blame] | 49 | test -f "$x" || continue |
| 50 | case "$x" in |
| 51 | "$0"|run-minimal|run-gprof) ;; |
| 52 | *.orig|*~) ;; |
| 53 | #*) echo $x ; sh $x ;; |
| 54 | *) |
Denys Vlasenko | bcf1fa8 | 2011-05-09 01:05:33 +0200 | [diff] [blame] | 55 | echo -n "$1/$x:" |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 56 | sh "$x" >"$TOPDIR/$noslash-$x.fail" 2>&1 && \ |
| 57 | { { echo " ok"; rm "$TOPDIR/$noslash-$x.fail"; } || echo " fail"; } |
Denys Vlasenko | cbfe6ad | 2009-08-12 19:47:44 +0200 | [diff] [blame] | 58 | ;; |
| 59 | esac |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 60 | 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 Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 64 | 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 Vlasenko | 19c9f31 | 2017-08-03 19:52:47 +0200 | [diff] [blame] | 83 | *) echo " fail ($?)"; tret=1;; |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 84 | esac |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 85 | done |
| 86 | exit ${tret} |
| 87 | ) |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | # Main part of this script |
| 91 | # Usage: run-all [directories] |
| 92 | |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 93 | ret=0 |
| 94 | |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 95 | if [ $# -lt 1 ]; then |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 96 | # All sub directories |
| 97 | modules=`ls -d hush-*` |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 98 | |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 99 | for module in $modules; do |
Denys Vlasenko | 9a8ece5 | 2017-07-06 17:59:25 +0200 | [diff] [blame] | 100 | do_test $module || ret=1 |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 101 | done |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 102 | else |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 103 | while [ $# -ge 1 ]; do |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 104 | if [ -d $1 ]; then |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 105 | do_test $1 || ret=1 |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 106 | fi |
| 107 | shift |
Mike Frysinger | eab40e5 | 2009-06-01 16:33:05 -0400 | [diff] [blame] | 108 | done |
Denis Vlasenko | 119b995 | 2007-05-11 12:57:35 +0000 | [diff] [blame] | 109 | fi |
Mike Frysinger | 42ab865 | 2009-03-28 15:43:47 +0000 | [diff] [blame] | 110 | |
| 111 | exit ${ret} |