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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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