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