diff mbox

[KVM-AUTOTEST] KVM test: timedrift: pass parameters to the get_time() helper function

Message ID 90183a035ae6e0fd5e63af51ce63102f576326a9.1249686169.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Aug. 7, 2009, 11:03 p.m. UTC
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_tests.py |   17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 8cc89f1..e678039 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -630,10 +630,16 @@  def run_timedrift(test, params, env):
         for tid, mask in prev_masks.items():
             commands.getoutput("taskset -p %s %s" % (mask, tid))
 
-    def get_time():
+    def get_time(session, time_command, time_filter_re, time_format):
         """
         Returns the host time and guest time.
 
+        @param session: A shell session.
+        @param time_command: Command to issue to get the current guest time.
+        @param time_filter_re: Regex filter to apply on the output of
+                time_command in order to get the current time.
+        @param time_format: Format string to pass to time.strptime() with the
+                result of the regex filter.
         @return: A tuple containing the host time and guest time.
         """
         host_time = time.time()
@@ -685,7 +691,8 @@  def run_timedrift(test, params, env):
 
     try:
         # Get time before load
-        (host_time_0, guest_time_0) = get_time()
+        (host_time_0, guest_time_0) = get_time(session, time_command,
+                                               time_filter_re, time_format)
 
         # Run some load on the guest
         logging.info("Starting load on guest...")
@@ -719,7 +726,8 @@  def run_timedrift(test, params, env):
         time.sleep(load_duration)
 
         # Get time delta after load
-        (host_time_1, guest_time_1) = get_time()
+        (host_time_1, guest_time_1) = get_time(session, time_command,
+                                               time_filter_re, time_format)
 
         # Report results
         host_delta = host_time_1 - host_time_0
@@ -747,7 +755,8 @@  def run_timedrift(test, params, env):
     time.sleep(rest_duration)
 
     # Get time after rest
-    (host_time_2, guest_time_2) = get_time()
+    (host_time_2, guest_time_2) = get_time(session, time_command,
+                                           time_filter_re, time_format)
 
     # Report results
     host_delta_total = host_time_2 - host_time_0