From patchwork Mon Mar 22 02:43:14 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 87327 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2M2iUJc010839 for ; Mon, 22 Mar 2010 02:44:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753808Ab0CVCo3 (ORCPT ); Sun, 21 Mar 2010 22:44:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38440 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753708Ab0CVCo1 (ORCPT ); Sun, 21 Mar 2010 22:44:27 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2M2iQmG028970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 21 Mar 2010 22:44:26 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2M2iQq0001659; Sun, 21 Mar 2010 22:44:26 -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 o2M2iMqG031710; Sun, 21 Mar 2010 22:44:25 -0400 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 2/5] KVM test: kvm.py: make sure all dump_env() calls are inside 'finally' blocks Date: Mon, 22 Mar 2010 04:43:14 +0200 Message-Id: <1269225797-11827-2-git-send-email-mgoldish@redhat.com> In-Reply-To: <1269225797-11827-1-git-send-email-mgoldish@redhat.com> References: <1269225797-11827-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 22 Mar 2010 02:44:31 +0000 (UTC) diff --git a/client/tests/kvm/kvm.py b/client/tests/kvm/kvm.py index 9b8a10c..c6e146d 100644 --- a/client/tests/kvm/kvm.py +++ b/client/tests/kvm/kvm.py @@ -21,6 +21,7 @@ class kvm(test.test): (Online doc - Getting started with KVM testing) """ version = 1 + def run_once(self, params): # Report the parameters we've received and write them as keyvals logging.debug("Test parameters:") @@ -33,7 +34,7 @@ class kvm(test.test): # Open the environment file env_filename = os.path.join(self.bindir, params.get("env", "env")) env = kvm_utils.load_env(env_filename, {}) - logging.debug("Contents of environment: %s" % str(env)) + logging.debug("Contents of environment: %s", str(env)) try: try: @@ -50,22 +51,30 @@ class kvm(test.test): f.close() # Preprocess - kvm_preprocessing.preprocess(self, params, env) - kvm_utils.dump_env(env, env_filename) + try: + kvm_preprocessing.preprocess(self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) # Run the test function run_func = getattr(test_module, "run_%s" % t_type) - run_func(self, params, env) - kvm_utils.dump_env(env, env_filename) + try: + run_func(self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) except Exception, e: logging.error("Test failed: %s", e) logging.debug("Postprocessing on error...") - kvm_preprocessing.postprocess_on_error(self, params, env) - kvm_utils.dump_env(env, env_filename) + try: + kvm_preprocessing.postprocess_on_error(self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) raise finally: # Postprocess - kvm_preprocessing.postprocess(self, params, env) - logging.debug("Contents of environment: %s", str(env)) - kvm_utils.dump_env(env, env_filename) + try: + kvm_preprocessing.postprocess(self, params, env) + finally: + kvm_utils.dump_env(env, env_filename) + logging.debug("Contents of environment: %s", str(env))