From patchwork Wed Feb 16 06:16:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masami Hiramatsu X-Patchwork-Id: 543042 Delivered-To: patch@linaro.org Received: by 2002:ac0:e142:0:0:0:0:0 with SMTP id r2csp1090762imn; Tue, 15 Feb 2022 22:16:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJwW5nLdzKb5ep2pRkht/rBwweEL3ThSVbg+WajspwlH1l5DqP+Av2kKt4GA9wfkpew4mysv X-Received: by 2002:a17:906:bc46:b0:6cd:e855:18fc with SMTP id s6-20020a170906bc4600b006cde85518fcmr1016581ejv.263.1644992191079; Tue, 15 Feb 2022 22:16:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644992191; cv=none; d=google.com; s=arc-20160816; b=0Ef1acMTiHbXuutQdADPRf371hGQlG6kuliUYWm2xMpMVD0eCnx6QEw1ZaEc/DbLmy jWid8cs4tKRS3iLZvjiLVpHWiuOUDCjoZm7F8pkKNdIPIzHkFJzj3NoZoVILNASESDfP 61tJCHnMrpF/7xAKjIpD1VEVZAEZptLhic7wOWdvkTKTkdI5DhKPety6HQyIuxdquFdO k91dIORsAcnTTYpXBKNAWznPhCSiILMMT3t42QWBkEtEWu+ICbZ7Q19N3sSjtd8pTgtj hUJB3pQ8tDIpTfL00k/ilossx9mFV3zEporCEEW2KcscodDXnTlDccJtSkPsyE2xgHCP wWrQ== 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=bgxY9nSI15ZZyavE+mtMTVzzTw7FqNqYxwYLBLhJ0rU=; b=mxXkpEm3gPrZqVhrGqTMDAmQ+MvJHzC6wdBS5WNGCQsUsXXNgqUHCRFu7OHCquKEMf LtqDmqVZ8pq4sG01aFR+3jSQjamL6HsqahjuHKdZVKRFRvyQslivzbqRNW8qQj/+2JVx iSLKS2Y7aR4+YFOgkk6DMGJAcJiUtZ9WKNAGAK2slYj8cF+LsIg8v81Dx8dPTao6YfwH yj5sWzj4y4R1neYXgpsdxFvQvtBXpTftWpmefN4QgZn7M095izjqWo4cqpdPkeucYJ9F tLq5Bfhd2QhAy1UrpjvkQGKaTmlHNUZO5h3bEC2lys22C4eMK3HL0dE1O/1wsoX+0n3R BVXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Moqzu1ny; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id 11si18086054eje.845.2022.02.15.22.16.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:31 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Moqzu1ny; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 A9E3C8366F; Wed, 16 Feb 2022 07:16:29 +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="Moqzu1ny"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C9088839EC; Wed, 16 Feb 2022 07:16:26 +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-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (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 E551B83A6E for ; Wed, 16 Feb 2022 07:16:08 +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-pl1-x635.google.com with SMTP id c3so1232390pls.5 for ; Tue, 15 Feb 2022 22:16:08 -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=bgxY9nSI15ZZyavE+mtMTVzzTw7FqNqYxwYLBLhJ0rU=; b=Moqzu1ny0yby1JzeAc/DQOYe2pnwIyKDn2uUenuNwOWdTVtfGiNTpQpvDEgiEQnWCs goWrrJw613YuLhIu4JWvJUTwvtBp86GrWtxkVgss2shW6/SKRIJMZvzZzfvWzhdhjIPi elmsmkGsBmixR6cP/lzDAUeOsRYEsRaCizZhYLZgM1Q8ndg3Omyw0iGnJ3iAvK/kSK9B 1lBCAb/52MW4KYOZh2nnQIRS0yvMbwsS55N3xIXsa5qRJq3J+QD1s82SIAeN78WpW1z9 uI+hLYJtuO/ZCadPfgYyf25vRKtD7DdrPd+gOD0JxVz4orMWBWyJx6+cjiC7e7rZzs2M rrNw== 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=bgxY9nSI15ZZyavE+mtMTVzzTw7FqNqYxwYLBLhJ0rU=; b=Q0UQzXN7myinhg5h54m/+HKHqYP0PACUJEe9LyV5mUgFOC+EfKqedd4gUXtbIYm1JK 61jmyGasK2ve+m9Bl0DB0T5l92gHX7PJQaU6mbM7HwNqhad7myPRavvKhgKv+wYZFlS6 D8gi7nUpu3g9tO+2Rd6veeFZizGZIfOahOMCx0o9JgQZeKzH3EvrEpVtxDG4owd22UmZ bsHIUpuCl1b8WdfeHqGUDEyDAcZapY7YFKl2zZysaOPtYx2IMxluM1Nlhqj0AHq7dRiu 8t/APVTzt+0iXiwuHndIgBQXE6LbLYhEL9K++zqZgpJBH6Hts96GsHwJhi2fznzEZPI9 KoVQ== X-Gm-Message-State: AOAM5326v54oOx7D/sY5gQNQJ0hbIRzrNtFmE5PJalMi20SVg7DPCIPt j1zscgiB74F7A7ZZplKl6lle42YmN0JV/A== X-Received: by 2002:a17:90a:4308:b0:1b8:bed5:c747 with SMTP id q8-20020a17090a430800b001b8bed5c747mr85197pjg.0.1644992167102; Tue, 15 Feb 2022 22:16:07 -0800 (PST) Received: from localhost.localdomain (113x37x226x201.ap113.ftth.ucom.ne.jp. [113.37.226.201]) by smtp.gmail.com with ESMTPSA id e8sm25356960pfv.168.2022.02.15.22.16.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:16:06 -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 3/4] test/py: Handle expected reboot while booting sandbox Date: Wed, 16 Feb 2022 15:16:02 +0900 Message-Id: <164499216253.688621.5866897494911875372.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 expected_reset optional argument to ConsoleBase::ensure_spawned(), ConsoleBase::restart_uboot() and ConsoleSandbox::restart_uboot_with_flags() so that it can handle a reset while the 1st boot process after main boot logo before prompt correctly. Signed-off-by: Masami Hiramatsu --- Changes in v5: - Rename parameter to expect_reset and update the description to clarify the reset will happen between main boot and the command prompt. --- test/py/u_boot_console_base.py | 48 ++++++++++++++++++++++--------------- test/py/u_boot_console_sandbox.py | 7 ++++- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py index afae07d9cc..3938ec1302 100644 --- a/test/py/u_boot_console_base.py +++ b/test/py/u_boot_console_base.py @@ -139,7 +139,7 @@ class ConsoleBase(object): self.p.close() self.logstream.close() - def wait_for_boot_prompt(self): + def wait_for_boot_prompt(self, loop_num = 1): """Wait for the boot up until command prompt. This is for internal use only. """ try: @@ -149,22 +149,24 @@ class ConsoleBase(object): 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) + while loop_num > 0: + loop_num -= 1 + 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 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: ' + + 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]) self.u_boot_version_string = self.p.after while True: m = self.p.expect([self.prompt_compiled, @@ -372,7 +374,7 @@ class ConsoleBase(object): finally: self.p.timeout = orig_timeout - def ensure_spawned(self): + def ensure_spawned(self, expect_reset=False): """Ensure a connection to a correctly running U-Boot instance. This may require spawning a new Sandbox process or resetting target @@ -381,7 +383,9 @@ class ConsoleBase(object): This is an internal function and should not be called directly. Args: - None. + expect_reset: Boolean indication whether this boot is expected + to be reset while the 1st boot process after main boot before + prompt. False by default. Returns: Nothing. @@ -400,7 +404,11 @@ class ConsoleBase(object): if not self.config.gdbserver: self.p.timeout = 30000 self.p.logfile_read = self.logstream - self.wait_for_boot_prompt() + if expect_reset: + loop_num = 2 + else: + loop_num = 1 + self.wait_for_boot_prompt(loop_num = loop_num) self.at_prompt = True self.at_prompt_logevt = self.logstream.logfile.cur_evt except Exception as ex: @@ -433,10 +441,10 @@ class ConsoleBase(object): pass self.p = None - def restart_uboot(self): + def restart_uboot(self, expect_reset=False): """Shut down and restart U-Boot.""" self.cleanup_spawn() - self.ensure_spawned() + self.ensure_spawned(expect_reset) def get_spawn_output(self): """Return the start-up output from U-Boot diff --git a/test/py/u_boot_console_sandbox.py b/test/py/u_boot_console_sandbox.py index 7e1eb0e0b4..ce4ca7e55e 100644 --- a/test/py/u_boot_console_sandbox.py +++ b/test/py/u_boot_console_sandbox.py @@ -57,11 +57,14 @@ class ConsoleSandbox(ConsoleBase): cmd += self.sandbox_flags return Spawn(cmd, cwd=self.config.source_dir) - def restart_uboot_with_flags(self, flags): + def restart_uboot_with_flags(self, flags, expect_reset=False): """Run U-Boot with the given command-line flags Args: flags: List of flags to pass, each a string + expect_reset: Boolean indication whether this boot is expected + to be reset while the 1st boot process after main boot before + prompt. False by default. Returns: A u_boot_spawn.Spawn object that is attached to U-Boot. @@ -69,7 +72,7 @@ class ConsoleSandbox(ConsoleBase): try: self.sandbox_flags = flags - return self.restart_uboot() + return self.restart_uboot(expect_reset) finally: self.sandbox_flags = []