1 #!/bin/bash 2 3 TOPDIR="$PWD" 4 FILES="$PWD"/tests/files 5 6 trap 'kill $(jobs -p) 2>/dev/null; exit 1' INT 7 8 rm -rf generated/testdir 9 mkdir -p generated/testdir/testdir 10 11 if [ -z "$TEST_HOST" ] 12 then 13 if [ $# -ne 0 ] 14 then 15 PREFIX=generated/testdir/ scripts/single.sh "$@" || exit 1 16 else 17 make install_flat PREFIX=generated/testdir || exit 1 18 fi 19 fi 20 21 cd generated/testdir 22 PATH="$PWD:$PATH" 23 cd testdir 24 export LC_COLLATE=C 25 26 . "$TOPDIR"/scripts/runtest.sh 27 [ -f "$TOPDIR/generated/config.h" ] && export OPTIONFLAGS=:$(echo $(sed -nr 's/^#define CFG_(.*) 1/\1/p' "$TOPDIR/generated/config.h") | sed 's/ /:/g') 28 29 do_test() 30 { 31 CMDNAME="${1##*/}" 32 CMDNAME="${CMDNAME%.test}" 33 [ -z "$2" ] && C="$(readlink -f ../$CMDNAME)" || C="$(which $CMDNAME)" 34 if [ ! -z "$C" ] 35 then 36 . "$1" 37 else 38 echo "$CMDNAME disabled" 39 fi 40 } 41 42 if [ $# -ne 0 ] 43 then 44 for i in "$@" 45 do 46 do_test "$TOPDIR"/tests/$i.test 47 done 48 else 49 for i in "$TOPDIR"/tests/*.test 50 do 51 if [ -z "$TEST_HOST" ] 52 then 53 do_test "$i" 1 54 else 55 rm -rf testdir && mkdir testdir && cd testdir || exit 1 56 do_test "$i" 57 cd .. 58 fi 59 done 60 fi 61