test/py: Make the number of SPL banners seen a variable

Currently we have the option to tell the console code that we should
ignore the SPL banner. We also have an option to say that we can see it
a second time, and ignore it. However, some platforms such as TI AM64x
will have us see the SPL banner three times. Rather than add an
"spl3_skipped" option, rework the code. By default we expect to see the
banner once, but boards can specify seeing it as many times as they
expect to.

Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
Tom Rini 2024-04-24 16:45:37 -06:00
parent 48022fb4a5
commit 645f75f688

View file

@ -17,7 +17,6 @@ import u_boot_spawn
# Regexes for text we expect U-Boot to send to the console. # Regexes for text we expect U-Boot to send to the console.
pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))') pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
pattern_u_boot_spl2_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))') pattern_u_boot_main_signon = re.compile('(U-Boot \\d{4}\\.\\d{2}[^\r\n]*\\))')
pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ') pattern_stop_autoboot_prompt = re.compile('Hit any key to stop autoboot: ')
pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'') pattern_unknown_command = re.compile('Unknown command \'.*\' - try \'help\'')
@ -29,7 +28,6 @@ PAT_RE = 1
bad_pattern_defs = ( bad_pattern_defs = (
('spl_signon', pattern_u_boot_spl_signon), ('spl_signon', pattern_u_boot_spl_signon),
('spl2_signon', pattern_u_boot_spl2_signon),
('main_signon', pattern_u_boot_main_signon), ('main_signon', pattern_u_boot_main_signon),
('stop_autoboot_prompt', pattern_stop_autoboot_prompt), ('stop_autoboot_prompt', pattern_stop_autoboot_prompt),
('unknown_command', pattern_unknown_command), ('unknown_command', pattern_unknown_command),
@ -152,25 +150,20 @@ class ConsoleBase(object):
""" """
try: try:
bcfg = self.config.buildconfig bcfg = self.config.buildconfig
config_spl = bcfg.get('config_spl', 'n') == 'y'
config_spl_serial = bcfg.get('config_spl_serial', 'n') == 'y' config_spl_serial = bcfg.get('config_spl_serial', 'n') == 'y'
env_spl_skipped = self.config.env.get('env__spl_skipped', False) env_spl_skipped = self.config.env.get('env__spl_skipped', False)
env_spl2_skipped = self.config.env.get('env__spl2_skipped', True) env_spl_banner_times = self.config.env.get('env__spl_banner_times', 1)
while loop_num > 0: while loop_num > 0:
loop_num -= 1 loop_num -= 1
if config_spl and config_spl_serial and not env_spl_skipped: while config_spl_serial and not env_spl_skipped and env_spl_banner_times > 0:
m = self.p.expect([pattern_u_boot_spl_signon] + m = self.p.expect([pattern_u_boot_spl_signon] +
self.bad_patterns) self.bad_patterns)
if m != 0: if m != 0:
raise Exception('Bad pattern found on SPL console: ' + raise Exception('Bad pattern found on SPL console: ' +
self.bad_pattern_ids[m - 1]) self.bad_pattern_ids[m - 1])
if not env_spl2_skipped: env_spl_banner_times -= 1
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) m = self.p.expect([pattern_u_boot_main_signon] + self.bad_patterns)
if m != 0: if m != 0:
raise Exception('Bad pattern found on console: ' + raise Exception('Bad pattern found on console: ' +