From patchwork Fri Apr 12 11:27:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 2434931 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 03F23DF2A1 for ; Fri, 12 Apr 2013 11:27:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755244Ab3DLL1s (ORCPT ); Fri, 12 Apr 2013 07:27:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49713 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754112Ab3DLL1r (ORCPT ); Fri, 12 Apr 2013 07:27:47 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3CBRlkk021127 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Apr 2013 07:27:47 -0400 Received: from dhcp-200-207.str.redhat.com (ovpn-116-52.ams2.redhat.com [10.36.116.52]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r3CBRhsM013167; Fri, 12 Apr 2013 07:27:45 -0400 From: Kevin Wolf To: kvm@vger.kernel.org Cc: kwolf@redhat.com, gleb@redhat.com, mtosatti@redhat.com, lmr@redhat.com Subject: [PATCH kvm-unittests v2 1/4] Add run_tests.sh Date: Fri, 12 Apr 2013 13:27:37 +0200 Message-Id: <1365766060-7604-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1365766060-7604-1-git-send-email-kwolf@redhat.com> References: <1365766060-7604-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org This adds a convenient way to run all tests without having to set up Autotest. Signed-off-by: Kevin Wolf --- run_tests.sh | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ x86-run | 9 +++- x86/unittests.cfg | 2 + 3 files changed, 132 insertions(+), 2 deletions(-) create mode 100755 run_tests.sh diff --git a/run_tests.sh b/run_tests.sh new file mode 100755 index 0000000..55ecac5 --- /dev/null +++ b/run_tests.sh @@ -0,0 +1,123 @@ +#!/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" + local arch="$6" + + if [ -z "$testname" ]; then + return + fi + + if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then + return + fi + + if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then + echo "skip $1 ($arch only)" + return + fi + + cmdline="./x86-run $kernel -smp $smp -display none $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 [ $? -le 1 ]; then + echo -e "\e[32mPASS\e[0m $1" + else + echo -e "\e[31mFAIL\e[0m $1" + fi +} + +function run_all() +{ + local config="$1" + local testname + local smp + local kernel + local opts + local groups + local arch + + exec {config_fd}<$config + + while read -u $config_fd line; do + if [[ "$line" =~ ^\[(.*)\]$ ]]; then + run "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" + testname=${BASH_REMATCH[1]} + smp=1 + kernel="" + opts="" + groups="" + arch="" + 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]} + elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then + arch=${BASH_REMATCH[1]} + fi + done + + run "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" + + 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 diff --git a/x86-run b/x86-run index e395a70..19e5dec 100755 --- a/x86-run +++ b/x86-run @@ -13,7 +13,7 @@ else qemu="${qemusystem}" else echo QEMU binary ${QEMU} has no support for test device. Exiting. - exit 1 + exit 2 fi fi @@ -24,4 +24,9 @@ then else command="${qemu} -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel" fi -exec ${command} "$@" + +echo ${command} "$@" +${command} "$@" +ret=$? +echo Return value from qemu: $ret +exit $ret diff --git a/x86/unittests.cfg b/x86/unittests.cfg index 5e08c55..7d0fa73 100644 --- a/x86/unittests.cfg +++ b/x86/unittests.cfg @@ -3,6 +3,8 @@ # file = foo.flat # Name of the flat file to be used # smp = 2 # Number of processors the VM will use during this test # extra_params = -cpu qemu64,+x2apic # Additional parameters used +# arch = i386/x86_64 # Only if the test case works only on one of them +# groups = group1 group2 # Used to identify test cases with run_tests -g ... [apic] file = apic.flat