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