1#!/bin/bash 2 3TOPDIR="$PWD" 4FILES="$PWD"/tests/files 5 6trap 'kill $(jobs -p) 2>/dev/null; exit 1' INT 7 8rm -rf generated/testdir 9mkdir -p generated/testdir/testdir 10 11if [ -z "$TEST_HOST" ] 12then 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 19fi 20 21cd generated/testdir 22PATH="$PWD:$PATH" 23cd testdir 24export 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 29do_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 42if [ $# -ne 0 ] 43then 44 for i in "$@" 45 do 46 do_test "$TOPDIR"/tests/$i.test 47 done 48else 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 60fi 61