From 18b0567051d298280c466493df54b81822de0a33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Hofrichter?= Date: Tue, 9 Sep 2025 12:26:17 +0200 Subject: [PATCH] strategy: add arguments wait_for_systemd and systemd_timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the following arguments to the strategies BareboxStrategy, ShellStrategy and UBootStrategy: - wait_for_systemd: If True, wait for all systemd services to be up and running when transitioning to the "shell" state default: True - systemd_timeout: Timeout to wait for systemd services in seconds default: 30 Signed-off-by: Jörg Hofrichter --- doc/configuration.rst | 15 +++++++++++++++ labgrid/strategy/bareboxstrategy.py | 11 ++++++++++- labgrid/strategy/shellstrategy.py | 11 ++++++++++- labgrid/strategy/ubootstrategy.py | 11 ++++++++++- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/doc/configuration.rst b/doc/configuration.rst index d93e58c90..53647fbb4 100644 --- a/doc/configuration.rst +++ b/doc/configuration.rst @@ -3458,6 +3458,11 @@ the "shell" state: This command would transition from the bootloader into a Linux shell and activate the `ShellDriver`_. +Arguments: + - wait_for_systemd (bool, default=True): If True, wait for all systemd services + to be up and running when transitioning to the "shell" state + - systemd_timeout (int, default=30): Timeout to wait for systemd services in seconds + ShellStrategy ~~~~~~~~~~~~~ A :any:`ShellStrategy` has three states: @@ -3504,6 +3509,11 @@ the "shell" state: This command would transition directly into a Linux shell and activate the `ShellDriver`_. +Arguments: + - wait_for_systemd (bool, default=True): If True, wait for all systemd services + to be up and running when transitioning to the "shell" state + - systemd_timeout (int, default=30): Timeout to wait for systemd services in seconds + UBootStrategy ~~~~~~~~~~~~~ A :any:`UBootStrategy` has four states: @@ -3553,6 +3563,11 @@ the "shell" state: This command would transition from the bootloader into a Linux shell and activate the `ShellDriver`_. +Arguments: + - wait_for_systemd (bool, default=True): If True, wait for all systemd services + to be up and running when transitioning to the "shell" state + - systemd_timeout (int, default=30): Timeout to wait for systemd services in seconds + DockerStrategy ~~~~~~~~~~~~~~ A :any:`DockerStrategy` has three states: diff --git a/labgrid/strategy/bareboxstrategy.py b/labgrid/strategy/bareboxstrategy.py index 8cae9eb6a..c2533e19d 100644 --- a/labgrid/strategy/bareboxstrategy.py +++ b/labgrid/strategy/bareboxstrategy.py @@ -26,6 +26,14 @@ class BareboxStrategy(Strategy): } status = attr.ib(default=Status.unknown) + wait_for_systemd = attr.ib( + default=True, + validator=attr.validators.optional(attr.validators.instance_of(bool)) + ) + systemd_timeout = attr.ib( + default=30, + validator=attr.validators.optional(attr.validators.instance_of(int)) + ) def __attrs_post_init__(self): super().__attrs_post_init__() @@ -57,7 +65,8 @@ def transition(self, status, *, step): # pylint: disable=redefined-outer-name self.barebox.boot("") self.barebox.await_boot() self.target.activate(self.shell) - self.shell.run("systemctl is-system-running --wait") + if self.wait_for_systemd: + self.shell.run("systemctl is-system-running --wait", timeout=self.systemd_timeout) else: raise StrategyError( f"no transition found from {self.status} to {status}" diff --git a/labgrid/strategy/shellstrategy.py b/labgrid/strategy/shellstrategy.py index 0f2c7ed7a..a6cf5ca81 100644 --- a/labgrid/strategy/shellstrategy.py +++ b/labgrid/strategy/shellstrategy.py @@ -24,6 +24,14 @@ class ShellStrategy(Strategy): } status = attr.ib(default=Status.unknown) + wait_for_systemd = attr.ib( + default=True, + validator=attr.validators.optional(attr.validators.instance_of(bool)) + ) + systemd_timeout = attr.ib( + default=30, + validator=attr.validators.optional(attr.validators.instance_of(int)) + ) def __attrs_post_init__(self): super().__attrs_post_init__() @@ -47,7 +55,8 @@ def transition(self, status, *, step): # pylint: disable=redefined-outer-name self.target.activate(self.console) self.power.cycle() self.target.activate(self.shell) - self.shell.run("systemctl is-system-running --wait") + if self.wait_for_systemd: + self.shell.run("systemctl is-system-running --wait", timeout=self.systemd_timeout) else: raise StrategyError( f"no transition found from {self.status} to {status}" diff --git a/labgrid/strategy/ubootstrategy.py b/labgrid/strategy/ubootstrategy.py index 8cbafc452..94cc3572d 100644 --- a/labgrid/strategy/ubootstrategy.py +++ b/labgrid/strategy/ubootstrategy.py @@ -25,6 +25,14 @@ class UBootStrategy(Strategy): } status = attr.ib(default=Status.unknown) + wait_for_systemd = attr.ib( + default=True, + validator=attr.validators.optional(attr.validators.instance_of(bool)) + ) + systemd_timeout = attr.ib( + default=30, + validator=attr.validators.optional(attr.validators.instance_of(int)) + ) def __attrs_post_init__(self): super().__attrs_post_init__() @@ -54,7 +62,8 @@ def transition(self, status): self.uboot.boot("") self.uboot.await_boot() self.target.activate(self.shell) - self.shell.run("systemctl is-system-running --wait") + if self.wait_for_systemd: + self.shell.run("systemctl is-system-running --wait", timeout=self.systemd_timeout) else: raise StrategyError(f"no transition found from {self.status} to {status}") self.status = status