From: Lucas Meneghel Rodrigues Subject: [PATCH 1/4] KVM test: Avoid race condition on boot_savevm Date: Wed, 30 Nov 2011 19:11:00 -0200 Message-ID: <1322687463-9924-1-git-send-email-lmr@redhat.com> Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues To: autotest@test.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:32047 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752493Ab1K3VLo (ORCPT ); Wed, 30 Nov 2011 16:11:44 -0500 Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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