From: Kevin Wolf Subject: [PATCH kvm-unit-tests 1/4] Add run_tests.sh Date: Mon, 23 Jan 2012 17:07:10 +0100 Message-ID: <1327334833-31650-2-git-send-email-kwolf@redhat.com> References: <1327334833-31650-1-git-send-email-kwolf@redhat.com> Cc: kwolf@redhat.com, kvm@vger.kernel.org To: avi@redhat.com Return-path: Received: from mx1.redhat.com ([209.132.183.28]:34653 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981Ab2AWQDv (ORCPT ); Mon, 23 Jan 2012 11:03:51 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q0NG3p1K017129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 23 Jan 2012 11:03:51 -0500 In-Reply-To: <1327334833-31650-1-git-send-email-kwolf@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: This adds a convenient way to run all tests without having to set up Autotest. Signed-off-by: Kevin Wolf --- run_tests.sh | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 107 insertions(+), 0 deletions(-) create mode 100755 run_tests.sh diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..8d152b0 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +testroot=x86 +config=$testroot/unittests.cfg +qemu=${qemu:-qemu-system-x86_64} +verbose=0 + +function run() +{ + local testname="$1" + local groups="$2" + local smp="$3" + local kernel="$4" + local opts="$5" + + if [ -z "$testname" ]; then + return + fi + + if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then + return + fi + + cmdline="$qemu -display none -enable-kvm -device testdev,chardev=testlog -chardev stdio,id=testlog -kernel $kernel -smp $smp $opts" + if [ $verbose != 0 ]; then + echo $cmdline + fi + + # extra_params in the config file may contain backticks that need to be + # expanded, so use eval to start qemu + eval $cmdline >> test.log + + if [ $? == 0 ]; then + echo PASS $1 + else + echo FAIL $1 + fi +} + +function run_all() +{ + local config="$1" + local testname + local smp + local kernel + local opts + local groups + + exec {config_fd}<$config + + while read -u $config_fd line; do + if [[ "$line" =~ ^\[(.*)\]$ ]]; then + run "$testname" "$groups" "$smp" "$kernel" "$opts" + testname=${BASH_REMATCH[1]} + smp=1 + kernel="" + opts="" + groups="" + elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then + kernel=$testroot/${BASH_REMATCH[1]} + elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then + smp=${BASH_REMATCH[1]} + elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then + opts=${BASH_REMATCH[1]} + elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then + groups=${BASH_REMATCH[1]} + fi + done + + run "$testname" "$groups" "$smp" "$kernel" "$opts" + + exec {config_fd}<&- +} + +function usage() +{ +cat < test.log +while getopts "g:hv" opt; do + case $opt in + g) + only_group=$OPTARG + ;; + h) + usage + exit + ;; + v) + verbose=1 + ;; + *) + exit + ;; + esac +done + +run_all $config -- 1.7.6.5