Skip to content

Commit

Permalink
contrib: u-boot: testpy: Add support for out-of-tree U-Boot builds
Browse files Browse the repository at this point in the history
Add a `uboot_builddir` parameter which can be used to specify the
location of an out-of-tree U-Boot build when such an environment is
used.

Signed-off-by: Rahix <[email protected]>
  • Loading branch information
Rahix committed Jan 7, 2024
1 parent 81b8d03 commit b603bb5
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tbot_contrib/uboot/_testpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ def testpy(
uboot: Optional[tbot.role.BoardUBoot] = None,
boardenv: Optional[str] = None,
testpy_args: Optional[List[str]] = None,
uboot_builddir: Optional[linux.Path[BH]] = None,
) -> None:
"""
Run U-Boot's test/py test-framework against a tbot-machine.
Expand Down Expand Up @@ -238,12 +239,27 @@ def run_testpy() -> None:
test/py invocation. For example, you can use ``["-k", "mmc"]`` to
filter for mmc tests only. Or ``["-v"]`` to show the names of all
testcases as they are executed (or skipped).
:param tbot.machine.linux.Path uboot_builddir: Optional path to the U-Boot
build directory when an out-of-tree build is used. In this case, the
U-Boot configuration must be located in the ``uboot_builddir`` instead
of the ``uboot_sources`` directory, of course.
.. versionchanged:: UNRELEASED
Added the optional ``uboot_builddir`` parameter.
.. versionadded:: 0.9.5
"""
if board is not None:
assert uboot is not None, "when passing `board`, `uboot` is also required!"

if uboot_builddir is None:
uboot_builddir = uboot_sources

Check warning on line 257 in tbot_contrib/uboot/_testpy.py

View check run for this annotation

Codecov / codecov/patch

tbot_contrib/uboot/_testpy.py#L256-L257

Added lines #L256 - L257 were not covered by tests

assert (

Check warning on line 259 in tbot_contrib/uboot/_testpy.py

View check run for this annotation

Codecov / codecov/patch

tbot_contrib/uboot/_testpy.py#L259

Added line #L259 was not covered by tests
uboot_builddir.host == uboot_sources.host
), "build and source directories must be on the same host!"

with tbot.ctx() as cx:
bh = uboot_sources.host

Expand All @@ -264,10 +280,10 @@ def run_testpy() -> None:
chan_console, chan_command = setup_testhooks(bh, m_console, m_command)

assert (
uboot_sources / ".config"
uboot_builddir / ".config"
).exists(), "u-boot does not seem configured (.config is missing)!"
assert (
uboot_sources / "include" / "autoconf.mk"
uboot_builddir / "include" / "autoconf.mk"
).exists(), "include/autoconf.mk is missing!"

if board is not None:
Expand Down Expand Up @@ -304,7 +320,7 @@ def run_testpy() -> None:
bh.run(
"./test/py/test.py",
"--build-dir",
".",
"." if uboot_builddir == uboot_sources else uboot_builddir,
"--board-type",
boardtype,
*(testpy_args or []),
Expand Down

0 comments on commit b603bb5

Please sign in to comment.