barebox built for some targets like the ARM virt machine doesn't yet include a device tree and instead depends on previous stage firmware running in QEMU (or QEMU itself) passing along the device tree that QEMU assembles internally. For debugging and to make it easier to use barebox in setups, where a device tree needs to be provided explicitly, add a --dump-dtb option. Note that not all machines seem to support this. If this is unsupported, the QEMU VM will be started normally. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- conftest.py | 3 +++ test/strategy.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/conftest.py b/conftest.py index 5639b7e22ebd..941eddcb72dd 100644 --- a/conftest.py +++ b/conftest.py @@ -45,6 +45,9 @@ def pytest_addoption(parser): parser.addoption('--dry-run', action='store_const', const='qemu_dry_run', dest='lg_initial_state', help=('(for debugging) skip tests and just print Qemu command line')) + parser.addoption('--dump-dtb', action='store_const', const='qemu_dump_dtb', + dest='lg_initial_state', + help=('(for debugging) skip tests and just dump the Qemu device tree')) parser.addoption('--rng', action='count', dest='qemu_rng', help=('instantiate Virt I/O random number generator')) parser.addoption('--console', action='count', dest='qemu_console', default=0, diff --git a/test/strategy.py b/test/strategy.py index 4063b8ff818b..3e9c73724048 100644 --- a/test/strategy.py +++ b/test/strategy.py @@ -23,6 +23,7 @@ class Status(enum.Enum): barebox = 2 qemu_dry_run = 3 qemu_interactive = 4 + qemu_dump_dtb = 5 @target_factory.reg_driver @attr.s(eq=False) @@ -72,7 +73,10 @@ class BareboxTestStrategy(Strategy): def force(self, state): self.transition(Status.off) # pylint: disable=missing-kwoa - if state == "qemu_dry_run" or state == "qemu_interactive": + if state.startswith("qemu_"): + if state == "qemu_dump_dtb": + self.qemu.machine += f",dumpdtb={self.target.name}.dtb" + cmd = self.qemu.get_qemu_base_args() cmd.append("-serial") @@ -88,7 +92,7 @@ class BareboxTestStrategy(Strategy): pytest.exit('Interactive session terminated') else: - pytest.exit('Can only force to: qemu_dry_run, qemu_interactive') + pytest.exit('Can only force to: qemu_dry_run, qemu_interactive, qemu_dump_dtb') def append_qemu_args(self, *args): if self.qemu is None: -- 2.39.5