This allows defining non-standard patterns from QEMU tests just as they
are already supported by the testimage.bbclass.

Will allow testing non-Linux shells in QEMU, too, e.g. a U-Boot or other
bootloader shell.

Signed-off-by: Enrico Jorns <[email protected]>
---
 meta/lib/oeqa/targetcontrol.py    | 5 +++--
 meta/lib/oeqa/utils/commands.py   | 5 +++--
 meta/lib/oeqa/utils/qemurunner.py | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py
index 1fdff82889..43a213ac0e 100644
--- a/meta/lib/oeqa/targetcontrol.py
+++ b/meta/lib/oeqa/targetcontrol.py
@@ -92,7 +92,7 @@ class QemuTarget(BaseTarget):
 
     supported_image_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
 
-    def __init__(self, d, logger, image_fstype=None):
+    def __init__(self, d, logger, image_fstype=None, boot_patterns=None):
 
         import oe.types
 
@@ -148,7 +148,8 @@ class QemuTarget(BaseTarget):
                             dump_host_cmds = d.getVar("testimage_dump_host"),
                             logger = logger,
                             tmpfsdir = d.getVar("RUNQEMU_TMPFS_DIR"),
-                            serial_ports = 
len(d.getVar("SERIAL_CONSOLES").split()))
+                            serial_ports = 
len(d.getVar("SERIAL_CONSOLES").split()),
+                            boot_patterns = boot_patterns)
 
         self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, 
self.runner)
         self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, 
self.runner)
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index efbb6ab6f2..1f6a617367 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -312,7 +312,7 @@ def create_temp_layer(templayerdir, templayername, 
priority=999, recipepathspec=
         f.write('LAYERSERIES_COMPAT_%s = "%s"\n' % (templayername, corenames))
 
 @contextlib.contextmanager
-def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, 
launch_cmd=None, qemuparams=None, overrides={}, discard_writes=True):
+def runqemu(pn, ssh=True, runqemuparams='', image_fstype=None, 
launch_cmd=None, qemuparams=None, overrides={}, boot_patterns = {}, 
discard_writes=True):
     """
     Starts a context manager for a 'oeqa.targetcontrol.QemuTarget' resource.
     The underlying Qemu will be booted into a shell when the generator yields.
@@ -329,6 +329,7 @@ def runqemu(pn, ssh=True, runqemuparams='', 
image_fstype=None, launch_cmd=None,
         image_fstype (str): IMAGE_FSTYPE to use
         launch_cmd (str): directly run this command and bypass automatic 
runqemu parameter generation
         overrides (dict): dict of "'<bitbake-variable>': value" pairs that 
allows overriding bitbake variables
+        boot_patterns (dict): dict of "'<pattern-name>': value" pairs to 
override default boot patterns, e.g. when not booting Linux
         discard_writes (boolean): enables qemu -snapshot feature to prevent 
modifying original image
     """
 
@@ -360,7 +361,7 @@ def runqemu(pn, ssh=True, runqemuparams='', 
image_fstype=None, launch_cmd=None,
 
         logdir = recipedata.getVar("TEST_LOG_DIR")
 
-        qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, 
image_fstype)
+        qemu = oeqa.targetcontrol.QemuTarget(recipedata, targetlogger, 
image_fstype, boot_patterns=boot_patterns)
     finally:
         # We need to shut down tinfoil early here in case we actually want
         # to run tinfoil-using utilities with the running QEMU instance.
diff --git a/meta/lib/oeqa/utils/qemurunner.py 
b/meta/lib/oeqa/utils/qemurunner.py
index 1e544acc90..0d64df7253 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -93,7 +93,7 @@ class QemuRunner:
 
         # Only override patterns that were set e.g. login user 
TESTIMAGE_BOOT_PATTERNS[send_login_user] = "webserver\n"
         for pattern in accepted_patterns:
-            if not self.boot_patterns[pattern]:
+            if pattern not in self.boot_patterns or not 
self.boot_patterns[pattern]:
                 self.boot_patterns[pattern] = default_boot_patterns[pattern]
 
     def create_socket(self):
-- 
2.39.2

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#179419): 
https://lists.openembedded.org/g/openembedded-core/message/179419
Mute This Topic: https://lists.openembedded.org/mt/97970642/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to