mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] test: pytest: add support for --dump-dtb
Date: Mon,  6 Jan 2025 10:19:27 +0100	[thread overview]
Message-ID: <20250106091927.3435620-1-a.fatoum@pengutronix.de> (raw)

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@pengutronix.de>
---
 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




             reply	other threads:[~2025-01-06  9:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-06  9:19 Ahmad Fatoum [this message]
2025-01-06 13:26 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250106091927.3435620-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox