From patchwork Wed Jun 4 14:03:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 64284 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 4BB20C61CE7 for ; Wed, 4 Jun 2025 14:03:33 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.17363.1749045811442298593 for ; Wed, 04 Jun 2025 07:03:31 -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 E3A8D1758 for ; Wed, 4 Jun 2025 07:03:13 -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 9F9E63F5A1 for ; Wed, 4 Jun 2025 07:03:30 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 1/4] recipetool/create: show more of the license path when it can't be identified Date: Wed, 4 Jun 2025 15:03:22 +0100 Message-ID: <20250604140326.2214919-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 ; Wed, 04 Jun 2025 14:03:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/217947 If there are multiple source trees in a project (incredibly common with go-mod, for example) then the relative path of the LICENSE file from the source tree could just be "LICENSE", which is not useful when there are tens of files across the recipe with that name. Show the parent directory name too, to clarify which file is unknown. Signed-off-by: Ross Burton --- scripts/lib/recipetool/create.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lib/recipetool/create.py b/scripts/lib/recipetool/create.py index ea2ef5be637..94d52d60772 100644 --- a/scripts/lib/recipetool/create.py +++ b/scripts/lib/recipetool/create.py @@ -1250,7 +1250,7 @@ def match_licenses(licfiles, srctree, d): license = 'Unknown' logger.info("Please add the following line for '%s' to a 'lib/recipetool/licenses.csv' " \ "and replace `Unknown` with the license:\n" \ - "%s,Unknown" % (os.path.relpath(licfile, srctree), md5value)) + "%s,Unknown" % (os.path.relpath(licfile, srctree + "/.."), md5value)) if license: licenses.append((license, os.path.relpath(licfile, srctree), md5value)) From patchwork Wed Jun 4 14:03:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 64285 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 4A9FDC5B549 for ; Wed, 4 Jun 2025 14:03:33 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.17364.1749045812207050862 for ; Wed, 04 Jun 2025 07:03:32 -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 927051758 for ; Wed, 4 Jun 2025 07:03:14 -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 506A73F5A1 for ; Wed, 4 Jun 2025 07:03:31 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 2/4] scripts/scriptutils: silence warning about S not existing in emptysrc Date: Wed, 4 Jun 2025 15:03:23 +0100 Message-ID: <20250604140326.2214919-2-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604140326.2214919-1-ross.burton@arm.com> References: <20250604140326.2214919-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 ; Wed, 04 Jun 2025 14:03:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/217948 This function creates an emptysrc recipe, but S points to a directory that doesn't exist and bitbake warns about this. As it is under the temporary working directory which will be deleted later, create it to silence the warning. Signed-off-by: Ross Burton --- scripts/lib/scriptutils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/lib/scriptutils.py b/scripts/lib/scriptutils.py index 81f0b01fa53..32e749dbb1a 100644 --- a/scripts/lib/scriptutils.py +++ b/scripts/lib/scriptutils.py @@ -182,7 +182,10 @@ def fetch_url(tinfoil, srcuri, srcrev, destdir, logger, preserve_tmp=False, mirr f.write('UNPACKDIR = "%s"\n' % destdir) # Set S out of the way so it doesn't get created under the workdir - f.write('S = "%s"\n' % os.path.join(tmpdir, 'emptysrc')) + s_dir = os.path.join(tmpdir, 'emptysrc') + bb.utils.mkdirhier(s_dir) + f.write('S = "%s"\n' % s_dir) + if not mirrors: # We do not need PREMIRRORS since we are almost certainly # fetching new source rather than something that has already From patchwork Wed Jun 4 14:03:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 64283 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 46CD9C5B543 for ; Wed, 4 Jun 2025 14:03:33 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.17364.1749045812650514546 for ; Wed, 04 Jun 2025 07:03:32 -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 3A74625E3 for ; Wed, 4 Jun 2025 07:03:15 -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 010BF3F5A1 for ; Wed, 4 Jun 2025 07:03:31 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 3/4] lib/oeqa/subprocesstweak: clean up __str__() Date: Wed, 4 Jun 2025 15:03:24 +0100 Message-ID: <20250604140326.2214919-3-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604140326.2214919-1-ross.burton@arm.com> References: <20250604140326.2214919-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 ; Wed, 04 Jun 2025 14:03:33 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/217949 Call super().__str__ to get the bulk of the string representation, and we don't need to guard on output/strerr existing as they always set. Signed-off-by: Ross Burton --- meta/lib/oeqa/utils/subprocesstweak.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/meta/lib/oeqa/utils/subprocesstweak.py b/meta/lib/oeqa/utils/subprocesstweak.py index 3e43ed547bd..1774513023b 100644 --- a/meta/lib/oeqa/utils/subprocesstweak.py +++ b/meta/lib/oeqa/utils/subprocesstweak.py @@ -8,16 +8,11 @@ import subprocess class OETestCalledProcessError(subprocess.CalledProcessError): def __str__(self): def strify(o): - if isinstance(o, bytes): - return o.decode("utf-8", errors="replace") - else: - return o + return o.decode("utf-8", errors="replace") if isinstance(o, bytes) else o - s = "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode) - if hasattr(self, "output") and self.output: - s = s + "\nStandard Output: " + strify(self.output) - if hasattr(self, "stderr") and self.stderr: - s = s + "\nStandard Error: " + strify(self.stderr) + s = super().__str__() + s = s + "\nStandard Output: " + strify(self.output) + s = s + "\nStandard Error: " + strify(self.stderr) return s def errors_have_output(): From patchwork Wed Jun 4 14:03:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Burton X-Patchwork-Id: 64286 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 27606C5B543 for ; Wed, 4 Jun 2025 14:03:43 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.17365.1749045813297261155 for ; Wed, 04 Jun 2025 07:03:33 -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 D61E61758 for ; Wed, 4 Jun 2025 07:03:15 -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 9D4BE3F5A1 for ; Wed, 4 Jun 2025 07:03:32 -0700 (PDT) From: Ross Burton To: openembedded-core@lists.openembedded.org Subject: [PATCH 4/4] oeqa/selftest: add test case for oeqa.utils.subprocesstweak Date: Wed, 4 Jun 2025 15:03:25 +0100 Message-ID: <20250604140326.2214919-4-ross.burton@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250604140326.2214919-1-ross.burton@arm.com> References: <20250604140326.2214919-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 ; Wed, 04 Jun 2025 14:03:43 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/217950 This class has a monkey-patched CalledProcessError instance that extends the __str__ method. Add a test case to ensure that it behaves as expected. Signed-off-by: Ross Burton --- meta/lib/oeqa/selftest/cases/liboe.py | 35 ++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/cases/liboe.py b/meta/lib/oeqa/selftest/cases/liboe.py index d5ffffdcb41..4eab9441435 100644 --- a/meta/lib/oeqa/selftest/cases/liboe.py +++ b/meta/lib/oeqa/selftest/cases/liboe.py @@ -9,7 +9,7 @@ from oeqa.utils.commands import get_bb_var, get_bb_vars, bitbake, runCmd import oe.path import os -class LibOE(OESelftestTestCase): +class CopyTreeTests(OESelftestTestCase): @classmethod def setUpClass(cls): @@ -102,3 +102,36 @@ class LibOE(OESelftestTestCase): self.assertEqual(dstcnt, len(testfiles), "Number of files in dst (%s) differs from number of files in src(%s)." % (dstcnt, srccnt)) oe.path.remove(testloc) + +class SubprocessTests(OESelftestTestCase): + + def test_subprocess_tweak(self): + """ + Test that the string representation of + oeqa.utils.subprocesstweak.OETestCalledProcessError includes stdout and + stderr, as expected. + """ + script = """ +#! /bin/sh +echo Ivn fgqbhg | tr '[a-zA-Z]' '[n-za-mN-ZA-M]' +echo Ivn fgqree | tr '[a-zA-Z]' '[n-za-mN-ZA-M]' >&2 +exit 42 + """ + + import subprocess + import unittest.mock + from oeqa.utils.subprocesstweak import OETestCalledProcessError + + with self.assertRaises(OETestCalledProcessError) as cm: + with unittest.mock.patch("subprocess.CalledProcessError", OETestCalledProcessError): + subprocess.run(["bash", "-"], input=script, text=True, capture_output=True, check=True) + + e = cm.exception + self.assertEqual(e.returncode, 42) + self.assertEqual("Via stdout\n", e.stdout) + self.assertEqual("Via stderr\n", e.stderr) + + string = str(e) + self.assertIn("exit status 42", string) + self.assertIn("Standard Output: Via stdout", string) + self.assertIn("Standard Error: Via stderr", string)