1: "${RUNTIME_arch_run?}" 2: ${MAX_SMP:=$(getconf _NPROCESSORS_CONF)} 3: ${TIMEOUT:=90s} 4 5PASS() { echo -ne "\e[32mPASS\e[0m"; } 6SKIP() { echo -ne "\e[33mSKIP\e[0m"; } 7FAIL() { echo -ne "\e[31mFAIL\e[0m"; } 8 9function run() 10{ 11 local testname="$1" 12 local groups="$2" 13 local smp="$3" 14 local kernel="$4" 15 local opts="$5" 16 local arch="$6" 17 local check="${CHECK:-$7}" 18 local accel="${ACCEL:-$8}" 19 local timeout="${9:-$TIMEOUT}" # unittests.cfg overrides the default 20 21 if [ -z "$testname" ]; then 22 return 23 fi 24 25 if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then 26 return 27 fi 28 29 if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then 30 echo "`SKIP` $1 ($arch only)" 31 return 2 32 fi 33 34 # check a file for a particular value before running a test 35 # the check line can contain multiple files to check separated by a space 36 # but each check parameter needs to be of the form <path>=<value> 37 for check_param in ${check[@]}; do 38 path=${check_param%%=*} 39 value=${check_param#*=} 40 if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then 41 echo "`SKIP` $1 ($path not equal to $value)" 42 return 2 43 fi 44 done 45 46 cmdline="TESTNAME=$testname TIMEOUT=$timeout ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts" 47 if [ "$verbose" = "yes" ]; then 48 echo $cmdline 49 fi 50 51 # extra_params in the config file may contain backticks that need to be 52 # expanded, so use eval to start qemu 53 eval $cmdline 54 ret=$? 55 56 if [ $ret -eq 0 ]; then 57 echo "`PASS` $1" 58 elif [ $ret -eq 77 ]; then 59 echo "`SKIP` $1" 60 elif [ $ret -eq 124 ]; then 61 echo "`FAIL` $1 (timeout; duration=$timeout)" 62 else 63 echo "`FAIL` $1" 64 fi 65 66 return $ret 67} 68 69# 70# Probe for MAX_SMP, in case it's less than the number of host cpus. 71# 72# This probing currently only works for ARM, as x86 bails on another 73# error first. Also, this probing isn't necessary for any ARM hosts 74# running kernels later than v4.3, i.e. those including ef748917b52 75# "arm/arm64: KVM: Remove 'config KVM_ARM_MAX_VCPUS'". So, at some 76# point when maintaining the while loop gets too tiresome, we can 77# just remove it... 78while $RUNTIME_arch_run _NO_FILE_4Uhere_ -smp $MAX_SMP \ 79 |& grep -qi 'exceeds max CPUs'; do 80 ((--MAX_SMP)) 81done 82