From patchwork Tue Jun 17 17:13:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 65160 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 B3325C7115B for ; Tue, 17 Jun 2025 17:13:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.25102.1750180419951578642 for ; Tue, 17 Jun 2025 10:13:40 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 7A68D150C for ; Tue, 17 Jun 2025 10:13:18 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 0AD003F673 for ; Tue, 17 Jun 2025 10:13:38 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/4] oeqa/utils/command: fast-path get_bb_var() Date: Tue, 17 Jun 2025 18:13:29 +0100 Message-ID: <20250617171332.3162295-1-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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 ; Tue, 17 Jun 2025 17:13:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/218910 get_bb_var() currently end up calling 'bitbake -e' and parsing the whole output. However if postconfig isn't set then we can speed this up by just calling bitbake-getvar. Signed-off-by: Ross Burton --- meta/lib/oeqa/utils/commands.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 2a47f90e327..bfe69474149 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -285,7 +285,14 @@ def get_bb_vars(variables=None, target=None, postconfig=None): return values def get_bb_var(var, target=None, postconfig=None): - return get_bb_vars([var], target, postconfig)[var] + if postconfig: + return bitbake("-e %s" % target or "", postconfig=postconfig).output + else: + # Fast-path for the non-postconfig case + cmd = ["bitbake-getvar", "--value", var] + if target: + cmd.extend(["--recipe", target]) + return subprocess.run(cmd, check=True, text=True, stdout=subprocess.PIPE).stdout.strip() def get_test_layer(bblayers=None): if bblayers is None: From patchwork Tue Jun 17 17:13:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 65162 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 C79CCC7115E for ; Tue, 17 Jun 2025 17:13:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.25143.1750180420480226844 for ; Tue, 17 Jun 2025 10:13:40 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1FA5F150C for ; Tue, 17 Jun 2025 10:13:19 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id B02F43F673 for ; Tue, 17 Jun 2025 10:13:39 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/4] scripts/test-remote-image: remove useless postconfig arguments Date: Tue, 17 Jun 2025 18:13:30 +0100 Message-ID: <20250617171332.3162295-2-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617171332.3162295-1-ross.burton@arm.com> References: <20250617171332.3162295-1-ross.burton@arm.com> MIME-Version: 1.0 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 ; Tue, 17 Jun 2025 17:13:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/218911 I can't see a reason for this script to need to use postconfig files to bounce a variable assignment through another, so remove them. Signed-off-by: Ross Burton --- scripts/test-remote-image | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/scripts/test-remote-image b/scripts/test-remote-image index d209d228544..1d018992b07 100755 --- a/scripts/test-remote-image +++ b/scripts/test-remote-image @@ -152,8 +152,7 @@ class AutoTargetProfile(BaseTargetProfile): return controller def set_kernel_file(self): - postconfig = "QA_GET_MACHINE = \"${MACHINE}\"" - machine = get_bb_var('QA_GET_MACHINE', postconfig=postconfig) + machine = get_bb_var('MACHINE') self.kernel_file = self.kernel_type + '-' + machine + '.bin' def set_rootfs_file(self): @@ -215,13 +214,11 @@ class PublicAB(BaseRepoProfile): def get_repo_path(self): path = '/machines/' - postconfig = "QA_GET_MACHINE = \"${MACHINE}\"" - machine = get_bb_var('QA_GET_MACHINE', postconfig=postconfig) + machine = get_bb_var('MACHINE') if 'qemu' in machine: path += 'qemu/' - postconfig = "QA_GET_DISTRO = \"${DISTRO}\"" - distro = get_bb_var('QA_GET_DISTRO', postconfig=postconfig) + distro = get_bb_var('DISTRO') path += distro.replace('poky', machine) + '/' return path From patchwork Tue Jun 17 17:13:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 65161 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 B32DAC71136 for ; Tue, 17 Jun 2025 17:13:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.25103.1750180421179772360 for ; Tue, 17 Jun 2025 10:13:41 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BB5DD150C for ; Tue, 17 Jun 2025 10:13:19 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 584413F673 for ; Tue, 17 Jun 2025 10:13:40 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/4] oeqa/selftest/esdk: remove postconfig argument Date: Tue, 17 Jun 2025 18:13:31 +0100 Message-ID: <20250617171332.3162295-3-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617171332.3162295-1-ross.burton@arm.com> References: <20250617171332.3162295-1-ross.burton@arm.com> MIME-Version: 1.0 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 ; Tue, 17 Jun 2025 17:13:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/218912 Discovered when looking for users of get_bb_var()'s postconfig argument, this wrapper around runCmd() has a postconfig argument that has odd behaviour: it _appends_ the new configuration to local.conf instead of having them used for this specific run (unlike the other functions in commands.py) None of the eSDK tests use this functionality, so remove it. Future test cases that need to write further configuration should do so directly. Signed-off-by: Ross Burton --- meta/lib/oeqa/selftest/cases/esdk.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/meta/lib/oeqa/selftest/cases/esdk.py b/meta/lib/oeqa/selftest/cases/esdk.py index 9f5de2cde7f..7a5fe00a082 100644 --- a/meta/lib/oeqa/selftest/cases/esdk.py +++ b/meta/lib/oeqa/selftest/cases/esdk.py @@ -27,11 +27,7 @@ class oeSDKExtSelfTest(OESelftestTestCase): return glob.glob(pattern)[0] @staticmethod - def run_esdk_cmd(env_eSDK, tmpdir_eSDKQA, cmd, postconfig=None, **options): - if postconfig: - esdk_conf_file = os.path.join(tmpdir_eSDKQA, 'conf', 'local.conf') - with open(esdk_conf_file, 'a+') as f: - f.write(postconfig) + def run_esdk_cmd(env_eSDK, tmpdir_eSDKQA, cmd, **options): if not options: options = {} if not 'shell' in options: From patchwork Tue Jun 17 17:13:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 65163 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 B5104C71157 for ; Tue, 17 Jun 2025 17:13:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.25144.1750180421771007594 for ; Tue, 17 Jun 2025 10:13:41 -0700 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ross.burton@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 637ED150C for ; Tue, 17 Jun 2025 10:13:20 -0700 (PDT) Received: from cesw-amp-gbt-1s-m12830-04.lab.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 003503F673 for ; Tue, 17 Jun 2025 10:13:40 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 4/4] oeqa/selftest: add new test for toolchain switching Date: Tue, 17 Jun 2025 18:13:32 +0100 Message-ID: <20250617171332.3162295-4-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250617171332.3162295-1-ross.burton@arm.com> References: <20250617171332.3162295-1-ross.burton@arm.com> MIME-Version: 1.0 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 ; Tue, 17 Jun 2025 17:13:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/218913 Add a basic test for the toolchain switching code: set the toolchain to GCC by default but Clang for a specific recipe, and verify that two recipes are built with the expected compiler. This works because before we strip the installed binaries there is a .comment segment that contains the list of toolchains used. Signed-off-by: Ross Burton --- meta/lib/oeqa/selftest/cases/toolchain.py | 71 +++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 meta/lib/oeqa/selftest/cases/toolchain.py diff --git a/meta/lib/oeqa/selftest/cases/toolchain.py b/meta/lib/oeqa/selftest/cases/toolchain.py new file mode 100644 index 00000000000..b4b280d0375 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/toolchain.py @@ -0,0 +1,71 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +import shutil +import subprocess +import tempfile +from types import SimpleNamespace + +import oe.path +from oeqa.selftest.case import OESelftestTestCase +from oeqa.utils.commands import bitbake, get_bb_var, get_bb_vars + +class ToolchainTests(OESelftestTestCase): + + def test_toolchain_switching(self): + """ + Test that a configuration that uses GCC by default but clang for one + specific recipe does infact do that. + """ + + def extract_comment(objcopy, filename): + """ + Using the specified `objcopy`, return the .comment segment from + `filename` as a bytes(). + """ + with tempfile.NamedTemporaryFile(prefix="comment-") as f: + cmd = [objcopy, "--dump-section", ".comment=" + f.name, filename] + subprocess.run(cmd, check=True) + # clang's objcopy writes to a temporary file and renames, so we need to re-open. + with open(f.name, "rb") as f2: + return f2.read() + + def check_recipe(recipe, filename, override, comment_present, comment_absent=None): + """ + Check that `filename` in `recipe`'s bindir contains `comment`, and + the overrides contain `override`. + """ + d = SimpleNamespace(**get_bb_vars(("D", "bindir", "OBJCOPY", "OVERRIDES", "PATH"), target=recipe)) + + self.assertIn(override, d.OVERRIDES) + + binary = oe.path.join(d.D, d.bindir, filename) + + objcopy = shutil.which(d.OBJCOPY, path=d.PATH) + self.assertIsNotNone(objcopy) + + comment = extract_comment(objcopy, binary) + self.assertIn(comment_present, comment) + if comment_absent: + self.assertNotIn(comment_absent, comment) + + + # GCC by default, clang for selftest-hello. + self.write_config(""" +TOOLCHAIN = "gcc" +TOOLCHAIN:pn-selftest-hello = "clang" + """) + + # Force these recipes to re-install so we can extract the .comments from + # the install directory, as they're stripped out of the final packages. + bitbake("m4 selftest-hello -C install") + + # m4 should be built with GCC and only GCC + check_recipe("m4", "m4", "toolchain-gcc", b"GCC: (GNU)", b"clang") + + # helloworld should be built with clang. We can't assert that GCC is not + # present as it will be linked against glibc which is built with GCC. + check_recipe("selftest-hello", "helloworld", "toolchain-clang", b"clang version")