Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Unified Diff: client/tests/kvm/tests/guest_s4.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/tests/kvm/tests/guest_s4.py
diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py
index 2eb035be30cae9e2b2fa2ce41f218766a656664c..efd8e3bf9a8d4d23d77fe812e96aa5284cc75c1f 100644
--- a/client/tests/kvm/tests/guest_s4.py
+++ b/client/tests/kvm/tests/guest_s4.py
@@ -1,8 +1,9 @@
import logging, time
from autotest_lib.client.common_lib import error
-import kvm_test_utils, kvm_utils
+import kvm_utils
+@error.context_aware
def run_guest_s4(test, params, env):
"""
Suspend guest to disk, supports both Linux & Windows OSes.
@@ -11,16 +12,15 @@ def run_guest_s4(test, params, env):
@param params: Dictionary with test parameters.
@param env: Dictionary with the test environment.
"""
- vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+ error.base_context("before S4")
+ vm = env.get_vm(params["main_vm"])
+ vm.verify_alive()
timeout = int(params.get("login_timeout", 360))
- session = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+ session = vm.wait_for_login(timeout=timeout)
- logging.info("Checking whether guest OS supports suspend to disk (S4)...")
- s, o = session.get_command_status_output(params.get("check_s4_support_cmd"))
- if "not enough space" in o:
- raise error.TestError("Check S4 support failed: %s" % o)
- elif s != 0:
- raise error.TestNAError("Guest OS does not support 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,20 +32,22 @@ def run_guest_s4(test, params, env):
time.sleep(5)
# Get the second session to start S4
- session2 = kvm_test_utils.wait_for_login(vm, timeout=timeout)
+ 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")
- if session2.get_command_status(check_s4_cmd) != 0:
- raise error.TestError("Failed to launch '%s' as a background process" %
- test_s4_cmd)
- logging.info("Launched background command in guest: %s" % test_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.")
@@ -55,24 +57,20 @@ def run_guest_s4(test, params, env):
# Start vm, and check whether the program is still running
logging.info("Resuming suspended VM...")
- if not vm.create():
- raise error.TestError("Failed to start VM after suspend to disk")
+ vm.create()
# Log into the resumed VM
relogin_timeout = int(params.get("relogin_timeout", 240))
logging.info("Logging into resumed VM, timeout %s", relogin_timeout)
- session2 = kvm_utils.wait_for(vm.remote_login, relogin_timeout, 0, 2)
- if not session2:
- raise error.TestFail("Could not log into VM after resuming from "
- "suspend to disk")
+ 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...")
- if session2.get_command_status(check_s4_cmd) != 0:
- raise error.TestFail("Background command '%s' stopped running. S4 "
- "failed." % test_s4_cmd)
+ 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.get_command_output(params.get("kill_test_s4_cmd"))
+ session2.cmd_output(params.get("kill_test_s4_cmd"))
session.close()
session2.close()

Powered by Google App Engine
This is Rietveld 408576698