From patchwork Sat Nov 5 16:45:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Stefan_Br=C3=BCns?= X-Patchwork-Id: 691583 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 3tB4N82LPGz9vF0 for ; Sun, 6 Nov 2016 03:46:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 9B72AA7559; Sat, 5 Nov 2016 17:46:04 +0100 (CET) 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 5h3tBRWKCSMs; Sat, 5 Nov 2016 17:46:04 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6845AA7574; Sat, 5 Nov 2016 17:45:56 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 592F04B98B for ; Sat, 5 Nov 2016 17:45:48 +0100 (CET) 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 gii2gS_d0STF for ; Sat, 5 Nov 2016 17:45:48 +0100 (CET) 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 mx-out-2.rwth-aachen.de (mx-out-2.rwth-aachen.de [134.130.5.187]) by theia.denx.de (Postfix) with ESMTPS id 23B854B68A for ; Sat, 5 Nov 2016 17:45:48 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.31,597,1473112800"; d="scan'208";a="468252635" Received: from rwthex-w2-b.rwth-ad.de ([134.130.26.159]) by mx-2.rz.rwth-aachen.de with ESMTP; 05 Nov 2016 17:45:43 +0100 Received: from pebbles.fritz.box (77.181.89.255) by rwthex-w2-b.rwth-ad.de (2002:8682:1a9f::8682:1a9f) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Sat, 5 Nov 2016 17:45:40 +0100 From: =?UTF-8?q?Stefan=20Br=C3=BCns?= To: Date: Sat, 5 Nov 2016 17:45:33 +0100 X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161105164534.26836-1-stefan.bruens@rwth-aachen.de> References: <20161105164534.26836-1-stefan.bruens@rwth-aachen.de> MIME-Version: 1.0 X-Originating-IP: [77.181.89.255] X-ClientProxiedBy: rwthex-s2-b.rwth-ad.de (2002:8682:1a9b::8682:1a9b) To rwthex-w2-b.rwth-ad.de (2002:8682:1a9f::8682:1a9f) Message-ID: <52fc650813aa4b498604a816e879f67e@rwthex-w2-b.rwth-ad.de> Cc: Stephen Warren Subject: [U-Boot] [PATCH 2/3] test/py: Allow to pass u_boot_log instead of console for run_and_log 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The runner actually has no console dependency, only on the log provided by the console. Accept both u_boot_console or a multiplexed_log. Signed-off-by: Stefan BrĂ¼ns --- test/py/u_boot_utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/py/u_boot_utils.py b/test/py/u_boot_utils.py index 2ba4bae..c80cf07 100644 --- a/test/py/u_boot_utils.py +++ b/test/py/u_boot_utils.py @@ -153,7 +153,7 @@ def wait_until_file_open_fails(fn, ignore_errors): return raise Exception('File can still be opened') -def run_and_log(u_boot_console, cmd, ignore_errors=False): +def run_and_log(u_boot_console_or_log, cmd, ignore_errors=False): """Run a command and log its output. Args: @@ -171,7 +171,10 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): """ if isinstance(cmd, str): cmd = cmd.split() - runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) + try: + runner = u_boot_console_or_log.get_runner(cmd[0], sys.stdout) + except: + runner = u_boot_console_or_log.log.get_runner(cmd[0], sys.stdout) output = runner.run(cmd, ignore_errors=ignore_errors) runner.close() return output @@ -189,7 +192,10 @@ def run_and_log_expect_exception(u_boot_console, cmd, retcode, msg): msg: String that should be contained within the command's output. """ try: + runner = u_boot_console.get_runner(cmd[0], sys.stdout) + except: runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) + try: runner.run(cmd) except Exception as e: assert(retcode == runner.exit_status)