From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lucas Meneghel Rodrigues Subject: Re: [PATCH kvm-unittests v2 1/4] Add run_tests.sh Date: Fri, 12 Apr 2013 09:24:21 -0300 Message-ID: <1365769461.2470.4.camel@thinkpad-t420s> References: <1365766060-7604-1-git-send-email-kwolf@redhat.com> <1365766060-7604-2-git-send-email-kwolf@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, gleb@redhat.com, mtosatti@redhat.com To: Kevin Wolf Return-path: Received: from mx1.redhat.com ([209.132.183.28]:29915 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753805Ab3DLMYX (ORCPT ); Fri, 12 Apr 2013 08:24:23 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3CCONHD025538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 12 Apr 2013 08:24:23 -0400 In-Reply-To: <1365766060-7604-2-git-send-email-kwolf@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, 2013-04-12 at 13:27 +0200, Kevin Wolf wrote: > 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 ^ This looks good to me, although using python and the ConfigParser library would be less work (no need to explicitly use regexp based parsing). I'm currently taking a look at the new fields and how autotest could make use of them... Thanks!