From: Lucas Meneghel Rodrigues Subject: Re: [Autotest] [PATCH] KVM-Test: Add kvm userspace unit test Date: Sat, 20 Mar 2010 17:14:18 -0300 Message-ID: <6ac58f4f1003201314s603fe3cesefab4922ca1eebb5@mail.gmail.com> References: <1267770155-12900-1-git-send-email-sshang@redhat.com> <6ac58f4f1003172016mea5c1acr20e0000349303d55@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: autotest@test.kernel.org, kvm@vger.kernel.org, Michael Goldish , nsprei@redhat.com To: sshang Return-path: Received: from mail-ww0-f46.google.com ([74.125.82.46]:37804 "EHLO mail-ww0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407Ab0CTUOV convert rfc822-to-8bit (ORCPT ); Sat, 20 Mar 2010 16:14:21 -0400 Received: by wwe15 with SMTP id 15so2482198wwe.19 for ; Sat, 20 Mar 2010 13:14:20 -0700 (PDT) In-Reply-To: <6ac58f4f1003172016mea5c1acr20e0000349303d55@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: I have an update about this test after talking to Naphtali Sprei: This patch does the unit testing using the old way of invoking it, and Avi superseded it with a new -kernel option. Naphtali is working in making the new way of doing the test work, so I will wait until we can merge both ways of doing this test, OK? On Thu, Mar 18, 2010 at 12:16 AM, Lucas Meneghel Rodrigues wrote: > Hi Shuxi, sorry that it took so long before I could give you return o= n this one. > > The general idea is just fine, but there is one gotcha that will need > more thought: This is dependent of having the KVM source code for > testing (ie, it depends on the build test *and* the build mode has to > involve source code, such as git builds, things like koji install wil= l > also not work). Since by default we are not making the tests dependin= g > directly on build, so we have to figure out a way to have this > integrated without breaking things for users who are not interested t= o > run the build test. > > Today I was reviewing the qemu-img functional test, so it occurred to > me that all those tests that do not depend on guests and different > qemu command line options, we can make them all dependent on the buil= d > test. This way we'd have the separation that we need, still not > breaking anything for users that do not care about build and other > types of test. > > Michael, what do you think? Should we put the config of tests like > this one and qemu_img on build.cfg, making them depend on build? > > Oh Shuxi, on the code below I have some small comments to make: > > On Fri, Mar 5, 2010 at 3:22 AM, sshang wrote: >> =A0The test use kvm test harness kvmctl load binary test case file t= o test various function of kvm kernel module. >> >> Signed-off-by: sshang >> --- >> =A0client/tests/kvm/tests/unit_test.py =A0 =A0| =A0 29 +++++++++++++= ++++++++++++++++ >> =A0client/tests/kvm/tests_base.cfg.sample | =A0 =A07 +++++++ >> =A02 files changed, 36 insertions(+), 0 deletions(-) >> =A0create mode 100644 client/tests/kvm/tests/unit_test.py >> >> diff --git a/client/tests/kvm/tests/unit_test.py b/client/tests/kvm/= tests/unit_test.py >> new file mode 100644 >> index 0000000..9bc7441 >> --- /dev/null >> +++ b/client/tests/kvm/tests/unit_test.py >> @@ -0,0 +1,29 @@ >> +import os >> +from autotest_lib.client.bin import utils >> +from autotest_lib.client.common_lib import error >> + >> +def run_unit_test(test, params, env): >> + =A0 =A0""" >> + =A0 =A0This is kvm userspace unit test, use kvm test harness kvmct= l load binary >> + =A0 =A0test case file to test various function of kvm kernel modul= e. >> + =A0 =A0The output of all unit test can be found in the test result= dir. >> + =A0 =A0""" >> + >> + =A0 =A0case_list =3D params.get("case_list","access apic emulator = hypercall irq"\ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0" port80 realmode sieve smptest tsc str= ingio vmexit").split() >> + =A0 =A0srcdir =3D params.get("srcdir",test.srcdir) >> + =A0 =A0user_dir =3D os.path.join(srcdir,"kvm_userspace/kvm/user") >> + =A0 =A0os.chdir(user_dir) >> + =A0 =A0test_fail_list =3D [] >> + >> + =A0 =A0for i in case_list: >> + =A0 =A0 =A0 =A0result_file =3D test.outputdir + "/" + i >> + =A0 =A0 =A0 =A0testfile =3D i + ".flat" >> + =A0 =A0 =A0 =A0results =3D utils.system("./kvmctl test/x86/bootstr= ap test/x86/" + \ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 testfile + " > " + result_= file,ignore_status=3DTrue) > > About the above statement: In general you should not use shell > redirection to write the output of your program to the log files. > Please take advantage of the fact utils.run allow you to connect > stdout and stderr pipes to the result file. Also, utils.run return a > CmdResult object, hat has a list of useful properties out of it. > >> + =A0 =A0 =A0 =A0if results !=3D 0: >> + =A0 =A0 =A0 =A0 =A0 =A0test_fail_list.append(i) >> + >> + =A0 =A0if test_fail_list: >> + =A0 =A0 =A0 =A0raise error.TestFail("< " + " ".join(test_fail_list= ) + \ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= " >") > > In the above, you could just have used > > =A0 =A0 =A0 =A0raise error.TestFail("KVM module unit test failed. Tes= t cases > failed: %s" % test_fail_list) > > IMHO it's easier to understand. > >> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/k= vm/tests_base.cfg.sample >> index 040d0c3..0918c26 100644 >> --- a/client/tests/kvm/tests_base.cfg.sample >> +++ b/client/tests/kvm/tests_base.cfg.sample >> @@ -300,6 +300,13 @@ variants: >> =A0 =A0 =A0 =A0 shutdown_method =3D shell >> =A0 =A0 =A0 =A0 kill_vm =3D yes >> =A0 =A0 =A0 =A0 kill_vm_gracefully =3D no >> + >> + =A0 =A0- unit_test: >> + =A0 =A0 =A0 =A0type =3D unit_test >> + =A0 =A0 =A0 =A0case_list =3D access apic emulator hypercall msr po= rt80 realmode sieve smptest tsc stringio vmexit >> + =A0 =A0 =A0 =A0#srcdir should be same as build.cfg >> + =A0 =A0 =A0 =A0srcdir =3D >> + =A0 =A0 =A0 =A0vms =3D '' >> =A0 =A0 # Do not define test variants below shutdown >> >> >> -- >> 1.5.5.6 >> >> _______________________________________________ >> Autotest mailing list >> Autotest@test.kernel.org >> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest >> > > > > -- > Lucas > --=20 Lucas