@@ -118,15 +118,6 @@ variants:
- linux_s3: install setup
type = linux_s3
- - guest_s4:
- type = guest_s4
- check_s4_support_cmd = grep -q disk /sys/power/state
- test_s4_cmd = "cd /tmp/;nohup tcpdump -q -t ip host localhost"
- check_s4_cmd = pgrep tcpdump
- set_s4_cmd = echo disk > /sys/power/state
- kill_test_s4_cmd = pkill tcpdump
- services_up_timeout = 30
-
- timedrift: install setup
extra_params += " -rtc-td-hack"
variants:
@@ -166,7 +157,6 @@ variants:
used_cpus = 5
used_mem = 2560
-
- autoit: install setup
type = autoit
autoit_binary = D:\AutoIt3.exe
@@ -176,6 +166,15 @@ variants:
- notepad:
autoit_script = autoit/notepad1.au3
+ - guest_s4:
+ type = guest_s4
+ check_s4_support_cmd = grep -q disk /sys/power/state
+ test_s4_cmd = "cd /tmp; nohup tcpdump -q -t ip host localhost"
+ check_s4_cmd = pgrep tcpdump
+ set_s4_cmd = echo disk > /sys/power/state
+ kill_test_s4_cmd = pkill tcpdump
+ services_up_timeout = 30
+
- nic_hotplug: install setup
type = pci_hotplug
pci_type = nic
@@ -518,8 +517,8 @@ variants:
host_load_instances = 8
guest_s4:
check_s4_support_cmd = powercfg /hibernate on
- test_s4_cmd = start /B ping -n 3000 localhost
- check_s4_cmd = tasklist | find /I "ping"
+ test_s4_cmd = start ping -t localhost
+ check_s4_cmd = tasklist | find /I "ping.exe"
set_s4_cmd = rundll32.exe PowrProf.dll, SetSuspendState
kill_test_s4_cmd = taskkill /IM ping.exe /F
services_up_timeout = 30
@@ -5,7 +5,7 @@ import kvm_test_utils, kvm_utils
def run_guest_s4(test, params, env):
"""
- Suspend guest to disk,supports both Linux & Windows OSes.
+ Suspend guest to disk, supports both Linux & Windows OSes.
@param test: kvm test object.
@param params: Dictionary with test parameters.
@@ -14,53 +14,62 @@ def run_guest_s4(test, params, env):
vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
session = kvm_test_utils.wait_for_login(vm)
- logging.info("Checking whether guest OS supports suspend to disk (S4)")
+ logging.info("Checking whether guest OS supports suspend to disk (S4)...")
status = session.get_command_status(params.get("check_s4_support_cmd"))
if status is None:
logging.error("Failed to check if guest OS supports S4")
elif status != 0:
raise error.TestFail("Guest OS does not support S4")
- logging.info("Wait until all guest OS services are fully started")
- time.sleep(params.get("services_up_timeout"))
+ logging.info("Waiting until all guest OS services are fully started...")
+ time.sleep(float(params.get("services_up_timeout", 30)))
# Start up a program (tcpdump for linux & ping for Windows), as a flag.
# If the program died after suspend, then fails this testcase.
test_s4_cmd = params.get("test_s4_cmd")
session.sendline(test_s4_cmd)
+ time.sleep(5)
# Get the second session to start S4
session2 = kvm_test_utils.wait_for_login(vm)
+ # Make sure the background program is running as expected
check_s4_cmd = params.get("check_s4_cmd")
- if session2.get_command_status(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)
# Suspend to disk
- logging.info("Start suspend to disk now...")
+ logging.info("Starting suspend to disk now...")
session2.sendline(params.get("set_s4_cmd"))
- if not kvm_utils.wait_for(vm.is_dead, 360, 30, 2):
- raise error.TestFail("VM refuses to go down. Suspend failed")
- logging.info("VM suspended successfully. Wait before booting it again.")
+ # Make sure the VM goes down
+ if not kvm_utils.wait_for(vm.is_dead, 240, 2, 2):
+ raise error.TestFail("VM refuses to go down. Suspend failed.")
+ logging.info("VM suspended successfully. Sleeping for a while before "
+ "resuming it.")
time.sleep(10)
# Start vm, and check whether the program is still running
- logging.info("Start suspended VM...")
-
+ logging.info("Resuming suspended VM...")
if not vm.create():
raise error.TestError("Failed to start VM after suspend to disk")
- if not vm.is_alive():
- raise error.TestError("VM seems to be dead after it was suspended")
- # Check whether test command still alive
- logging.info("Checking if background command is still alive")
- if session2.get_command_status(check_s4_cmd):
- raise error.TestFail("Command %s failed. S4 failed" % test_s4_cmd)
+ # Log into the resumed VM
+ logging.info("Logging into resumed VM...")
+ session2 = kvm_utils.wait_for(vm.remote_login, 120, 0, 2)
+ if not session2:
+ raise error.TestFail("Could not log into VM after resuming from "
+ "suspend to disk")
+
+ # 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)
logging.info("VM resumed successfuly after suspend to disk")
- session2.sendline(params.get("kill_test_s4_cmd"))
+ session2.get_command_output(params.get("kill_test_s4_cmd"))
session.close()
session2.close()