blob: b9413d6839eac6e62a4a9f65c14237fea1f339e5 [file] [log] [blame]
source config.mak
function for_each_unittest()
{
local unittests="$1"
local cmd="$2"
local testname
local smp
local kernel
local opts
local groups
local arch
local check
local accel
local timeout
local rematch
exec {fd}<"$unittests"
while read -r -u $fd line; do
if [[ "$line" =~ ^\[(.*)\]$ ]]; then
rematch=${BASH_REMATCH[1]}
if [ -n "${testname}" ]; then
$(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
fi
testname=$rematch
smp=1
kernel=""
opts=""
groups=""
arch=""
check=""
accel=""
timeout=""
elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
kernel=$TEST_DIR/${BASH_REMATCH[1]}
elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
smp=${BASH_REMATCH[1]}
elif [[ $line =~ ^extra_params\ *=\ *'"""'(.*)$ ]]; then
opts=${BASH_REMATCH[1]}$'\n'
while read -r -u $fd; do
#escape backslash newline, but not double backslash
if [[ $opts =~ [^\\]*(\\*)$'\n'$ ]]; then
if (( ${#BASH_REMATCH[1]} % 2 == 1 )); then
opts=${opts%\\$'\n'}
fi
fi
if [[ "$REPLY" =~ ^(.*)'"""'[:blank:]*$ ]]; then
opts+=${BASH_REMATCH[1]}
break
else
opts+=$REPLY$'\n'
fi
done
elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
opts=${BASH_REMATCH[1]}
elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
groups=${BASH_REMATCH[1]}
elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
arch=${BASH_REMATCH[1]}
elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then
check=${BASH_REMATCH[1]}
elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then
accel=${BASH_REMATCH[1]}
elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then
timeout=${BASH_REMATCH[1]}
fi
done
if [ -n "${testname}" ]; then
$(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout"
fi
exec {fd}<&-
}
function arch_cmd()
{
[ "${ARCH_CMD}" ] && echo "${ARCH_CMD}"
}
# The current file has to be the only file sourcing the arch helper
# file
ARCH_FUNC=scripts/${ARCH}/func.bash
if [ -f "${ARCH_FUNC}" ]; then
source "${ARCH_FUNC}"
fi