1#!/bin/bash 2 3if [ ! -f config.mak ]; then 4 echo "run ./configure && make first. See ./configure -h" 5 exit 6fi 7source config.mak 8source scripts/functions.bash 9 10config=$TEST_DIR/unittests.cfg 11qemu=${QEMU:-qemu-system-$ARCH} 12verbose=0 13 14function run() 15{ 16 local testname="$1" 17 local groups="$2" 18 local smp="$3" 19 local kernel="$4" 20 local opts="$5" 21 local arch="$6" 22 local check="$7" 23 local accel="$8" 24 25 if [ -z "$testname" ]; then 26 return 27 fi 28 29 if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then 30 return 31 fi 32 33 if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then 34 echo "skip $1 ($arch only)" 35 return 36 fi 37 38 # check a file for a particular value before running a test 39 # the check line can contain multiple files to check separated by a space 40 # but each check parameter needs to be of the form <path>=<value> 41 for check_param in ${check[@]}; do 42 path=${check_param%%=*} 43 value=${check_param#*=} 44 if [ "$path" ] && [ "$(cat $path)" != "$value" ]; then 45 echo "skip $1 ($path not equal to $value)" 46 return 47 fi 48 done 49 50 cmdline="TESTNAME=$testname ACCEL=$accel ./$TEST_DIR-run $kernel -smp $smp $opts" 51 if [ $verbose != 0 ]; then 52 echo $cmdline 53 fi 54 55 # extra_params in the config file may contain backticks that need to be 56 # expanded, so use eval to start qemu 57 eval $cmdline >> test.log 58 59 if [ $? -le 1 ]; then 60 echo -e "\e[32mPASS\e[0m $1" 61 else 62 echo -e "\e[31mFAIL\e[0m $1" 63 fi 64} 65 66function usage() 67{ 68cat <<EOF 69 70Usage: $0 [-g group] [-h] [-v] 71 72 -g: Only execute tests in the given group 73 -h: Output this help text 74 -v: Enables verbose mode 75 76Set the environment variable QEMU=/path/to/qemu-system-ARCH to 77specify the appropriate qemu binary for ARCH-run. 78 79EOF 80} 81 82echo > test.log 83while getopts "g:hv" opt; do 84 case $opt in 85 g) 86 only_group=$OPTARG 87 ;; 88 h) 89 usage 90 exit 91 ;; 92 v) 93 verbose=1 94 ;; 95 *) 96 exit 97 ;; 98 esac 99done 100 101# 102# Probe for MAX_SMP 103# 104MAX_SMP=$(getconf _NPROCESSORS_CONF) 105while ./$TEST_DIR-run _NO_FILE_4Uhere_ -smp $MAX_SMP \ 106 |& grep -q 'exceeds max cpus'; do 107 ((--MAX_SMP)) 108done 109 110for_each_unittest $config run 111