From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>
Subject: [PATCH v6 12/19] test: Introduce lab mode
Date: Fri, 20 Sep 2024 08:01:47 +0200 [thread overview]
Message-ID: <20240920060158.106612-13-sjg@chromium.org> (raw)
In-Reply-To: <20240920060158.106612-1-sjg@chromium.org>
There is quite a bit of code in pytest to try to start up U-Boot on a
board, with timeouts, expects, etc.
This is tedious to maintain and is peripheral to the test system's
purpose. It seems better to put this logic in the lab itself, where is
can provide such support.
With Labgrid we can use the UbootStrategy class to get the board into a
useful state, however it needs to do it. Then it can report to pytest
by writing a suitable string along with the U-Boot version it detected.
Add support for detecting 'lab mode' and simply assume that all is well
in that case. Collect the version string when Labgrid says it is ready.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
(no changes since v1)
test/py/u_boot_console_base.py | 68 ++++++++++++++++++++++++++--------
1 file changed, 53 insertions(+), 15 deletions(-)
diff --git a/test/py/u_boot_console_base.py b/test/py/u_boot_console_base.py
index 9474fa87ec9..bcba68f0aac 100644
--- a/test/py/u_boot_console_base.py
+++ b/test/py/u_boot_console_base.py
@@ -23,13 +23,21 @@ pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
pattern_error_notification = re.compile('## Error: ')
pattern_error_please_reset = re.compile('### ERROR ### Please RESET the board ###')
-pattern_ready_prompt = re.compile('U-Boot is ready')
+pattern_ready_prompt = re.compile('{lab ready in (.*)s: (.*)}')
+pattern_lab_mode = re.compile('{lab mode.*}')
PAT_ID = 0
PAT_RE = 1
# Timeout before expecting the console to be ready (in milliseconds)
-TIMEOUT_MS = 30000
+TIMEOUT_MS = 30000 # Standard timeout
+
+# Timeout for board preparation in lab mode. This needs to be enough to build
+# U-Boot, write it to the board and then boot the board. Since this process is
+# under the control of another program (e.g. Labgrid), it will failure sooner
+# if something goes way. So use a very long timeout here to cover all possible
+# situations.
+TIMEOUT_PREPARE_MS = 3 * 60 * 1000
bad_pattern_defs = (
('spl_signon', pattern_u_boot_spl_signon),
@@ -143,6 +151,7 @@ class ConsoleBase(object):
self.at_prompt = False
self.at_prompt_logevt = None
+ self.lab_mode = False
def get_spawn(self):
# This is not called, ssubclass must define this.
@@ -176,40 +185,69 @@ class ConsoleBase(object):
self.p.close()
self.logstream.close()
+ def set_lab_mode(self):
+ """Select lab mode
+
+ This tells us that we will get a 'lab ready' message when the board is
+ ready for use. We don't need to look for signon messages.
+ """
+ self.log.info(f'test.py: Lab mode is active')
+ self.p.timeout = TIMEOUT_PREPARE_MS
+ self.lab_mode = True
+
def wait_for_boot_prompt(self, loop_num = 1):
"""Wait for the boot up until command prompt. This is for internal use only.
"""
try:
+ self.log.info('Waiting for U-Boot to be ready')
bcfg = self.config.buildconfig
config_spl_serial = bcfg.get('config_spl_serial', 'n') == 'y'
env_spl_skipped = self.config.env.get('env__spl_skipped', False)
env_spl_banner_times = self.config.env.get('env__spl_banner_times', 1)
- while loop_num > 0:
+ while not self.lab_mode and loop_num > 0:
loop_num -= 1
while config_spl_serial and not env_spl_skipped and env_spl_banner_times > 0:
- m = self.p.expect([pattern_u_boot_spl_signon] +
- self.bad_patterns)
- if m != 0:
+ m = self.p.expect([pattern_u_boot_spl_signon,
+ pattern_lab_mode] + self.bad_patterns)
+ if m == 1:
+ self.set_lab_mode()
+ break
+ elif m != 0:
raise BootFail('Bad pattern found on SPL console: ' +
- self.bad_pattern_ids[m - 1])
+ self.bad_pattern_ids[m - 1])
env_spl_banner_times -= 1
- m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns)
- if m != 0:
- raise BootFail('Bad pattern found on console: ' +
- self.bad_pattern_ids[m - 1])
- self.u_boot_version_string = self.p.after
+ if not self.lab_mode:
+ m = self.p.expect([pattern_u_boot_main_signon,
+ pattern_lab_mode] + self.bad_patterns)
+ if m == 1:
+ self.set_lab_mode()
+ elif m != 0:
+ raise BootFail('Bad pattern found on console: ' +
+ self.bad_pattern_ids[m - 1])
+ if not self.lab_mode:
+ self.u_boot_version_string = self.p.after
while True:
m = self.p.expect([self.prompt_compiled, pattern_ready_prompt,
pattern_stop_autoboot_prompt] + self.bad_patterns)
- if m == 0 or m == 1:
+ if m == 0:
+ self.log.info(f'Found ready prompt {m}')
+ break
+ elif m == 1:
+ m = pattern_ready_prompt.search(self.p.after)
+ self.u_boot_version_string = m.group(2)
+ self.log.info(f'Lab: Board is ready')
+ self.p.timeout = TIMEOUT_MS
break
if m == 2:
+ self.log.info(f'Found autoboot prompt {m}')
self.p.send(' ')
continue
- raise BootFail('Bad pattern found on console: ' +
- self.bad_pattern_ids[m - 3])
+ if not self.lab_mode:
+ raise BootFail('Missing prompt / ready message on console: ' +
+ self.bad_pattern_ids[m - 3])
+ self.log.info(f'U-Boot is ready')
finally:
self.log.timestamp()
--
2.43.0
next prev parent reply other threads:[~2024-09-20 6:05 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-20 6:01 [PATCH v6 00/19] labgrid: Provide an integration with Labgrid Simon Glass
2024-09-20 6:01 ` [PATCH v6 01/19] test: Allow signaling that U-Boot is ready Simon Glass
2024-09-23 20:35 ` Tom Rini
2024-09-25 12:49 ` Simon Glass
2024-09-25 17:26 ` Tom Rini
2024-09-26 21:36 ` Simon Glass
2024-09-27 2:51 ` Tom Rini
2024-10-31 18:03 ` Simon Glass
2024-10-31 18:28 ` Tom Rini
2024-11-01 15:33 ` Simon Glass
2024-11-01 19:02 ` Tom Rini
2024-11-02 16:32 ` Simon Glass
2024-11-02 21:39 ` Tom Rini
2024-09-20 6:01 ` [PATCH v6 02/19] test: Use a constant for the test timeout Simon Glass
2024-09-23 20:35 ` Tom Rini
2024-09-20 6:01 ` [PATCH v6 03/19] test: Release board after tests complete Simon Glass
2024-09-20 6:01 ` [PATCH v6 04/19] test: Allow connecting to a running board Simon Glass
2024-09-23 20:35 ` Tom Rini
2024-09-25 12:50 ` Simon Glass
2024-09-20 6:01 ` [PATCH v6 05/19] test: Avoid failing skipped tests Simon Glass
2024-09-20 6:01 ` [PATCH v6 06/19] test: Create a common function to get the config Simon Glass
2024-09-20 6:01 ` [PATCH v6 07/19] test: Introduce the concept of a role Simon Glass
2024-09-20 6:01 ` [PATCH v6 08/19] test: Move the receive code into a function Simon Glass
2024-09-20 6:01 ` [PATCH v6 09/19] test: Separate out the exception handling Simon Glass
2024-09-20 6:01 ` [PATCH v6 10/19] test: Detect dead connections Simon Glass
2024-09-20 6:01 ` [PATCH v6 11/19] test: Tidy up remaining exceptions Simon Glass
2024-09-20 6:01 ` Simon Glass [this message]
2024-09-20 6:01 ` [PATCH v6 13/19] test: Improve handling of sending commands Simon Glass
2024-09-20 6:01 ` [PATCH v6 14/19] test: Fix mulptiplex_log typo Simon Glass
2024-09-20 6:01 ` [PATCH v6 15/19] test: Avoid double echo when starting up Simon Glass
2024-09-20 6:01 ` [PATCH v6 16/19] test: Try to shut down the lab console gracefully Simon Glass
2024-09-20 6:01 ` [PATCH v6 17/19] test: Add a section for closing the connection Simon Glass
2024-09-20 6:01 ` [PATCH v6 18/19] test: Support testing with two board-builds Simon Glass
2024-09-20 6:01 ` [PATCH v6 19/19] CI: Allow running tests on sjg lab Simon Glass
2024-09-23 20:36 ` [PATCH v6 00/19] labgrid: Provide an integration with Labgrid Tom Rini
2024-09-25 12:50 ` Simon Glass
2024-09-25 17:26 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240920060158.106612-13-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.