From patchwork Thu Oct 10 06:29:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Enrico_J=C3=B6rns?= X-Patchwork-Id: 50194 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64141CF07AE for ; Thu, 10 Oct 2024 06:30:57 +0000 (UTC) Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [185.203.201.7]) by mx.groups.io with SMTP id smtpd.web11.37357.1728541849308035811 for ; Wed, 09 Oct 2024 23:30:49 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: pengutronix.de, ip: 185.203.201.7, mailfrom: ejo@pengutronix.de) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1symhB-0005vq-6a; Thu, 10 Oct 2024 08:30:45 +0200 Received: from [2a0a:edc0:0:1101:1d::5c] (helo=dude06.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1symhA-000mLT-6V; Thu, 10 Oct 2024 08:30:44 +0200 Received: from ejo by dude06.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1symhA-006tna-0R; Thu, 10 Oct 2024 08:30:44 +0200 From: =?utf-8?q?Enrico_J=C3=B6rns?= To: openembedded-core@lists.openembedded.org Cc: yocto@pengutronix.de, Alexander Kanavin , Richard Purdie , Ahmad Fatoum Subject: [PATCH v8 5/7] oeqa: support passing custom boot patterns to runqemu Date: Thu, 10 Oct 2024 08:29:39 +0200 Message-Id: <20241010062941.1644325-6-ejo@pengutronix.de> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20241010062941.1644325-1-ejo@pengutronix.de> References: <20241010062941.1644325-1-ejo@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ejo@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: openembedded-core@lists.openembedded.org List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Thu, 10 Oct 2024 06:30:57 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/205377 From: Enrico Jorns 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 shell or another bootloader shell). Signed-off-by: Enrico Jorns --- 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 6e8b781973..cdf382ee21 100644 --- a/meta/lib/oeqa/targetcontrol.py +++ b/meta/lib/oeqa/targetcontrol.py @@ -88,7 +88,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 @@ -141,7 +141,8 @@ class QemuTarget(BaseTarget): dump_dir = dump_dir, 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.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner) if (self.monitor_dumper): diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index bf2f49d0c0..ca22d69f29 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 @@ -330,6 +330,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 "'': value" pairs that allows overriding bitbake variables + boot_patterns (dict): dict of "'': 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 """ @@ -361,7 +362,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 63fc6f6b53..5c3a8e5999 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py @@ -103,7 +103,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):