As while loops termination conditions are checked at
the beginning of the loop, if we successfuly log onto
the vm on the last cycle, but the timeout happened
to be ended by then, we'd have a test failure.

So, introduce a variable that records whether the
test managed to log onto the VM, and use this variable
as the criteria for PASS/FAIL.

Signed-off-by: Lucas Meneghel Rodrigues <l...@redhat.com>
---
 client/tests/kvm/tests/boot_savevm.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/tests/boot_savevm.py 
b/client/tests/kvm/tests/boot_savevm.py
index 91199fb..d02463d 100644
--- a/client/tests/kvm/tests/boot_savevm.py
+++ b/client/tests/kvm/tests/boot_savevm.py
@@ -21,6 +21,7 @@ def run_boot_savevm(test, params, env):
     savevm_login_delay = float(params.get("savevm_login_delay"))
     end_time = time.time() + float(params.get("savevm_timeout"))
 
+    successful_login = False
     while time.time() < end_time:
         time.sleep(savevm_delay)
         try:
@@ -46,10 +47,11 @@ def run_boot_savevm(test, params, env):
 
         try:
             vm.wait_for_login(timeout=savevm_login_delay)
+            successful_login = True
             break
         except Exception, detail:
             logging.debug(detail)
 
-    if (time.time() > end_time):
+    if not successful_login:
         raise error.TestFail("Not possible to log onto the vm after %s s" %
                              params.get("savevm_timeout"))
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to