From patchwork Wed Mar 2 03:46:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 601761 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p223kEWC027152 for ; Wed, 2 Mar 2011 03:46:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757882Ab1CBDqL (ORCPT ); Tue, 1 Mar 2011 22:46:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63353 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757860Ab1CBDqK (ORCPT ); Tue, 1 Mar 2011 22:46:10 -0500 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 p223k9GK029096 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 1 Mar 2011 22:46:09 -0500 Received: from freedom.redhat.com (vpn-11-162.rdu.redhat.com [10.11.11.162]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p223k3CX017969; Tue, 1 Mar 2011 22:46:04 -0500 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues Subject: [PATCH] KVM test: Create a verify_kernel_crash() VM method Date: Wed, 2 Mar 2011 00:46:01 -0300 Message-Id: <1299037561-5613-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 02 Mar 2011 03:46:16 +0000 (UTC) diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py index 41f7491..ab60f71 100755 --- a/client/tests/kvm/kvm_vm.py +++ b/client/tests/kvm/kvm_vm.py @@ -105,6 +105,15 @@ class VMDeadError(VMError): (self.status, self.output)) +class VMDeadKernelCrashError(VMError): + def __init__(self, kernel_crash): + VMError.__init__(self, kernel_crash) + self.kernel_crash = kernel_crash + + def __str__(self): + return ("VM is dead due to a kernel crash: %s" % self.kernel_crash) + + class VMAddressError(VMError): pass @@ -1471,6 +1480,29 @@ class VM: return self.serial_login(internal_timeout) + def verify_kernel_crash(self, timeout=2): + """ + Find kernel crash message on serial console. + + @param timeout: Timeout used to verify expected output. + + @raise: VMDeadKernelCrashError, in case a kernel crash message was + found. + """ + data = self.serial_console.read_nonblocking() + match = re.search("BUG:", data, re.MULTILINE) + if match is not None: + match = re.search(r"BUG:.*---\[ end trace .* \]---", + data, re.DOTALL |re.MULTILINE) + if match is None: + data += self.serial_console.read_until_last_line_matches( + ["---\[ end trace .* \]---"], + timeout) + match = re.search(r"(BUG:.*---\[ end trace .* \]---)", + data, re.DOTALL |re.MULTILINE) + raise VMDeadKernelCrashError(match.group(0)) + + @error.context_aware def migrate(self, timeout=3600, protocol="tcp", cancel_delay=None, offline=False, stable_check=False, clean=True, diff --git a/client/tests/kvm/tests/unattended_install.py b/client/tests/kvm/tests/unattended_install.py index 7c6d845..955f8d6 100644 --- a/client/tests/kvm/tests/unattended_install.py +++ b/client/tests/kvm/tests/unattended_install.py @@ -33,6 +33,7 @@ def run_unattended_install(test, params, env): start_time = time.time() while (time.time() - start_time) < install_timeout: vm.verify_alive() + vm.verify_kernel_crash() client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: client.connect((vm.get_address(), port))