From patchwork Mon Sep 14 08:46:48 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 47259 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n8E8o1uj022052 for ; Mon, 14 Sep 2009 08:50:01 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754983AbZINIt4 (ORCPT ); Mon, 14 Sep 2009 04:49:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754926AbZINItz (ORCPT ); Mon, 14 Sep 2009 04:49:55 -0400 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 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8nvXV007891; Mon, 14 Sep 2009 04:49:57 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8nv6Y013913; Mon, 14 Sep 2009 04:49:57 -0400 Received: from localhost.localdomain (dhcp-1-188.tlv.redhat.com [10.35.1.188]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n8E8nocM018130; Mon, 14 Sep 2009 04:49:55 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: 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> In-Reply-To: <1252918008-2742-3-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> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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):