The current boot helper activates the barebox strategy with the assumption that barebox is booting itself, which is indeed the case in the FIT boot test.
In preparation for adding customized boot tests of actual kernels (and not only barebox masquerading as one), rename it to boot_barebox and add boot_kernel, which behaves similarly, but activates the shell driver. Additionally, add support for using bootm instead of boot, which is more convenient if we have no script, no ESP and no bootloader spec file. Signed-off-by: Ahmad Fatoum <[email protected]> --- test/py/test_fit.py | 2 +- test/strategy.py | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/test/py/test_fit.py b/test/py/test_fit.py index 97fdac0c79d9..e0999a01b0cb 100644 --- a/test/py/test_fit.py +++ b/test/py/test_fit.py @@ -78,7 +78,7 @@ def test_fit(barebox, strategy, testfs, fit_testdata): boottarget = generate_bootscript(barebox, fit_name('gzipped')) - with strategy.boot(boottarget): + with strategy.boot_barebox(boottarget) as barebox: assert of_get_property(barebox, "/chosen/barebox-version") == f'"{ver}"', \ "/chosen/barebox-version suggests we did not chainload" diff --git a/test/strategy.py b/test/strategy.py index 0ca08b0cdd15..c04d38c180a7 100644 --- a/test/strategy.py +++ b/test/strategy.py @@ -86,20 +86,50 @@ class BareboxTestStrategy(Strategy): ) self.status = status + def barebox_bootm(self, image=None): + self.barebox._run(f"global.loglevel={self.barebox.saved_log_level}", + adjust_log_level=False) + if image: + self.console.sendline(f"bootm -v {image}") + else: + self.console.sendline("bootm -v") + @contextmanager - def boot(self, boottarget=None): + def boot_barebox(self, boottarget=None, bootm=False): self.transition(Status.barebox) try: - self.barebox.boot(boottarget) + if bootm: + self.barebox_bootm(boottarget) + else: + self.barebox.boot(boottarget) + self.target.deactivate(self.barebox) self.target.activate(self.barebox) - yield + yield self.barebox finally: self.target.deactivate(self.barebox) self.power.cycle() self.target.activate(self.barebox) + @contextmanager + def boot_kernel(self, boottarget=None, bootm=False): + self.transition(Status.barebox) + + try: + if bootm: + self.barebox_bootm(boottarget) + else: + self.barebox.boot(boottarget) + + self.barebox.await_boot() + self.target.activate(self.shell) + yield self.shell + finally: + self.target.deactivate(self.shell) + self.power.cycle() + self.target.activate(self.barebox) + def force(self, state): self.transition(Status.off) # pylint: disable=missing-kwoa -- 2.47.3
