Skip to content

Commit d02396e

Browse files
Merge pull request labgrid-project#1071 from meuren/bareboxdriver_boot_command
driver/bareboxdriver.py: Add parameter 'boot_command'
2 parents ecb6fe5 + cdcc5b4 commit d02396e

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

doc/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,7 @@ Arguments:
19991999
boots (for barebox >=v2025.03.0).
20002000
- bootstring (regex, default="Linux version \\d"): regex that indicating that the Linux Kernel is
20012001
booting
2002+
- boot_command (str, default="boot -v"): optional, boot command to boot target
20022003
- password (str): optional, password to use for access to the shell
20032004
- login_timeout (int, default=60): timeout for access to the shell
20042005

labgrid/driver/bareboxdriver.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class BareboxDriver(CommandMixin, Driver, CommandProtocol, LinuxBootProtocol):
2727
interrupt (str): optional, string to interrupt autoboot (use "\x03" for CTRL-C)
2828
bootstring (regex): optional, regex indicating that the Linux Kernel is booting
2929
password (str): optional, password to use for access to the shell
30+
boot_command (str): optional, boot command to boot target
3031
login_timeout (int): optional, timeout for access to the shell
3132
"""
3233
bindings = {"console": ConsoleProtocol, }
@@ -35,6 +36,7 @@ class BareboxDriver(CommandMixin, Driver, CommandProtocol, LinuxBootProtocol):
3536
interrupt = attr.ib(default="\x04", validator=attr.validators.instance_of(str))
3637
bootstring = attr.ib(default=r"Linux version \d", validator=attr.validators.instance_of(str))
3738
password = attr.ib(default="", validator=attr.validators.instance_of(str))
39+
boot_command = attr.ib(default="boot -v", validator=attr.validators.instance_of(str))
3840
login_timeout = attr.ib(default=60, validator=attr.validators.instance_of(int))
3941

4042
def __attrs_post_init__(self):
@@ -213,7 +215,7 @@ def await_boot(self):
213215
self.console.expect(self.bootstring)
214216

215217
@Driver.check_active
216-
def boot(self, name: str):
218+
def boot(self, name: str = ""):
217219
"""Boot the default or a specific boot entry
218220
219221
Args:
@@ -224,4 +226,4 @@ def boot(self, name: str):
224226
if name:
225227
self.console.sendline(f"boot -v {name}")
226228
else:
227-
self.console.sendline("boot -v")
229+
self.console.sendline(self.boot_command)

tests/test_bareboxdriver.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,16 @@ def test_barebox_run_error(self, target_with_fakeconsole, mocker):
4141
res = d.run_check("test")
4242
res = d.run("test")
4343
assert res == (['error'], [], 1)
44+
45+
def test_barebox_boot(self, target_with_fakeconsole, mocker):
46+
t = target_with_fakeconsole
47+
d = BareboxDriver(t, "barebox", boot_command='boot -v foo')
48+
d = t.get_driver(BareboxDriver, activate=False)
49+
# mock for d._run('echo $global.loglevel')
50+
d._run = mocker.MagicMock(return_value=(['7'], [], 0))
51+
t.activate(d)
52+
d._run = mocker.MagicMock(return_value=(['success'], [], 0))
53+
d.boot()
54+
assert d.console.txq.pop() == b"boot -v foo\n"
55+
d.boot(name='bar')
56+
assert d.console.txq.pop() == b"boot -v bar\n"

0 commit comments

Comments
 (0)