History log of /u-boot/test/py/u_boot_utils.py
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 7e91bf89 13-Feb-2023 Simon Glass <sjg@chromium.org>

test: Add a way to set the environment for a pytest

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>

# 2402c931 28-Nov-2021 Tom Rini <trini@konsulko.com>

Merge tag 'v2022.01-rc3' into next

Prepare v2022.01-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>


# 15156c95 23-Oct-2021 Simon Glass <sjg@chromium.org>

test/py: Allow passing input to a program

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>

# 9aa1a14d 22-Nov-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

test: fix pylint errors in u_boot_utils.py

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

# 99f5303c 04-Jun-2021 Alper Nebi Yasak <alpernebiyasak@gmail.com>

test/py: Wait for guestmount worker to exit after running guestunmount

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>

# b2c26081 28-Mar-2020 Bin Meng <bmeng.cn@gmail.com>

test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memory

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>

# abba7635 09-Jul-2018 Quentin Schulz <quentin.schulz@bootlin.com>

test/py: return a RAM address different from 0 as it can be interpreted as NULL

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>

# b8c45550 14-Sep-2017 Paul Burton <paul.burton@mips.com>

test/py: Use range() rather than xrange()

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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>

# c3342cd5 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: add generic CRC32 function

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>

# 64a2cebb 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: do not import pytest multiple times

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>

# ac122efd 26-Oct-2017 Stephen Warren <swarren@nvidia.com>

test/py: regenerate persistent GPT image if code changes

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>

# ec70f8a9 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Drop the cmd() function

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>

# 72f52268 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Fix typos in comments

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>

# 7f64b187 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Check exit status in run_and_log_expect_exception()

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)

# 9e17b034 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Provide a way to check that a command fails

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>

# 8b304a37 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Add an option to execute a string containing a command

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>

# f3d3e95c 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Return output from run_and_log()

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>

# d56dd0b1 05-Jul-2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

test/py: support 'memstart =' in u_boot_utils.find_ram_base()

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>

# 7e6621a1 05-May-2016 Heiko Schocher <hs@denx.de>

test/py: fix NameError exception if bdi cmd is not supported

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>

# b8218a91 09-May-2016 Heiko Schocher <hs@denx.de>

tests: py: fix NameError exception if bdi cmd is not supported

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>

# e8debf39 26-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: use " for docstrings

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>

# 05266103 21-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: move find_ram_base() into u_boot_utils

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>

# 76b46939 22-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: add various utility code

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>

# 2402c931 28-Nov-2021 Tom Rini <trini@konsulko.com>

Merge tag 'v2022.01-rc3' into next

Prepare v2022.01-rc3

Signed-off-by: Tom Rini <trini@konsulko.com>


# 15156c95 23-Oct-2021 Simon Glass <sjg@chromium.org>

test/py: Allow passing input to a program

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>

# 9aa1a14d 22-Nov-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

test: fix pylint errors in u_boot_utils.py

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

# 99f5303c 04-Jun-2021 Alper Nebi Yasak <alpernebiyasak@gmail.com>

test/py: Wait for guestmount worker to exit after running guestunmount

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>

# b2c26081 28-Mar-2020 Bin Meng <bmeng.cn@gmail.com>

test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memory

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>

# abba7635 09-Jul-2018 Quentin Schulz <quentin.schulz@bootlin.com>

test/py: return a RAM address different from 0 as it can be interpreted as NULL

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>

# b8c45550 14-Sep-2017 Paul Burton <paul.burton@mips.com>

test/py: Use range() rather than xrange()

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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>

# c3342cd5 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: add generic CRC32 function

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>

# 64a2cebb 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: do not import pytest multiple times

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>

# ac122efd 26-Oct-2017 Stephen Warren <swarren@nvidia.com>

test/py: regenerate persistent GPT image if code changes

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>

# ec70f8a9 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Drop the cmd() function

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>

# 72f52268 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Fix typos in comments

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>

# 7f64b187 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Check exit status in run_and_log_expect_exception()

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)

# 9e17b034 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Provide a way to check that a command fails

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>

# 8b304a37 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Add an option to execute a string containing a command

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>

# f3d3e95c 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Return output from run_and_log()

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>

# d56dd0b1 05-Jul-2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

test/py: support 'memstart =' in u_boot_utils.find_ram_base()

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>

# 7e6621a1 05-May-2016 Heiko Schocher <hs@denx.de>

test/py: fix NameError exception if bdi cmd is not supported

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>

# b8218a91 09-May-2016 Heiko Schocher <hs@denx.de>

tests: py: fix NameError exception if bdi cmd is not supported

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>

# e8debf39 26-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: use " for docstrings

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>

# 05266103 21-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: move find_ram_base() into u_boot_utils

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>

# 76b46939 22-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: add various utility code

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>

# 9aa1a14d 22-Nov-2021 Heinrich Schuchardt <xypron.glpk@gmx.de>

test: fix pylint errors in u_boot_utils.py

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

# 99f5303c 04-Jun-2021 Alper Nebi Yasak <alpernebiyasak@gmail.com>

test/py: Wait for guestmount worker to exit after running guestunmount

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>

# b2c26081 28-Mar-2020 Bin Meng <bmeng.cn@gmail.com>

test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memory

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>

# abba7635 09-Jul-2018 Quentin Schulz <quentin.schulz@bootlin.com>

test/py: return a RAM address different from 0 as it can be interpreted as NULL

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>

# b8c45550 14-Sep-2017 Paul Burton <paul.burton@mips.com>

test/py: Use range() rather than xrange()

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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>

# c3342cd5 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: add generic CRC32 function

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>

# 64a2cebb 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: do not import pytest multiple times

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>

# ac122efd 26-Oct-2017 Stephen Warren <swarren@nvidia.com>

test/py: regenerate persistent GPT image if code changes

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>

# ec70f8a9 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Drop the cmd() function

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>

# 72f52268 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Fix typos in comments

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>

# 7f64b187 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Check exit status in run_and_log_expect_exception()

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)

# 9e17b034 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Provide a way to check that a command fails

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>

# 8b304a37 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Add an option to execute a string containing a command

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>

# f3d3e95c 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Return output from run_and_log()

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>

# d56dd0b1 05-Jul-2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

test/py: support 'memstart =' in u_boot_utils.find_ram_base()

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>

# 7e6621a1 05-May-2016 Heiko Schocher <hs@denx.de>

test/py: fix NameError exception if bdi cmd is not supported

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>

# b8218a91 09-May-2016 Heiko Schocher <hs@denx.de>

tests: py: fix NameError exception if bdi cmd is not supported

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>

# e8debf39 26-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: use " for docstrings

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>

# 05266103 21-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: move find_ram_base() into u_boot_utils

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>

# 76b46939 22-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: add various utility code

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>

# 99f5303c 04-Jun-2021 Alper Nebi Yasak <alpernebiyasak@gmail.com>

test/py: Wait for guestmount worker to exit after running guestunmount

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>

# b2c26081 28-Mar-2020 Bin Meng <bmeng.cn@gmail.com>

test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memory

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>

# abba7635 09-Jul-2018 Quentin Schulz <quentin.schulz@bootlin.com>

test/py: return a RAM address different from 0 as it can be interpreted as NULL

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>

# b8c45550 14-Sep-2017 Paul Burton <paul.burton@mips.com>

test/py: Use range() rather than xrange()

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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>

# c3342cd5 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: add generic CRC32 function

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>

# 64a2cebb 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: do not import pytest multiple times

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>

# ac122efd 26-Oct-2017 Stephen Warren <swarren@nvidia.com>

test/py: regenerate persistent GPT image if code changes

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>

# ec70f8a9 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Drop the cmd() function

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>

# 72f52268 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Fix typos in comments

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>

# 7f64b187 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Check exit status in run_and_log_expect_exception()

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)

# 9e17b034 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Provide a way to check that a command fails

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>

# 8b304a37 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Add an option to execute a string containing a command

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>

# f3d3e95c 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Return output from run_and_log()

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>

# d56dd0b1 05-Jul-2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

test/py: support 'memstart =' in u_boot_utils.find_ram_base()

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>

# 7e6621a1 05-May-2016 Heiko Schocher <hs@denx.de>

test/py: fix NameError exception if bdi cmd is not supported

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>

# b8218a91 09-May-2016 Heiko Schocher <hs@denx.de>

tests: py: fix NameError exception if bdi cmd is not supported

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>

# e8debf39 26-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: use " for docstrings

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>

# 05266103 21-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: move find_ram_base() into u_boot_utils

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>

# 76b46939 22-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: add various utility code

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>

# b2c26081 28-Mar-2020 Bin Meng <bmeng.cn@gmail.com>

test/py: Update u_boot_utils.find_ram_base to bypass the low 2MiB memory

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>

# abba7635 09-Jul-2018 Quentin Schulz <quentin.schulz@bootlin.com>

test/py: return a RAM address different from 0 as it can be interpreted as NULL

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>

# b8c45550 14-Sep-2017 Paul Burton <paul.burton@mips.com>

test/py: Use range() rather than xrange()

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>

# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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>

# c3342cd5 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: add generic CRC32 function

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>

# 64a2cebb 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: do not import pytest multiple times

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>

# ac122efd 26-Oct-2017 Stephen Warren <swarren@nvidia.com>

test/py: regenerate persistent GPT image if code changes

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>

# ec70f8a9 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Drop the cmd() function

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>

# 72f52268 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Fix typos in comments

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>

# 7f64b187 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Check exit status in run_and_log_expect_exception()

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)

# 9e17b034 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Provide a way to check that a command fails

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>

# 8b304a37 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Add an option to execute a string containing a command

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>

# f3d3e95c 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Return output from run_and_log()

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>

# d56dd0b1 05-Jul-2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

test/py: support 'memstart =' in u_boot_utils.find_ram_base()

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>

# 7e6621a1 05-May-2016 Heiko Schocher <hs@denx.de>

test/py: fix NameError exception if bdi cmd is not supported

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>

# b8218a91 09-May-2016 Heiko Schocher <hs@denx.de>

tests: py: fix NameError exception if bdi cmd is not supported

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>

# e8debf39 26-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: use " for docstrings

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>

# 05266103 21-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: move find_ram_base() into u_boot_utils

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>

# 76b46939 22-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: add various utility code

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>

# abba7635 09-Jul-2018 Quentin Schulz <quentin.schulz@bootlin.com>

test/py: return a RAM address different from 0 as it can be interpreted as NULL

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>


# b8c45550 14-Sep-2017 Paul Burton <paul.burton@imgtec.com>

test/py: Use range() rather than xrange()

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>


# 83d290c5 06-May-2018 Tom Rini <trini@konsulko.com>

SPDX: Convert all of our single license tags to Linux Kernel style

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>


# c3342cd5 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: add generic CRC32 function

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>


# 64a2cebb 14-Mar-2018 Liam Beguin <liambeguin@gmail.com>

test/py: do not import pytest multiple times

Signed-off-by: Liam Beguin <liambeguin@gmail.com>
Reviewed-by: Stephen Warren <swarren@nvidia.com>


# ac122efd 26-Oct-2017 Stephen Warren <swarren@nvidia.com>

test/py: regenerate persistent GPT image if code changes

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>


# ec70f8a9 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Drop the cmd() function

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>


# 72f52268 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Fix typos in comments

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>


# 7f64b187 31-Jul-2016 Simon Glass <sjg@chromium.org>

test: Check exit status in run_and_log_expect_exception()

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)


# 9e17b034 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Provide a way to check that a command fails

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>


# 8b304a37 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Add an option to execute a string containing a command

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>


# f3d3e95c 03-Jul-2016 Simon Glass <sjg@chromium.org>

test/py: Return output from run_and_log()

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>


# d56dd0b1 05-Jul-2016 Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

test/py: support 'memstart =' in u_boot_utils.find_ram_base()

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>


# 7e6621a1 05-May-2016 Heiko Schocher <hs@denx.de>

test/py: fix NameError exception if bdi cmd is not supported

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>


# b8218a91 09-May-2016 Heiko Schocher <hs@denx.de>

tests: py: fix NameError exception if bdi cmd is not supported

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>


# e8debf39 26-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: use " for docstrings

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>


# 05266103 21-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: move find_ram_base() into u_boot_utils

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>


# 76b46939 22-Jan-2016 Stephen Warren <swarren@nvidia.com>

test/py: add various utility code

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>