From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jason Wang Subject: Re: [PATCH v2 10/10] KVM test: Add a helper to search the panic in the log Date: Mon, 17 May 2010 15:28:58 +0800 Message-ID: <4BF0F03A.7060207@redhat.com> References: <20100511083338.19914.7719.stgit@localhost.localdomain> <20100511090431.19914.24287.stgit@localhost.localdomain> <4BEA786C.5090301@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Cc: lmr@redhat.com, autotest@test.kernel.org, kvm@vger.kernel.org To: Michael Goldish Return-path: Received: from mx1.redhat.com ([209.132.183.28]:30582 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752159Ab0EQHYA (ORCPT ); Mon, 17 May 2010 03:24:00 -0400 In-Reply-To: <4BEA786C.5090301@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Michael Goldish wrote: > On 05/11/2010 12:04 PM, Jason Wang wrote: > >> This checker serves as the post_command to find the panic information >> in the file which contains the content of guest serial console. >> >> Signed-off-by: Jason Wang >> --- >> client/tests/kvm/scripts/check_serial.py | 41 ++++++++++++++++++++++++++++++ >> client/tests/kvm/tests_base.cfg.sample | 7 ++++- >> 2 files changed, 46 insertions(+), 2 deletions(-) >> create mode 100644 client/tests/kvm/scripts/check_serial.py >> >> diff --git a/client/tests/kvm/scripts/check_serial.py b/client/tests/kvm/scripts/check_serial.py >> new file mode 100644 >> index 0000000..969bbe3 >> --- /dev/null >> +++ b/client/tests/kvm/scripts/check_serial.py >> @@ -0,0 +1,41 @@ >> +import os, sys, glob, re >> + >> + >> +class SerialCheckerError(Exception): >> + """ >> + Simple wrapper for the builtin Exception class. >> + """ >> + pass >> + >> + >> +class SerialChecker(object): >> + """ >> + Serach the panic or other keywords in the guest serial. >> + """ >> + def __init__(self): >> + """ >> + Gets params from environment variables and sets class attributes. >> + """ >> + client_dir = os.environ['AUTODIR'] >> + self.pattern = os.environ['KVM_TEST_search_pattern'] >> + self.shortname = os.environ['KVM_TEST_shortname'] >> + self.debugdir = os.path.join(client_dir, "results/default/kvm.%s/debug" \ >> > > I think the final backslash is unnecessary. > > >> + % self.shortname) >> + self.serial_files = glob.glob(os.path.join(self.debugdir, 'serial*')) >> + >> + >> + def check(self): >> + """ >> + Check whether the pattern were found in the serial files >> + """ >> + fail = [ f for f in self.serial_files if >> + re.findall(self.pattern, file(f).read(), re.I) ] >> + if fail: >> + print "%s is found in %s" % (self.pattern, fail) >> + raise SerialCheckerError("Error found during the check, Please" \ >> > > Same here. > > >> + " check the log") >> + >> + >> +if __name__ == "__main__": >> + checker = SerialChecker() >> + checker.check() >> > > I wonder why we need a class. Why not just put all the code here? > > Just follow the style of other pre_command, maybe Lucas like it. >> diff --git a/client/tests/kvm/tests_base.cfg.sample b/client/tests/kvm/tests_base.cfg.sample >> index 3c0933e..3ac8f0d 100644 >> --- a/client/tests/kvm/tests_base.cfg.sample >> +++ b/client/tests/kvm/tests_base.cfg.sample >> @@ -52,6 +52,10 @@ address_index = 0 >> # Misc >> profilers = kvm_stat >> >> +# pattern serach in guest serial console >> +serach_pattern = panic >> +post_command = "python scripts/check_serial.py" >> +post_command_noncritical = no >> >> # Tests >> variants: >> @@ -1314,10 +1318,9 @@ virtio|virtio_blk|e1000|balloon_check: >> variants: >> - @qcow2: >> image_format = qcow2 >> - post_command = " python scripts/check_image.py;" >> + post_command = " python scripts/check_image.py; python scripts/check_serial.py" >> > ^ > This should be +=, because post_command may have been previously > assigned some value. > > Would change it, and do you have any other comments about this patchset? >> remove_image = no >> post_command_timeout = 600 >> - post_command_noncritical = yes >> - vmdk: >> only Fedora Ubuntu Windows >> only smp2 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe kvm" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> > > -- > To unsubscribe from this list: send the line "unsubscribe kvm" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >