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@xxxxxxxxxxxxxx> Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- 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