diff mbox

[1/2] KVM test: Create a verify_kernel_crash() VM method v3

Message ID 1300481908-4931-1-git-send-email-lmr@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues March 18, 2011, 8:58 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_vm.py b/client/tests/kvm/kvm_vm.py
index 43ae79c..8114670 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:\n%s" % self.kernel_crash)
+
+
 class VMAddressError(VMError):
     pass
 
@@ -1158,6 +1167,20 @@  class VM:
         return not self.process or not self.process.is_alive()
 
 
+    def verify_kernel_crash(self):
+        """
+        Find kernel crash message on the VM serial console.
+
+        @raise: VMDeadKernelCrashError, in case a kernel crash message was
+                found.
+        """
+        data = self.serial_console.get_output()
+        match = re.search(r"BUG:.*---\[ end trace .* \]---", data,
+                          re.DOTALL|re.MULTILINE)
+        if match is not None:
+            raise VMDeadKernelCrashError(match.group(0))
+
+
     def get_params(self):
         """
         Return the VM's params dict. Most modified params take effect only