[PATCH] test: add --bootarg option when running under QEMU
Ahmad Fatoum
a.fatoum at barebox.org
Wed Aug 6 06:57:51 PDT 2025
On platforms, where the device tree is passed by QEMU, /chosen/bootargs
is an easy way to pass early settings to barebox.
Expose this over a new --bootarg parameter.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
conftest.py | 5 +++++
test/strategy.py | 7 +++++++
2 files changed, 12 insertions(+)
diff --git a/conftest.py b/conftest.py
index 782ebc0536fd..45e8835924b3 100644
--- a/conftest.py
+++ b/conftest.py
@@ -68,6 +68,8 @@ def pytest_addoption(parser):
help=('Pass barebox environment files to barebox. Can be specified more than once'))
parser.addoption('--qemu', dest='qemu_arg', nargs=argparse.REMAINDER, default=[],
help=('Pass all remaining options to QEMU as is'))
+ parser.addoption('--bootarg', action='append', dest='bootarg', default=[],
+ help=('Pass boot arguments to barebox for debugging purposes'))
@pytest.fixture(scope="session")
def strategy(request, target, pytestconfig):
@@ -152,6 +154,9 @@ def strategy(request, target, pytestconfig):
else:
pytest.exit("--env unsupported for target\n", 1)
+ if len(pytestconfig.option.bootarg) > 0:
+ strategy.append_qemu_bootargs(pytestconfig.option.bootarg)
+
for arg in pytestconfig.option.qemu_arg:
strategy.append_qemu_args(arg)
diff --git a/test/strategy.py b/test/strategy.py
index b5a9d8b814a8..11406b97f5f1 100644
--- a/test/strategy.py
+++ b/test/strategy.py
@@ -100,6 +100,13 @@ class BareboxTestStrategy(Strategy):
for arg in args:
self.console.extra_args += " " + arg
+ def append_qemu_bootargs(self, args):
+ if self.qemu is None:
+ pytest.exit('Qemu option supplied for non-Qemu target')
+ if self.console.boot_args is None:
+ self.console.boot_args = ""
+ self.console.boot_args += " ".join(args)
+
def quote_cmd(cmd):
quoted = map(lambda s : s if s.find(" ") == -1 else "'" + s + "'", cmd)
return " ".join(quoted)
--
2.39.5
More information about the barebox
mailing list