[1765] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
[2725] | 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
|
---|
[1765] | 11 |
|
---|
[2725] | 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
|
---|
| 17 | echo "No ./hush - creating a link to ../../busybox"
|
---|
| 18 | ln -s ../../busybox hush
|
---|
| 19 | fi
|
---|
| 20 | if test ! -f .config; then
|
---|
| 21 | if test ! -f ../../.config; then
|
---|
| 22 | echo "Missing .config file"
|
---|
| 23 | exit 1
|
---|
| 24 | fi
|
---|
| 25 | cp ../../.config . || exit 1
|
---|
| 26 | fi
|
---|
| 27 |
|
---|
| 28 | eval $(sed -e '/^#/d' -e '/^$/d' -e 's:^:export :' .config)
|
---|
| 29 |
|
---|
| 30 | PATH="`pwd`:$PATH" # for hush and recho/zecho/printenv
|
---|
[1765] | 31 | export PATH
|
---|
| 32 |
|
---|
[2725] | 33 | THIS_SH="`pwd`/hush"
|
---|
[1765] | 34 | export THIS_SH
|
---|
| 35 |
|
---|
| 36 | do_test()
|
---|
| 37 | {
|
---|
[2725] | 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
|
---|
| 45 | test -f "$x" || continue
|
---|
| 46 | case "$x" in
|
---|
| 47 | "$0"|run-minimal|run-gprof) ;;
|
---|
| 48 | *.orig|*~) ;;
|
---|
| 49 | #*) echo $x ; sh $x ;;
|
---|
| 50 | *)
|
---|
[3232] | 51 | echo -n "$1/$x:"
|
---|
[2725] | 52 | sh "$x" >"../$1-$x.fail" 2>&1 && \
|
---|
[3232] | 53 | { { echo " ok"; rm "../$1-$x.fail"; } || echo " fail"; }
|
---|
[2725] | 54 | ;;
|
---|
| 55 | esac
|
---|
| 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
|
---|
[1765] | 60 | test -x "$x" || continue
|
---|
| 61 | name="${x%%.tests}"
|
---|
| 62 | test -f "$name.right" || continue
|
---|
[2725] | 63 | # echo Running test: "$x"
|
---|
[3232] | 64 | echo -n "$1/$x:"
|
---|
[2725] | 65 | (
|
---|
| 66 | "$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"
|
---|
| 73 | )
|
---|
| 74 | case $? in
|
---|
[3232] | 75 | 0) echo " ok";;
|
---|
| 76 | 77) echo " skip (feature disabled)";;
|
---|
| 77 | *) echo " fail"; tret=1;;
|
---|
[2725] | 78 | esac
|
---|
| 79 | done
|
---|
| 80 | exit ${tret}
|
---|
| 81 | )
|
---|
[1765] | 82 | }
|
---|
| 83 |
|
---|
| 84 | # Main part of this script
|
---|
| 85 | # Usage: run-all [directories]
|
---|
| 86 |
|
---|
[2725] | 87 | ret=0
|
---|
| 88 |
|
---|
[1765] | 89 | if [ $# -lt 1 ]; then
|
---|
[2725] | 90 | # All sub directories
|
---|
| 91 | modules=`ls -d hush-*`
|
---|
[1765] | 92 |
|
---|
[2725] | 93 | for module in $modules; do
|
---|
| 94 | do_test $module || ret=1
|
---|
| 95 | done
|
---|
[1765] | 96 | else
|
---|
[2725] | 97 | while [ $# -ge 1 ]; do
|
---|
[1765] | 98 | if [ -d $1 ]; then
|
---|
[2725] | 99 | do_test $1 || ret=1
|
---|
[1765] | 100 | fi
|
---|
| 101 | shift
|
---|
[2725] | 102 | done
|
---|
[1765] | 103 | fi
|
---|
[2725] | 104 |
|
---|
| 105 | exit ${ret}
|
---|