aboutsummaryrefslogtreecommitdiff
path: root/test/py/u_boot_utils.py
Commit message (Collapse)AuthorAgeFilesLines
* test: Add a way to set the environment for a pytestSimon Glass2023-02-141-2/+3
| | | | | | | This is useful when we need to control a particular environment variable. Add a way to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge tag 'v2022.01-rc3' into nextTom Rini2021-11-291-11/+14
|\ | | | | | | | | | | Prepare v2022.01-rc3 Signed-off-by: Tom Rini <trini@konsulko.com>
| * test: fix pylint errors in u_boot_utils.pyHeinrich Schuchardt2021-11-261-11/+14
| | | | | | | | | | | | | | | | | | | | | | * there is no os.path.unlink() method * don't inherit from object * add module docstring * move imports to the top * avoid unused variable Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | test/py: Allow passing input to a programSimon Glass2021-11-281-2/+3
|/ | | | | | | When running a program on the host, allow input to be passed in as stdin. This is needed for running sfdisk, for example. Signed-off-by: Simon Glass <sjg@chromium.org>
* test/py: Wait for guestmount worker to exit after running guestunmountAlper Nebi Yasak2021-07-051-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some filesystem tests are failing when their image is prepared with guestmount, but succeeding if loop mounts are used instead. The reason seems to be a race condition the guestmount(1) manual page explains: When guestunmount(1)/fusermount(1) exits, guestmount may still be running and cleaning up the mountpoint. The disk image will not be fully finalized. This means that scripts like the following have a nasty race condition: guestmount -a disk.img -i /mnt # copy things into /mnt guestunmount /mnt # immediately try to use 'disk.img' ** UNSAFE ** The solution is to use the --pid-file option to write the guestmount PID to a file, then after guestunmount spin waiting for this PID to exit. The Python standard library has an os.waitpid() function for waiting a child to terminate, but it cannot wait on non-child processes. Implement a utility function that can do this by polling the process repeatedly for a given duration, optionally killing the process if it won't terminate on its own. Apply the suggested solution with this utility function, which makes the failing tests succeed again. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memoryBin Meng2020-04-101-3/+4
| | | | | | | On some RISC-V targets the low memory is protected that prevents S-mode U-Boot from access. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
* test/py: return a RAM address different from 0 as it can be interpreted as NULLQuentin Schulz2018-07-201-0/+6
| | | | | | | | | | | | | | | | Some functions test that the given address is not NULL (0) and fail or have a different behaviour if that's the case (e.g. hexport_r). Let's make the RAM base address to be not zero by setting it to 2MiB if that's the case. 2MiB is chosen because it represents the size of an ARM LPAE/v8 section. Suggested-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Stephen Warren <swarren@nvidia.com> Tested-by: Stephen Warren <swarren@nvidia.com>
* test/py: Use range() rather than xrange()Paul Burton2018-07-101-2/+2
| | | | | | | | | | | In python 3.x the xrange() function has been removed, and range() returns an iterator much like Python 2.x's xrange(). Simply use range() in place of xrange() in order to work on both python 2.x & 3.x. This will mean a small cost on python 2.x since range() will return a list there rather than an iterator, but the cost should be negligible. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* test/py: add generic CRC32 functionLiam Beguin2018-03-221-0/+23
| | | | | | | | Add a generic function which can be used to compute the CRC32 value of a region of RAM. Signed-off-by: Liam Beguin <liambeguin@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* test/py: do not import pytest multiple timesLiam Beguin2018-03-221-1/+0
| | | | | Signed-off-by: Liam Beguin <liambeguin@gmail.com> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* test/py: regenerate persistent GPT image if code changesStephen Warren2017-11-061-0/+74
| | | | | | | | | | | | test_gpt generates a persistent disk image which can be re-used across multiple test runs. Currently, if the Python code that generates the disk image change, the image is not regenerated, which could cause test failures e.g. if a test was updated to expect some new partition name or size, yet the persistent disk image contained the old name or size. This change introduces functionality to regenerate the disk image if the instructions to generate the image have changed. Signed-off-by: Stephen Warren <swarren@nvidia.com>
* test: Drop the cmd() functionSimon Glass2016-08-051-14/+5
| | | | | | | | | Instead of this, use the existing run_and_log() function, enhanced to support a command string as well as a list of arguments. Suggested-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Fix typos in commentsSimon Glass2016-08-051-2/+2
| | | | | | | | Fix some typos in various files introduced with the vboot test conversion. Reported-by: Teddy Reed <teddy.reed@gmail.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Check exit status in run_and_log_expect_exception()Simon Glass2016-08-051-1/+3
| | | | | | | | This check was missed. Add it and make the message more verbose. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Tom Rini <trini@konsulko.com> Fixes: 9e17b034 (test/py: Provide a way to check that a command fails)
* test/py: Provide a way to check that a command failsSimon Glass2016-07-141-0/+22
| | | | | | | | Sometimes we want to run a command and check that it fails. Add a function to handle this. It can check the return code and also make sure that the output contains a given error message. Signed-off-by: Simon Glass <sjg@chromium.org>
* test/py: Add an option to execute a string containing a commandSimon Glass2016-07-141-0/+12
| | | | | | | | It is sometimes inconvenient to convert a string into a list for execution with run_and_log(). Provide a helper function to do this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Teddy Reed <teddy.reed@gmail.com>
* test/py: Return output from run_and_log()Simon Glass2016-07-141-2/+3
| | | | | | | | It is useful to be able to obtain the output from a command. Return it from this function. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Teddy Reed <teddy.reed@gmail.com>
* test/py: support 'memstart =' in u_boot_utils.find_ram_base()Daniel Schwierzeck2016-07-081-1/+1
| | | | | | | | | | Some archs like MIPS or PPC have a different 'bdinfo' output than ARM regarding the memory configuration. Also support 'memstart = 0x*' in u_boot_utils.find_ram_base() to make all tests requiring the RAM base working on those archs. Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com> Acked-by: Stephen Warren <swarren@nvidia.com>
* test/py: fix NameError exception if bdi cmd is not supportedHeiko Schocher2016-05-271-0/+1
| | | | | | | | | | | | test/py raises an error, if a board has not enabled bdi command > pytest.skip('bdinfo command not supported') E NameError: global name 'pytest' is not defined import pytest in test/py/u_boot_utils.py fixes this. Signed-off-by: Heiko Schocher <hs@denx.de> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* tests: py: fix NameError exception if bdi cmd is not supportedHeiko Schocher2016-05-131-0/+1
| | | | | | | | | | | | test/py raises an error, if a board has not enabled bdi command > pytest.skip('bdinfo command not supported') E NameError: global name 'pytest' is not defined import pytest in test/py/u_boot_utils.py fixes this. Signed-off-by: Heiko Schocher <hs@denx.de> Reviewed-by: Stephen Warren <swarren@nvidia.com>
* test/py: use " for docstringsStephen Warren2016-01-281-18/+18
| | | | | | | | | | | Python's coding style docs indicate to use " not ' for docstrings. test/py has other violations of the coding style docs, since the docs specify a stranger style than I would expect, but nobody has complained about those yet:-) Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test/py: move find_ram_base() into u_boot_utilsStephen Warren2016-01-281-0/+38
| | | | | | | | find_ram_base() is a shared utility function, not a core part of the U-Boot console interaction. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>
* test/py: add various utility codeStephen Warren2016-01-281-0/+171
Add various common utility functions. These will be used by a forthcoming re-written UMS test, and a brand-new DFU test. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Simon Glass <sjg@chromium.org>