From patchwork Thu Oct 15 10:13:56 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 54003 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9FAN5BK025773 for ; Thu, 15 Oct 2009 10:23:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758093AbZJOKRj (ORCPT ); Thu, 15 Oct 2009 06:17:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756903AbZJOKRj (ORCPT ); Thu, 15 Oct 2009 06:17:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26733 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755933AbZJOKRh (ORCPT ); Thu, 15 Oct 2009 06:17:37 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9FAH6ME017061; Thu, 15 Oct 2009 06:17:07 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9FAH64I003285; Thu, 15 Oct 2009 06:17:06 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n9FAH1x2004569; Thu, 15 Oct 2009 06:17:04 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/3] KVM test: corrections to guest_s4 Date: Thu, 15 Oct 2009 12:13:56 +0200 Message-Id: <1255601637-6355-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1255601637-6355-1-git-send-email-mgoldish@redhat.com> References: <1255601637-6355-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample index 9ccc9b5..296449d 100644 --- a/client/tests/kvm/kvm_tests.cfg.sample +++ b/client/tests/kvm/kvm_tests.cfg.sample @@ -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 diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py index 7147e3b..f08b9d2 100644 --- a/client/tests/kvm/tests/guest_s4.py +++ b/client/tests/kvm/tests/guest_s4.py @@ -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()