From patchwork Wed Feb 16 06:15:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543041 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090637imn; Tue, 15 Feb 2022 22:16:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJywUDo0AyK/GzOhCSQ46cqfgUiG18lezRR4NwX5YhRAsIKuKQEVK4F80iSVNYSRdLHpAI3G X-Received: by 2002:a05:6402:349:b0:410:a0bd:35ad with SMTP id r9-20020a056402034900b00410a0bd35admr1342481edw.12.1644992177020; Tue, 15 Feb 2022 22:16:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992177; cv=none; d=google.com; s=arc-20160816; b=kpuV6KrCuuu1x7Tvl8kpSpelDuiCp43dxQUGb8xc8PekSolsbpW4L3JscYtkVsZDNi oNV0hCCG7hB99SfnDJ/hp7+n6OFS3aRe7cFjagMvm/8NOwq4nd9HtDvSiFFh2vrzOJTE Kjkp+rUSqPa/bLrkitxNBN8y9SVf135vyrKXZUZBOiuZOZN1Iz/vC50tUjrhoIIXlMVS 3ZeIxT11gZMU3IRCyovr3Nk6YylZkFX0zpl9MIRI/CI8H5tF0H7BlCGyKZmC0URBQ+W7 cdbOjmthlQDpcjrj/Slb9sx6CBaJQ6GMF3NZJvPh1FJjEJ+IzmtTsDl4X1e7F365PZdc RU1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=gvU4w67g5o/oDmUQA8J5u0oVm1JiCU+boU2O6MKmaVc=; b=gA101X+DYO41y+cBTs+TU2aOckX4j0fk4/JryiOVsbbUO3FxOvknaREUVd1V0HU4tX NFD3Q+WQoSADlVBbwAz7J5dIpMCGIQZ6lZe3HMZQgdi8GyeJzVcOHbBsa7Br9VGyo3LF 7cjHhufBDoAvIc/mvc5omZGovUjzguKTuLI8xrClVh3aWf3C2oVUNQeyvbMucMECsueO xYW4bEAaiTQ0DkPrNYEMrhz+4HvnULuD3sXRsVHIOX70bKa0RYVxeODx4yVFuGS4qzIa S9utRZcoMmtAdORGqQyokG/I3ZvXUeRKcXiOwY0bDEyl+L33qp5HVnGe9Ft9lPuPaNGU 3M7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sb7WV8yh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id he34si4061269ejc.18.2022.02.15.22.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:17 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sb7WV8yh; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 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-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 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: