From: Michael Goldish Subject: [KVM-AUTOTEST PATCH 4/4] KVM test: boot test: change the scope of the try-finally statement Date: Mon, 14 Sep 2009 11:46:48 +0300 Message-ID: <1252918008-2742-4-git-send-email-mgoldish@redhat.com> References: <1252918008-2742-1-git-send-email-mgoldish@redhat.com> <1252918008-2742-2-git-send-email-mgoldish@redhat.com> <1252918008-2742-3-git-send-email-mgoldish@redhat.com> Cc: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:1143 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754712AbZINIty (ORCPT ); Mon, 14 Sep 2009 04:49:54 -0400 In-Reply-To: <1252918008-2742-3-git-send-email-mgoldish@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: It's possible for the test to fail when there's no shell session to close, and then session.close() in the finally clause raises a TypeError. Signed-off-by: Michael Goldish --- client/tests/kvm/kvm_tests.py | 15 +++++++-------- 1 files changed, 7 insertions(+), 8 deletions(-) diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index 446b415..43a6291 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -44,18 +44,17 @@ def run_boot(test, params, env): 120, 0, 1): raise error.TestFail("Guest refuses to go down") + finally: session.close() - logging.info("Guest is down; waiting for it to go up again...") - - session = kvm_utils.wait_for(vm.remote_login, 240, 0, 2) - if not session: - raise error.TestFail("Could not log into guest after reboot") + logging.info("Guest is down; waiting for it to go up again...") - logging.info("Guest is up again") + session = kvm_utils.wait_for(vm.remote_login, 240, 0, 2) + if not session: + raise error.TestFail("Could not log into guest after reboot") + session.close() - finally: - session.close() + logging.info("Guest is up again") def run_shutdown(test, params, env): -- 1.5.4.1