mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH] test: fit: power cycle after tests in booted barebox
Date: Tue, 21 Oct 2025 08:48:49 +0200	[thread overview]
Message-ID: <20251021064851.775660-1-a.fatoum@barebox.org> (raw)

Networking in QEMU may run into issues in the chainloaded barebox.
Power cycle the virtual machine after the end of the FIT tests to avoid
this interference.

Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
 test/py/test_fit.py | 34 ++++++++++++++++------------------
 test/strategy.py    | 15 +++++++++++++++
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/test/py/test_fit.py b/test/py/test_fit.py
index 2a51ac1bc075..97fdac0c79d9 100644
--- a/test/py/test_fit.py
+++ b/test/py/test_fit.py
@@ -58,7 +58,7 @@ def fit_testdata(barebox_config, testfs):
         pytest.skip(f"Skip dm tests due to missing dependency: {e}")
 
 
-def test_fit(barebox, target, testfs, fit_testdata):
+def test_fit(barebox, strategy, testfs, fit_testdata):
     _, _, returncode = barebox.run(f"ls {fit_name('gzipped')}")
     if returncode != 0:
         pytest.xfail("skipping test due to missing FIT image")
@@ -77,25 +77,23 @@ def test_fit(barebox, target, testfs, fit_testdata):
     barebox.run_check("global linux.bootargs.testarg=barebox.chainloaded")
 
     boottarget = generate_bootscript(barebox, fit_name('gzipped'))
-    barebox.boot(boottarget)
-    target.deactivate(barebox)
-    target.activate(barebox)
 
-    assert of_get_property(barebox, "/chosen/barebox-version") == f'"{ver}"', \
-           "/chosen/barebox-version suggests we did not chainload"
+    with strategy.boot(boottarget):
+        assert of_get_property(barebox, "/chosen/barebox-version") == f'"{ver}"', \
+               "/chosen/barebox-version suggests we did not chainload"
 
-    assert of_get_property(barebox, "/chosen/barebox,boot-count") == '<0x1>', \
-           "/chosen/barebox,boot-count suggests we got bultin DT"
+        assert of_get_property(barebox, "/chosen/barebox,boot-count") == '<0x1>', \
+               "/chosen/barebox,boot-count suggests we got bultin DT"
 
-    # Check that command line arguments were fixed up
-    bootargs = of_get_property(barebox, "/chosen/bootargs")
-    assert "barebox.chainloaded" in bootargs
+        # Check that command line arguments were fixed up
+        bootargs = of_get_property(barebox, "/chosen/bootargs")
+        assert "barebox.chainloaded" in bootargs
 
-    initrd_start = of_get_property(barebox, "/chosen/linux,initrd-start")
-    initrd_end = of_get_property(barebox, "/chosen/linux,initrd-end")
+        initrd_start = of_get_property(barebox, "/chosen/linux,initrd-start")
+        initrd_end = of_get_property(barebox, "/chosen/linux,initrd-end")
 
-    addr_regex = r"<(0x[0-9a-f]{1,8} ?)+>"
-    assert re.search(addr_regex, initrd_start), \
-        f"initrd start {initrd_start} malformed"
-    assert re.search(addr_regex, initrd_end), \
-        f"initrd end {initrd_end} malformed"
+        addr_regex = r"<(0x[0-9a-f]{1,8} ?)+>"
+        assert re.search(addr_regex, initrd_start), \
+            f"initrd start {initrd_start} malformed"
+        assert re.search(addr_regex, initrd_end), \
+            f"initrd end {initrd_end} malformed"
diff --git a/test/strategy.py b/test/strategy.py
index bf4dacfefd81..fc65895daece 100644
--- a/test/strategy.py
+++ b/test/strategy.py
@@ -6,6 +6,7 @@ import attr
 import pytest
 import subprocess
 import re
+from contextlib import contextmanager
 
 from labgrid import target_factory, step, driver
 from labgrid.strategy import Strategy, StrategyError
@@ -71,6 +72,20 @@ class BareboxTestStrategy(Strategy):
             )
         self.status = status
 
+    @contextmanager
+    def boot(self, boottarget=None):
+        self.transition(Status.barebox)
+
+        try:
+            self.barebox.boot(boottarget)
+            self.target.deactivate(self.barebox)
+            self.target.activate(self.barebox)
+            yield
+        finally:
+            self.target.deactivate(self.barebox)
+            self.power.cycle()
+            self.target.activate(self.barebox)
+
     def force(self, state):
         self.transition(Status.off)  # pylint: disable=missing-kwoa
 
-- 
2.47.3




                 reply	other threads:[~2025-10-21  6:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251021064851.775660-1-a.fatoum@barebox.org \
    --to=a.fatoum@barebox.org \
    --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