From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Michael S. Tsirkin" Subject: Re: [PATCH] kvm-unit-test: more documentation and runner script Date: Wed, 27 Feb 2013 22:44:16 +0200 Message-ID: <20130227204416.GB26956@redhat.com> References: <20130227155557.GA23629@redhat.com> <512E4BF9.5090704@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org, gleb@redhat.com To: Lucas Meneghel Rodrigues Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48639 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005Ab3B0UoB (ORCPT ); Wed, 27 Feb 2013 15:44:01 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r1RKi17K021306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 27 Feb 2013 15:44:01 -0500 Content-Disposition: inline In-Reply-To: <512E4BF9.5090704@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Wed, Feb 27, 2013 at 03:10:01PM -0300, Lucas Meneghel Rodrigues wrote: > On 02/27/2013 12:55 PM, Michael S. Tsirkin wrote: > >Add documentation about using qemu-system for unit tests. > >Add runner script to select the correct binary and flags. > > > >Signed-off-by: Michael S. Tsirkin > >--- > > README | 10 +++++++++- > > x86-run | 27 +++++++++++++++++++++++++++ > > 2 files changed, 36 insertions(+), 1 deletion(-) > > create mode 100755 x86-run > > > >diff --git a/README b/README > >index 4ceb869..214397c 100644 > >--- a/README > >+++ b/README > >@@ -10,10 +10,18 @@ To create the tests' images just type 'make' in this directory. > > Tests' images created in .//*.flat > > > > An example of a test invocation: > >-qemu-system-x86_64 -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel ./x86/msr.flat > >+Using qemu-kvm: > >+ > >+qemu-kvm -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel ./x86/msr.flat > > This invocation runs the msr test case. The test outputs to stdio. > > > >+Using qemu (supported since qemu 1.3): > >+qemu-system-x86_64 -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel ./x86/msr.flat > > I think it is worth here to point out that with new qemu, after the > unittest is done, the exit status of qemu is 1, different from the > 'old style', whose exit status in successful completion is 0. > > >+Or use a runner script to detect the correct invocation: > >+./x86-run ./x86/msr.flat > >+To select a specific qemu binary, specify the QEMU= environment: > >+QEMU=/tmp/qemu/x86_64-softmmu/qemu-system-x86_64 ./x86-run ./x86/msr.flat > > > > Directory structure: > > .: Makefile and config files for the tests > >diff --git a/x86-run b/x86-run > >new file mode 100755 > >index 0000000..cf1d38a > >--- /dev/null > >+++ b/x86-run > >@@ -0,0 +1,27 @@ > >+#!/usr/bin/bash > >+ > >+qemukvm="${QEMU:-qemu-kvm}" > >+qemusystem="${QEMU:-qemu-system-x86_64}" > >+if > >+ ${qemukvm} -device '?' 2>&1 | fgrep -e \"testdev\" -e \"pc-testdev\" > /dev/null; > >+then > >+ qemu="${qemukvm}" > >+else > >+ if > >+ ${qemsystem} -device '?' 2>&1 | fgrep -e \"testdev\" -e \"pc-testdev\" > /dev/null; > >+ then > >+ qemu="${qemusystem}" > >+ else > >+ echo QEMU binary ${QEMU} has no support for test device. Exiting. > >+ exit 1 > >+ fi > >+fi > >+ > >+if > >+ ${qemu} -device '?' 2>&1 | fgrep "pc-testdev" > /dev/null; > >+then > >+ command="${qemu} -enable-kvm -device pc-testdev -serial stdio -device isa-debug-exit,iobase=0xf4,iosize=0x4 -kernel" > >+else > >+ command="${qemu} -device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out -serial stdio -kernel ./x86/msr.flat" > >+fi > >+exec ${command} "$@" > > ^ What about checking the exit status of qemu here and print > something like "test $@ PASS" or "test $@ FAIL"? How do we know how to interpret it? Overall I think it's best to rely on test output than on return status. -- MST