diff mbox

[KVM-AUTOTEST,v3,11/11] KVM test: use error.context() in guest_s4

Message ID 1294426091-16704-11-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Jan. 7, 2011, 6:48 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py
index 7f61c33..5641654 100644
--- a/client/tests/kvm/tests/guest_s4.py
+++ b/client/tests/kvm/tests/guest_s4.py
@@ -3,6 +3,7 @@  from autotest_lib.client.common_lib import error
 import kvm_test_utils, kvm_utils
 
 
+@error.context_aware
 def run_guest_s4(test, params, env):
     """
     Suspend guest to disk, supports both Linux & Windows OSes.
@@ -11,13 +12,15 @@  def run_guest_s4(test, params, env):
     @param params: Dictionary with test parameters.
     @param env: Dictionary with the test environment.
     """
+    error.base_context("before S4")
     vm = env.get_vm(params["main_vm"])
     vm.verify_alive()
     timeout = int(params.get("login_timeout", 360))
     session = vm.wait_for_login(timeout=timeout)
 
-    logging.info("Checking whether guest OS supports suspend to disk (S4)...")
+    error.context("checking whether guest OS supports S4", logging.info)
     session.cmd(params.get("check_s4_support_cmd"))
+    error.context()
 
     logging.info("Waiting until all guest OS services are fully started...")
     time.sleep(float(params.get("services_up_timeout", 30)))
@@ -32,15 +35,19 @@  def run_guest_s4(test, params, env):
     session2 = vm.wait_for_login(timeout=timeout)
 
     # Make sure the background program is running as expected
+    error.context("making sure background program is running")
     check_s4_cmd = params.get("check_s4_cmd")
     session2.cmd(check_s4_cmd)
     logging.info("Launched background command in guest: %s" % test_s4_cmd)
+    error.context()
+    error.base_context()
 
     # Suspend to disk
     logging.info("Starting suspend to disk now...")
     session2.sendline(params.get("set_s4_cmd"))
 
     # Make sure the VM goes down
+    error.base_context("after S4")
     suspend_timeout = 240 + int(params.get("smp")) * 60
     if not kvm_utils.wait_for(vm.is_dead, suspend_timeout, 2, 2):
         raise error.TestFail("VM refuses to go down. Suspend failed.")
@@ -58,8 +65,10 @@  def run_guest_s4(test, params, env):
     session2 = vm.wait_for_login(timeout=relogin_timeout)
 
     # Check whether the test command is still alive
-    logging.info("Checking if background command is still alive...")
+    error.context("making sure background program is still running",
+                  logging.info)
     session2.cmd(check_s4_cmd)
+    error.context()
 
     logging.info("VM resumed successfuly after suspend to disk")
     session2.cmd_output(params.get("kill_test_s4_cmd"))