Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2428BC433EF for ; Wed, 16 Feb 2022 06:16:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EC0A683A3C; Wed, 16 Feb 2022 07:16:15 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Sb7WV8yh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C4E7283A3C; Wed, 16 Feb 2022 07:16:12 +0100 (CET) Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 2748983A5C for ; Wed, 16 Feb 2022 07:15:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masami.hiramatsu@linaro.org Received: by mail-pf1-x432.google.com with SMTP id c4so1324034pfl.7 for ; Tue, 15 Feb 2022 22:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=gvU4w67g5o/oDmUQA8J5u0oVm1JiCU+boU2O6MKmaVc=; b=Sb7WV8yhoEQDIKRO+HezUvDACKAo3m+/CSozdLvlcTtcaRqLQ1FaevHzUwOHDLh4NT Br2Nkx8tdxla1fGKIOrjRaYWjEGlg3prS1WEp1Ekgd7JTXQy1FtGFbPaPh4+ikQQvYZP /JESOVgweuA05wTFRdJuql3SvPfRth9KVazLU8swA60CIZ9Jn4yoeo7gW+DSKRhhJbjh wwF5E0SGnJaB7XiRxrWcNB/Mp4KPpq9nwbesb+xB1Sz5Yhtky2B0kaXGi1w0VgOe3iEO aiLZEbyOEyDyD2J3JX/T/TGXZW4NM+SgqsnHT7eCniUq2EMSldY/EUTG282vAQyE1eKZ LqsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=gvU4w67g5o/oDmUQA8J5u0oVm1JiCU+boU2O6MKmaVc=; b=GcJq24FXpSEABzzkWfmw25xksBmOLLFPMbzgepnxOyHitfp2cCmZzilSPpz9wilee0 XeaY2Xu4hf1QJBoROc50PqAhxFNEB9E/KhiQvZF4bHwk8t+V8mRFl9NPM0v1CWYkGtjR TD3dClNg8f0vXQuQQeXKRTnzo0/gNVRsFlvcSMwCtjRg32IMS3OudzP/5CuSxCr5V4bw h5R+zLaGPCwTjDHyusheoEtuHGP9u5AfPiyZEsXbFJ1ERDBTFRZ/uKevqlLrlLfJHjek rrG9dJD9U0oTYcxmuBprty2Ds8o7BzMmOQOlP7zXm0iyAFn7nvM+nBav/xEsdN0xXNEE on9g== X-Gm-Message-State: AOAM532WJ4mXyBhVKSVgpWAR6UeFu2cjI+EMhNB6j2QRhlooWio4iKY/ p2FROeYu5AzLmYg7pfIlMYbg7Zt+pPvc8Q== X-Google-Smtp-Source: ABdhPJxXg+JuhSMbCXyiGP3cQdlW4wBENel5RmvtK/SxCOCDYDjovgM3aH8U6Ela0QefL0bRLTgQtQ== X-Received: by 2002:a63:f053:0:b0:364:cff3:55f8 with SMTP id s19-20020a63f053000000b00364cff355f8mr1009882pgj.578.1644992157125; Tue, 15 Feb 2022 22:15:57 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id i3sm4284702pgq.65.2022.02.15.22.15.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:15:56 -0800 (PST) From: Masami Hiramatsu To: u-boot@lists.denx.de Cc: Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Heinrich Schuchardt , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu , Paul Liu Subject: [PATCH v5 2/4] test/py: Handle expected reset by command Date: Wed, 16 Feb 2022 15:15:52 +0900 Message-Id: <164499215201.688621.12198458581018156227.stgit@localhost> X-Mailer: git-send-email 2.25.1 In-Reply-To: <164499213192.688621.17382243642029677399.stgit@localhost> References: <164499213192.688621.17382243642029677399.stgit@localhost> User-Agent: StGit/0.19 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Add wait_for_reboot optional argument to ConsoleBase::run_command() so that it can handle an expected reset by command execution. This is useful if a command will reset the sandbox while testing such commands, e.g. run_command("reset", wait_for_reboot = True) Signed-off-by: Masami Hiramatsu --- Changes in v5: - Split the wait-for-boot-prompt code as an internal function so that it is able to be shared with ensure_spawned(). - Fix wait_for_reboot parameter description. --- test/py/u_boot_console_base.py | 99 +++++++++++++++++++++++----------------- 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index 384fd53c65..afae07d9cc 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -139,8 +139,53 @@ class ConsoleBase(object): self.p.close() self.logstream.close() + def wait_for_boot_prompt(self): + """Wait for the boot up until command prompt. This is for internal use only. + """ + try: + bcfg = self.config.buildconfig + config_spl = bcfg.get('config_spl', 'n') == 'y' + config_spl_serial = bcfg.get('config_spl_serial', 'n') == 'y' + env_spl_skipped = self.config.env.get('env__spl_skipped', False) + env_spl2_skipped = self.config.env.get('env__spl2_skipped', True) + + if config_spl and config_spl_serial and not env_spl_skipped: + m = self.p.expect([pattern_u_boot_spl_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL console: ' + + self.bad_pattern_ids[m - 1]) + if not env_spl2_skipped: + m = self.p.expect([pattern_u_boot_spl2_signon] + + self.bad_patterns) + if m != 0: + raise Exception('Bad pattern found on SPL2 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]) + self.u_boot_version_string = self.p.after + while True: + m = self.p.expect([self.prompt_compiled, + pattern_stop_autoboot_prompt] + self.bad_patterns) + if m == 0: + break + if m == 1: + self.p.send(' ') + continue + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 2]) + + except Exception as ex: + self.log.error(str(ex)) + self.cleanup_spawn() + raise + finally: + self.log.timestamp() + def run_command(self, cmd, wait_for_echo=True, send_nl=True, - wait_for_prompt=True): + wait_for_prompt=True, wait_for_reboot=False): """Execute a command via the U-Boot console. The command is always sent to U-Boot. @@ -168,6 +213,9 @@ class ConsoleBase(object): wait_for_prompt: Boolean indicating whether to wait for the command prompt to be sent by U-Boot. This typically occurs immediately after the command has been executed. + wait_for_reboot: Boolean indication whether to wait for the + reboot U-Boot. If this sets True, wait_for_prompt must also + be True. Returns: If wait_for_prompt == False: @@ -202,11 +250,14 @@ class ConsoleBase(object): self.bad_pattern_ids[m - 1]) if not wait_for_prompt: return - m = self.p.expect([self.prompt_compiled] + self.bad_patterns) - if m != 0: - self.at_prompt = False - raise Exception('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 1]) + if wait_for_reboot: + self.wait_for_boot_prompt() + else: + m = self.p.expect([self.prompt_compiled] + self.bad_patterns) + if m != 0: + self.at_prompt = False + raise Exception('Bad pattern found on console: ' + + self.bad_pattern_ids[m - 1]) self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt # Only strip \r\n; space/TAB might be significant if testing @@ -349,41 +400,7 @@ class ConsoleBase(object): if not self.config.gdbserver: self.p.timeout = 30000 self.p.logfile_read = self.logstream - bcfg = self.config.buildconfig - config_spl = bcfg.get('config_spl', 'n') == 'y' - config_spl_serial = bcfg.get('config_spl_serial', - 'n') == 'y' - env_spl_skipped = self.config.env.get('env__spl_skipped', - False) - env_spl2_skipped = self.config.env.get('env__spl2_skipped', - True) - if config_spl and config_spl_serial and not env_spl_skipped: - m = self.p.expect([pattern_u_boot_spl_signon] + - self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on SPL console: ' + - self.bad_pattern_ids[m - 1]) - if not env_spl2_skipped: - m = self.p.expect([pattern_u_boot_spl2_signon] + - self.bad_patterns) - if m != 0: - raise Exception('Bad pattern found on SPL2 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]) - self.u_boot_version_string = self.p.after - while True: - m = self.p.expect([self.prompt_compiled, - pattern_stop_autoboot_prompt] + self.bad_patterns) - if m == 0: - break - if m == 1: - self.p.send(' ') - continue - raise Exception('Bad pattern found on console: ' + - self.bad_pattern_ids[m - 2]) + self.wait_for_boot_prompt() self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt except Exception as ex: