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