1source config.mak 2 3function for_each_unittest() 4{ 5 local unittests="$1" 6 local cmd="$2" 7 local testname 8 local smp 9 local kernel 10 local test_args 11 local opts 12 local groups 13 local arch 14 local machine 15 local check 16 local accel 17 local timeout 18 local rematch 19 20 exec {fd}<"$unittests" 21 22 while read -r -u $fd line; do 23 if [[ "$line" =~ ^\[(.*)\]$ ]]; then 24 rematch=${BASH_REMATCH[1]} 25 if [ -n "${testname}" ]; then 26 $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" 27 fi 28 testname=$rematch 29 smp=1 30 kernel="" 31 test_args="" 32 opts="" 33 groups="" 34 arch="" 35 machine="" 36 check="" 37 accel="" 38 timeout="" 39 elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then 40 kernel=$TEST_DIR/${BASH_REMATCH[1]} 41 elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then 42 smp=${BASH_REMATCH[1]} 43 elif [[ $line =~ ^test_args\ *=\ *(.*)$ ]]; then 44 test_args=${BASH_REMATCH[1]} 45 elif [[ $line =~ ^(extra_params|qemu_params)\ *=\ *'"""'(.*)$ ]]; then 46 opts=${BASH_REMATCH[2]}$'\n' 47 while read -r -u $fd; do 48 #escape backslash newline, but not double backslash 49 if [[ $opts =~ [^\\]*(\\*)$'\n'$ ]]; then 50 if (( ${#BASH_REMATCH[1]} % 2 == 1 )); then 51 opts=${opts%\\$'\n'} 52 fi 53 fi 54 if [[ "$REPLY" =~ ^(.*)'"""'[:blank:]*$ ]]; then 55 opts+=${BASH_REMATCH[1]} 56 break 57 else 58 opts+=$REPLY$'\n' 59 fi 60 done 61 elif [[ $line =~ ^(extra_params|qemu_params)\ *=\ *(.*)$ ]]; then 62 opts=${BASH_REMATCH[2]} 63 elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then 64 groups=${BASH_REMATCH[1]} 65 elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then 66 arch=${BASH_REMATCH[1]} 67 elif [[ $line =~ ^machine\ *=\ *(.*)$ ]]; then 68 machine=${BASH_REMATCH[1]} 69 elif [[ $line =~ ^check\ *=\ *(.*)$ ]]; then 70 check=${BASH_REMATCH[1]} 71 elif [[ $line =~ ^accel\ *=\ *(.*)$ ]]; then 72 accel=${BASH_REMATCH[1]} 73 elif [[ $line =~ ^timeout\ *=\ *(.*)$ ]]; then 74 timeout=${BASH_REMATCH[1]} 75 fi 76 done 77 if [ -n "${testname}" ]; then 78 $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout" 79 fi 80 exec {fd}<&- 81} 82 83function arch_cmd() 84{ 85 [ "${ARCH_CMD}" ] && echo "${ARCH_CMD}" 86} 87 88# The current file has to be the only file sourcing the arch helper 89# file. Shellcheck can't follow this so help it out. There doesn't appear to be a 90# way to specify multiple alternatives, so we will have to rethink this if things 91# get more complicated. 92ARCH_FUNC=scripts/${ARCH}/func.bash 93if [ -f "${ARCH_FUNC}" ]; then 94# shellcheck source=scripts/s390x/func.bash 95 source "${ARCH_FUNC}" 96fi 97