All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yolkfull Chow <yzhou@redhat.com>
To: kvm@vger.kernel.org
Cc: autotest@test.kernel.org, Yolkfull Chow <yzhou@redhat.com>,
	Ken Cao <kcao@redhat.com>
Subject: [PATCH] Add a kvm test guest_s4 which supports both Linux and Windows platform
Date: Sun, 27 Sep 2009 17:11:36 +0800	[thread overview]
Message-ID: <1254042696-16487-1-git-send-email-yzhou@redhat.com> (raw)

For this case, Ken Cao wrote the linux part previously and I did extensive
modifications on Windows platform support.

Signed-off-by: Ken Cao <kcao@redhat.com>
Signed-off-by: Yolkfull Chow <yzhou@redhat.com>
---
 client/tests/kvm/kvm_tests.cfg.sample |   14 +++++++
 client/tests/kvm/tests/guest_s4.py    |   66 +++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100644 client/tests/kvm/tests/guest_s4.py

diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 285a38f..f9ecb61 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -94,6 +94,14 @@ 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
+
     - timedrift:    install setup
         type = timedrift
         extra_params += " -rtc-td-hack"
@@ -382,6 +390,12 @@ variants:
             # Alternative host load:
             #host_load_command = "dd if=/dev/urandom of=/dev/null"
             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"
+            set_s4_cmd = rundll32.exe PowrProf.dll, SetSuspendState
+            kill_test_s4_cmd = taskkill /IM ping.exe /F
 
         variants:
             - Win2000:
diff --git a/client/tests/kvm/tests/guest_s4.py b/client/tests/kvm/tests/guest_s4.py
new file mode 100644
index 0000000..5d8fbdf
--- /dev/null
+++ b/client/tests/kvm/tests/guest_s4.py
@@ -0,0 +1,66 @@
+import logging, time
+from autotest_lib.client.common_lib import error
+import kvm_test_utils, kvm_utils
+
+
+def run_guest_s4(test, params, env):
+    """
+    Suspend guest to disk,supports both Linux & Windows OSes.
+
+    @param test: kvm test object.
+    @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"))
+    session = kvm_test_utils.wait_for_login(vm)
+
+    logging.info("Checking whether VM supports S4")
+    status = session.get_command_status(params.get("check_s4_support_cmd"))
+    if status is None:
+        logging.error("Failed to check if S4 exists")
+    elif status != 0:
+        raise error.TestFail("Guest does not support S4")
+
+    logging.info("Waiting for a while for X to start...")
+    time.sleep(10)
+
+    # Start up a program(tcpdump for linux OS & ping for M$ OS), 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)
+
+    # Get the second session to start S4
+    session2 = kvm_test_utils.wait_for_login(vm)
+    
+    check_s4_cmd = params.get("check_s4_cmd")
+    if session2.get_command_status(check_s4_cmd):
+        raise error.TestError("Failed to launch %s background" % test_s4_cmd)
+    logging.info("Launched command background in guest: %s" % test_s4_cmd)
+    
+    # Implement S4
+    logging.info("Start 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 refuse to go down,suspend failed")
+    logging.info("VM suspended successfully.")
+
+    logging.info("VM suspended to disk. sleep 10 seconds to have a break...")
+    time.sleep(10)
+
+    # Start vm, and check whether the program is still running
+    logging.info("Restart VM now...")
+
+    if not vm.create():
+        raise error.TestError("failed to start the vm again.")
+    if not vm.is_alive():
+        raise error.TestError("VM seems to be dead; Test requires a live VM.")
+
+    # Check whether test command still alive
+    if session2.get_command_status(check_s4_cmd):
+        raise error.TestFail("%s died, indicating that S4 failed" % test_s4_cmd)
+
+    logging.info("VM resumed after S4")
+    session2.sendline(params.get("kill_test_s4_cmd"))
+    session.close()
+    session2.close()
-- 
1.6.2.5


             reply	other threads:[~2009-09-27  9:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-27  9:11 Yolkfull Chow [this message]
2009-10-13 20:29 ` [Autotest] [PATCH] Add a kvm test guest_s4 which supports both Linux and Windows platform Lucas Meneghel Rodrigues
2009-10-14  2:54   ` Yolkfull Chow
2009-10-14  9:58     ` Lucas Meneghel Rodrigues
2009-10-14 10:09       ` Yolkfull Chow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1254042696-16487-1-git-send-email-yzhou@redhat.com \
    --to=yzhou@redhat.com \
    --cc=autotest@test.kernel.org \
    --cc=kcao@redhat.com \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.