21 Commits

Author SHA1 Message Date
Simon Glass
652e93b301 test/py: Use longer timeout for lab-mode restart
When restarting U-Boot in lab mode, ensure_spawned() sets the timeout
to TIMEOUT_MS (30 seconds) before calling _wait_for_boot_prompt(). In
lab mode, _wait_for_banner() is skipped, so TIMEOUT_PREPARE_MS is never
restored.

This causes tests that boot into Linux and then restart U-Boot (like
test_distro_script) to fail with a timeout if the board takes more than
30 seconds to reset and boot.

Fix this by setting the timeout to TIMEOUT_PREPARE_MS (3 minutes) at
the start of _wait_for_boot_prompt() when in lab mode.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-19 21:48:59 -07:00
Simon Glass
ca30385c61 Correct implementation of Spawn() in ConsoleBase
Now that this base-class function is called, it can produce an error on
test failure, since it passes an empty list for the arguments.

Rename the reset() function to prepare_for_spawn() and use that instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 14:39:59 -06:00
Simon Glass
684fc8c4d7 Revert "Merge branch 'loadg' into 'master'"
This reverts merge request !141
2025-08-02 19:50:30 +00:00
Simon Glass
fdcc591414 Correct implementation of Spawn() in ConsoleBase
Now that this base-class function is called, it can produce an error on
test failure, since it passes an empty list for the arguments.

Rename the reset() function to prepare_for_spawn() and use that instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-02 12:21:34 -06:00
Simon Glass
43c42430af test/py: Add a proper function to shut down U-Boot
Some tests boot out of U-Boot or perform such other action that it can
no-longer be used for tests. Provide a function to handle this, rather
than having tests do it themselves.

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-to: u-boot
Cover-letter:
test/py: Some code tidy-updates
This series includes various improvements to the test/py close:

- Fix some pylint warnings
- Log the PYTHONPATH when no py hooks are found
- Improve how the pattern list is handled
- Move 'expect' handling into ConsoleBase
- Add an exported function to shutdown U-Boot in tests
- A few other minor things
END
2025-07-23 19:40:18 -06:00
Simon Glass
09b52857bb test/py: Split up _wait_for_boot_prompt
The banner-detection code is quite large and is not needed in lab mode.
Move it into its own function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 19:38:22 -06:00
Simon Glass
791872b9fe test/py: Move member variables from spawn to console_base
Now that all the expect() functionality is in console_base, move the
variables there too.

Ensure they are reset when a new connection is spawned.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 19:38:03 -06:00
Simon Glass
31c6d1d063 test/py: Move the timeout to console_base
This timeout relates to the expect() function so move it into the same
file and class.

Reset the timeout when a new spawn is created, to mimic the existing
behabiour. Update a few tests which access the timeout directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 17:44:15 -06:00
Simon Glass
c5cad939ad test/py: Move expect() function into console_base
This function is only used from console_base and it is always accessed
via a 'self.p.expect()' expression, which is confusing.

Checking for expected output doesn't really relate to spawning in any
case, so move this function to console_base

For now the spawn class is kept as it is, to reduce the change in each
patch.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 17:38:59 -06:00
Simon Glass
ffdf4039cb test/py: Move exceptions to console_base
As a first step towards moving the expect() handler to console_base,
move the exceptions there.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 17:30:11 -06:00
Simon Glass
e94063b4c7 test/py: Provide an expect() function for use by tests
At present some tests are directly calling the Spawn() object in order
to check for required output. This is a bit messy. Add a function to the
ubman fixture to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 12:17:34 -06:00
Simon Glass
9f7227ee17 test/py: Maintain a list of available patterns
Some tests want to augment the list, so rather than using the global
PATTERNS values, create an avail_patterns property in ConsoleBase

With this we can avoid changing the global.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 12:17:34 -06:00
Simon Glass
f36b2e7285 test/py: Rename bad_pattern_defs to PATTERNS
This name is quite confusing. Not all of the patterns are necessarily
bad. For example, main_signon is expected on start-up.

Rename it to the more neutral 'PATTERNS', using capitals since it is a
global. Rename eval_bad_patterns() also.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 12:17:34 -06:00
Simon Glass
376dfaf3bf test/py: Create a named tuple for the pattern list
It is a bit clumsy to have to subscript a list. Use a named tuple
instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 12:17:34 -06:00
Simon Glass
5683831563 test/py: Tidy up comments in ConsoleBase()
Some of the attributes are missing comments. Add these and tidy up a
few existing ones.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 12:16:43 -06:00
Simon Glass
4f1e711579 test/py: Tidy up pylint warnings in console_base
There are quite a few warnings which makes it confusing when editing
this file. Resolve the easy ones, leaving:

  125:0: R0902: Too many instance attributes (14/7) (too-many-instance-attributes)
  212:4: R0912: Too many branches (14/12) (too-many-branches)
  271:4: R0913: Too many arguments (6/5) (too-many-arguments)
  271:4: R0912: Too many branches (13/12) (too-many-branches)
  454:8: W0702: No exception type(s) specified (bare-except)
  531:8: W0702: No exception type(s) specified (bare-except)

Rename wait_for_boot_prompt() so it is clear that it is an internal
function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-23 12:16:43 -06:00
Simon Glass
0dccad74d8 Mark this tree as a concept
Use a 'Concept' tag for the experimental U-Boot so that it is clear it
is experimental.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-07 11:39:43 -06:00
Heinrich Schuchardt
37e1b5b09b test: add command to 'Lab failure' timeout message
When a timeout occurs while executing a command a 'Lab failure' message is
written and testing is stopped. The user is left in the dark about the
failure cause.

    ! _pytest.outcomes.Exit: Lab failure: Marking connection bad - no other tests will run !

Add the word 'Timeout' and the executed command to the message.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-05-01 06:37:43 -06:00
Heinrich Schuchardt
5eb562d8d3 test: add command to 'Boot fail' message
When a timeout occurs while executing a command a 'Boot fail' message is
written and testing is stopped. The user is left in the dark about the
failure cause.

    ! _pytest.outcomes.Exit: Boot fail: Marking connection bad - no other tests will run !

Add the executed command to the message.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-01 06:37:43 -06:00
Simon Glass
52a3219fee test/py: Add a helper to send characters
The existing run_command() method is not great for sending things other
than U-Boot commands. Add a helper for sending arbitrary strings as well
as control characters.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-03-15 08:49:43 +00:00
Simon Glass
d428226459 test/py: Drop u_boot_ prefix on test files
We know this is U-Boot so the prefix serves no purpose other than to
make things longer and harder to read. Drop it and rename the files.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # test_android / test_dfu
2025-02-16 17:30:53 -07:00