From patchwork Mon Jan 3 18:34:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 448911 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 p03IXixt027593 for ; Mon, 3 Jan 2011 18:33:45 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754763Ab1ACSdl (ORCPT ); Mon, 3 Jan 2011 13:33:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1214 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754742Ab1ACSdk (ORCPT ); Mon, 3 Jan 2011 13:33:40 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p03IXen1008913 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 3 Jan 2011 13:33:40 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p03IXdNg007485; Mon, 3 Jan 2011 13:33:39 -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 p03IXWvx027804; Mon, 3 Jan 2011 13:33:38 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 5/7] [RFC] Set the .context attribute for exceptions in _call_test_function() Date: Mon, 3 Jan 2011 20:34:09 +0200 Message-Id: <1294079651-21631-5-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294079651-21631-1-git-send-email-mgoldish@redhat.com> References: <1294079651-21631-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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]); Mon, 03 Jan 2011 18:33:46 +0000 (UTC) diff --git a/client/common_lib/test.py b/client/common_lib/test.py index 2561242..9521326 100644 --- a/client/common_lib/test.py +++ b/client/common_lib/test.py @@ -596,13 +596,17 @@ def _call_test_function(func, *args, **dargs): inside test code are considered test failures.""" try: return func(*args, **dargs) - except error.AutotestError: - # Pass already-categorized errors on up as is. - raise + except error.AutotestError, e: + # Inject context info and pass already-categorized errors on up. + e.context = error.get_context(sys.exc_info()[2]) + raise sys.exc_info()[0], e, sys.exc_info()[2] except Exception, e: - # Other exceptions must be treated as a FAIL when - # raised during the test functions - raise error.UnhandledTestFail(e) + # Other exceptions are treated as a FAIL when raised during the test + # functions. Convert them to UnhandledTestFail, inject context info + # and pass them on up. + e = error.UnhandledTestFail(e) + e.context = error.get_context(sys.exc_info()[2]) + raise e def runtest(job, url, tag, args, dargs,