From patchwork Wed Jan 5 15:45:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 453771 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p05FjOuE016604 for ; Wed, 5 Jan 2011 15:45:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751942Ab1AEPpW (ORCPT ); Wed, 5 Jan 2011 10:45:22 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21085 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751338Ab1AEPpV (ORCPT ); Wed, 5 Jan 2011 10:45:21 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p05FjKdR026187 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 5 Jan 2011 10:45:21 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p05FjKCN026352; Wed, 5 Jan 2011 10:45:20 -0500 Received: from moof.tlv.redhat.com (dhcp-1-185.tlv.redhat.com [10.35.1.185]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p05FjBQL027486; Wed, 5 Jan 2011 10:45:19 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH v2 6/6] [RFC] KVM test: use error.context() in kvm_preprocessing.py Date: Wed, 5 Jan 2011 17:45:29 +0200 Message-Id: <1294242329-11034-6-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294242329-11034-1-git-send-email-mgoldish@redhat.com> References: <1294242329-11034-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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 (demeter1.kernel.org [140.211.167.41]); Wed, 05 Jan 2011 15:45:28 +0000 (UTC) diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py index 5ce0a3b..e5b8906 100644 --- a/client/tests/kvm/kvm_preprocessing.py +++ b/client/tests/kvm/kvm_preprocessing.py @@ -39,6 +39,7 @@ def preprocess_image(test, params): raise error.TestError("Could not create image") +@error.context_aware def preprocess_vm(test, params, env, name): """ Preprocess a single VM object according to the instructions in params. @@ -49,7 +50,8 @@ def preprocess_vm(test, params, env, name): @param env: The environment (a dict-like object). @param name: The name of the VM object. """ - logging.debug("Preprocessing VM '%s'..." % name) + error.context("preprocessing '%s'" % name) + vm = env.get_vm(name) if vm: logging.debug("VM object found in environment") @@ -104,6 +106,7 @@ def postprocess_image(test, params): kvm_vm.remove_image(params, test.bindir) +@error.context_aware def postprocess_vm(test, params, env, name): """ Postprocess a single VM object according to the instructions in params. @@ -114,7 +117,7 @@ def postprocess_vm(test, params, env, name): @param env: The environment (a dict-like object). @param name: The name of the VM object. """ - logging.debug("Postprocessing VM '%s'..." % name) + error.context("postprocessing '%s'" % name) vm = env.get_vm(name) if vm: logging.debug("VM object found in environment") @@ -187,6 +190,7 @@ def process(test, params, env, image_func, vm_func): vm_func(test, vm_params, env, vm_name) +@error.context_aware def preprocess(test, params, env): """ Preprocess all VMs and images according to the instructions in params. @@ -196,6 +200,8 @@ def preprocess(test, params, env): @param params: A dict containing all VM and image parameters. @param env: The environment (a dict-like object). """ + error.context("preprocessing") + # Start tcpdump if it isn't already running if "address_cache" not in env: env["address_cache"] = {} @@ -274,6 +280,7 @@ def preprocess(test, params, env): _screendump_thread.start() +@error.context_aware def postprocess(test, params, env): """ Postprocess all VMs and images according to the instructions in params. @@ -282,6 +289,8 @@ def postprocess(test, params, env): @param params: Dict containing all VM and image parameters. @param env: The environment (a dict-like object). """ + error.context("postprocessing") + # Postprocess all VMs and images process(test, params, env, postprocess_image, postprocess_vm)