From patchwork Thu Jan 28 06:57:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 574556 X-Patchwork-Delegate: sjg@chromium.org 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 D33AE140A9A for ; Thu, 28 Jan 2016 17:59:22 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B50F0A75CA; Thu, 28 Jan 2016 07:59:00 +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 0MszdWm42b0I; Thu, 28 Jan 2016 07:59:00 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5FF57A75CD; Thu, 28 Jan 2016 07:58:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 86DE4A754C for ; Thu, 28 Jan 2016 07:58:17 +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 ZPzn4FFqC8LP for ; Thu, 28 Jan 2016 07:58:17 +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 avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 75E904BBD0 for ; Thu, 28 Jan 2016 07:58:12 +0100 (CET) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id F1AE76342; Wed, 27 Jan 2016 23:57:58 -0700 (MST) Received: from swarren-lx1.nvidia.com (localhost [127.0.0.1]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id CCBF7E4626; Wed, 27 Jan 2016 23:58:29 -0700 (MST) From: Stephen Warren To: Simon Glass Date: Wed, 27 Jan 2016 23:57:49 -0700 Message-Id: <1453964274-9129-4-git-send-email-swarren@wwwdotorg.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1453964274-9129-1-git-send-email-swarren@wwwdotorg.org> References: <1453964274-9129-1-git-send-email-swarren@wwwdotorg.org> X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.98.6 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: u-boot@lists.denx.de, Stephen Warren Subject: [U-Boot] [PATCH 4/9] test/py: check for bad patterns everywhere we wait 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" From: Stephen Warren Currently, bad patterns are only honored when executing a shell command. Other cases, such as the initial boot-up of U-Boot or when interacting with command output rather than gathering all output prior to the shell prompt, do not currently look for bad patterns in console output. This patch makes sure that bad patterns are honored everywhere. One benefit of this change is that if U-Boot sandbox fails to start up, the error message it emits can be caught immediately, rather than relying on a (long) timeout when waiting for the expected signon message and/or command prompt. Signed-off-by: Stephen Warren Acked-by: Simon Glass --- test/py/u_boot_console_base.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index efb06cad0af0..71a00e863385 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -231,7 +231,10 @@ class ConsoleBase(object): if type(text) == type(''): text = re.escape(text) - self.p.expect([text]) + m = self.p.expect([text] + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 1]) def drain_console(self): """Read from and log the U-Boot console for a short time. @@ -298,8 +301,14 @@ class ConsoleBase(object): self.p.timeout = 30000 self.p.logfile_read = self.logstream if self.config.buildconfig.get('CONFIG_SPL', False) == 'y': - self.p.expect([pattern_u_boot_spl_signon]) - self.p.expect([pattern_u_boot_main_signon]) + m = self.p.expect([pattern_u_boot_spl_signon] + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 1]) + m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 1]) signon = self.p.after build_idx = signon.find(', Build:') if build_idx == -1: @@ -307,12 +316,15 @@ class ConsoleBase(object): else: self.u_boot_version_string = signon[:build_idx] while True: - match = self.p.expect([self.prompt_escaped, - pattern_stop_autoboot_prompt]) - if match == 1: + m = self.p.expect([self.prompt_escaped, + pattern_stop_autoboot_prompt] + self.bad_patterns) + if m == 0: + break + if m == 1: self.p.send(chr(3)) # CTRL-C continue - break + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 2]) self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt except Exception as ex: