From patchwork Sun Jul 3 15:40:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 643769 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3rjDt91Pjcz9sBR for ; Mon, 4 Jul 2016 01:42:25 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=jq6OSvQC; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id AAF2A4BA68; Sun, 3 Jul 2016 17:41:57 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eDd-CK5zMD0X; Sun, 3 Jul 2016 17:41:57 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4CA184B99D; Sun, 3 Jul 2016 17:41:33 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7FCCC4B656 for ; Sun, 3 Jul 2016 17:41:17 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pbtiPyPxedUJ for ; Sun, 3 Jul 2016 17:41:17 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-it0-f51.google.com (mail-it0-f51.google.com [209.85.214.51]) by theia.denx.de (Postfix) with ESMTPS id 166E64B698 for ; Sun, 3 Jul 2016 17:41:13 +0200 (CEST) Received: by mail-it0-f51.google.com with SMTP id g4so5748117ith.1 for ; Sun, 03 Jul 2016 08:41:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=5vGLmg/T+fUEq40m0mQnsvJH2wTTBfROWxCq+XTKAlg=; b=jq6OSvQC1lfcZc+BkqekzrT3NDxoJnhm20xVNxRxJtIDSNmKx4pn3bjaJRVjy+YG6n Jlhj/pOaP0xORt78jd1X11jLzwBvhrY14lGlmZRVJch1k/pg/hxhDTZcJ6n93+euzV0v aCZzUJL2pyssHXqzPZqpxtUl0DTkZex3dGEdk6JnUyEhBl9vd02FPWXBbsVg1hLO5vb2 iBgRZVBeFH09wgFnbNy3l9q1JCmGbqMj8ajkZaVBcA6T83b/1wYvLpqvYQ+kkW0/xpqo 6P0fm7AiCEbiGiIws7AnyUWwDk9INqZdCHm+OJN8tw3AIZ1/kGVSBLQSgTfcqx2u+uPa N5gA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=5vGLmg/T+fUEq40m0mQnsvJH2wTTBfROWxCq+XTKAlg=; b=DLX56UufZ4sWX/Ku/yFf8yVskJTjIiwnIpXnFXyGMGjoDxV0SH8KXynkQ2DR8LXYSr dW6Wjq2bJb/MedtUw8sMkjObPvMVU7EBvfbndPRqFXR3Rm5YUIFAyuvngEO651T+JvDQ SVN+Wd5Xif7aYYxU7JOXz7ETJY52u0qTbqJAiC1BnZ2ZiVUass3J1GkAtcFq3sXuLvHI LadzOnwAdJ10KNYguNr+R/4iYHmB75Kh2DM/qMa8Cvy0qXxSCDv47G+qvS65buvANNDF MlnewZIC3ikineMRoqIJPOpnGoN6MHDAVFAMEHcyzOVJC1RD9TsRezT36LBzBHssWXSC PCmw== X-Gm-Message-State: ALyK8tKdb5ent67+GY90sQ7yHxDaw9TXS1gg+gKMy8tVPvsgdIOGT2BnuTGQAfRooEClrP4X X-Received: by 10.36.107.88 with SMTP id v85mr5589292itc.51.1467560471952; Sun, 03 Jul 2016 08:41:11 -0700 (PDT) Received: from kaki.bld.corp.google.com ([100.100.202.57]) by smtp.gmail.com with ESMTPSA id e35sm1965277ioj.28.2016.07.03.08.41.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Jul 2016 08:41:11 -0700 (PDT) Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 5980C221424; Sun, 3 Jul 2016 09:41:09 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Sun, 3 Jul 2016 09:40:38 -0600 Message-Id: <1467560446-10628-7-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1467560446-10628-1-git-send-email-sjg@chromium.org> References: <1467560446-10628-1-git-send-email-sjg@chromium.org> Cc: Tom Rini , Stephen Warren Subject: [U-Boot] [PATCH 06/14] test/py: Provide output from exceptions with RunAndLog() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Tests may want to look at the output from running a command, even if it fails (e.g. with a non-zero return code). Provide a means to obtain this. Another approach would be to return a class object containing both the output and the exception, but I'm not sure if that would result in a lot of refactoring. Signed-off-by: Simon Glass Reviewed-by: Teddy Reed --- test/py/multiplexed_log.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/py/multiplexed_log.py b/test/py/multiplexed_log.py index 02c44df..35a32fb 100644 --- a/test/py/multiplexed_log.py +++ b/test/py/multiplexed_log.py @@ -101,6 +101,7 @@ class RunAndLog(object): self.logfile = logfile self.name = name self.chained_file = chained_file + self.output = None def close(self): """Clean up any resources managed by this object.""" @@ -109,6 +110,9 @@ class RunAndLog(object): def run(self, cmd, cwd=None, ignore_errors=False): """Run a command as a sub-process, and log the results. + The output is available at self.output which can be useful if there is + an exception. + Args: cmd: The command to execute. cwd: The directory to run the command in. Can be None to use the @@ -159,6 +163,9 @@ class RunAndLog(object): self.logfile.write(self, output) if self.chained_file: self.chained_file.write(output) + + # Store the output so it can be accessed if we raise an exception. + self.output = output if exception: raise exception return output