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: Rouven Czerwinski <r.czerwinski@pengutronix.de>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 7/7] test: py: strategy: drop no longer needed labgrid workarounds
Date: Tue, 13 Aug 2024 09:02:01 +0200	[thread overview]
Message-ID: <20240813070201.1069847-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240813070201.1069847-1-a.fatoum@pengutronix.de>

We were monkey patching in support for following two Labgrid pull
requests:

  - #1166 ("config: return passed in tool by default")
  - #1212 ("qemudriver: export get_qemu_base_args method")

Both are now part of the newest v24.0 release, so let's drop our
workaround and require that at least Labgrid v24.0 is used.

[1]: https://github.com/labgrid-project/labgrid/commit/69fd553c69
[2]: https://github.com/labgrid-project/labgrid/commit/318e7788ce

Cc: Rouven Czerwinski <r.czerwinski@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  - new patch
---
 test/strategy.py | 53 ++++++++----------------------------------------
 1 file changed, 8 insertions(+), 45 deletions(-)

diff --git a/test/strategy.py b/test/strategy.py
index 8aa58151f6b8..4063b8ff818b 100644
--- a/test/strategy.py
+++ b/test/strategy.py
@@ -6,9 +6,16 @@ import subprocess
 import os
 import shutil
 import sys
+import re
 
 from labgrid import target_factory, step, driver
 from labgrid.strategy import Strategy, StrategyError
+from labgrid.util import labgrid_version
+
+match = re.match(r'^(\d+?)\.', labgrid_version())
+if match is None or int(match.group(1)) < 24:
+    pytest.exit(f"Labgrid has version v{labgrid_version()}, "
+                f"but barebox test suite requires at least v24.")
 
 class Status(enum.Enum):
     unknown = 0
@@ -34,7 +41,6 @@ class BareboxTestStrategy(Strategy):
         super().__attrs_post_init__()
         if isinstance(self.console, driver.QEMUDriver):
             self.qemu = self.console
-        self.patchtools()
 
     @step(args=['status'])
     def transition(self, status, *, step):
@@ -67,7 +73,7 @@ class BareboxTestStrategy(Strategy):
         self.transition(Status.off)  # pylint: disable=missing-kwoa
 
         if state == "qemu_dry_run" or state == "qemu_interactive":
-            cmd = self.get_qemu_base_args()
+            cmd = self.qemu.get_qemu_base_args()
 
             cmd.append("-serial")
             cmd.append("mon:stdio")
@@ -84,44 +90,6 @@ class BareboxTestStrategy(Strategy):
         else:
             pytest.exit('Can only force to: qemu_dry_run, qemu_interactive')
 
-    def get_qemu_base_args(self):
-        if self.qemu is None:
-            pytest.exit('interactive mode only supported with QEMUDriver')
-
-        try:
-            # https://github.com/labgrid-project/labgrid/pull/1212
-            cmd = self.qemu.get_qemu_base_args()
-        except AttributeError:
-            self.qemu.on_activate()
-            orig = self.qemu._cmd
-            cmd = []
-
-            list_iter = enumerate(orig)
-            for i, opt in list_iter:
-                if opt == "-S":
-                    continue
-                opt2 = double_opt(opt, orig, i)
-                if (opt2.startswith("-chardev socket,id=serialsocket") or
-                   opt2 == "-serial chardev:serialsocket" or
-                   opt2 == "-qmp stdio"):
-                    # skip over two elements at once
-                    next(list_iter, None)
-                    continue
-
-                cmd.append(opt)
-
-        return cmd
-
-    def patchtools(self):
-        # https://github.com/labgrid-project/labgrid/commit/69fd553c6969526b609d0be6bb81f0c35f08d1d0
-        if self.qemu is None:
-            return
-
-        if 'tools' not in self.target.env.config.data:
-            self.target.env.config.data['tools'] = {}
-        self.target.env.config.data["tools"][self.qemu.qemu_bin] = \
-                shutil.which(self.qemu.qemu_bin)
-
     def append_qemu_args(self, *args):
         if self.qemu is None:
             pytest.exit('Qemu option supplied for non-Qemu target')
@@ -131,8 +99,3 @@ class BareboxTestStrategy(Strategy):
 def quote_cmd(cmd):
     quoted = map(lambda s : s if s.find(" ") == -1 else "'" + s + "'", cmd)
     return " ".join(quoted)
-
-def double_opt(opt, orig, i):
-    if opt == orig[-1]:
-        return opt
-    return " ".join([opt, orig[i + 1]])
-- 
2.39.2




  parent reply	other threads:[~2024-08-13  7:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-13  7:01 [PATCH 1/7] ci: container: update to Debian Bookworm with GCC v14.2.0 Ahmad Fatoum
2024-08-13  7:01 ` [PATCH 2/7] ci: container: add kvx-elf- toolchain Ahmad Fatoum
2024-08-13  7:01 ` [PATCH 3/7] ci: container: update to newest Labgrid release Ahmad Fatoum
2024-08-13  7:01 ` [PATCH 4/7] test: sandbox: support testing with Labgrid Ahmad Fatoum
2024-08-13  7:01 ` [PATCH 5/7] ci: pytest: test sandbox configuration with labgrid Ahmad Fatoum
2024-08-13  7:02 ` [PATCH 6/7] ci: build: add kvx build test Ahmad Fatoum
2024-08-13  7:02 ` Ahmad Fatoum [this message]
2024-08-14  7:49 ` [PATCH 1/7] ci: container: update to Debian Bookworm with GCC v14.2.0 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=20240813070201.1069847-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=r.czerwinski@pengutronix.de \
    /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