All of lore.kernel.org
 help / color / mirror / Atom feed
From: Babanpreet Singh <bbnpreetsingh@gmail.com>
To: openembedded-core@lists.openembedded.org
Cc: Paul Barker <paul@pbarker.dev>, Ross Burton <ross.burton@arm.com>,
	Babanpreet Singh <bbnpreetsingh@gmail.com>
Subject: [PATCH] oeqa/selftest/oescripts: add a test for oe-init-build-env under set -u
Date: Tue, 24 Nov 2026 19:10:32 +0000	[thread overview]
Message-ID: <20261124191032.7-1-bbnpreetsingh@gmail.com> (raw)
In-Reply-To: <DN2HD431V6TX.3GQ0CXC17IQLQ@pbarker.dev>

Add a test that sources oe-init-build-env from bash and dash with
'set -u', to catch a regression of 81df4c8650 ("oe-init-build-env: fix
unbound variable errors under 'set -u'"). Both fail with that commit
reverted.

[YOCTO #15469]

Suggested-by: Paul Barker <paul@pbarker.dev>
AI-Generated: Uses Claude (claude-opus-5-5)
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
 meta/lib/oeqa/selftest/cases/oescripts.py | 26 +++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/meta/lib/oeqa/selftest/cases/oescripts.py b/meta/lib/oeqa/selftest/cases/oescripts.py
index 3e0bd6f4ec..342e6531df 100644
--- a/meta/lib/oeqa/selftest/cases/oescripts.py
+++ b/meta/lib/oeqa/selftest/cases/oescripts.py
@@ -7,6 +7,7 @@
 import os
 import shutil
 import importlib
+import tempfile
 import unittest
 from oeqa.selftest.case import OESelftestTestCase
 from oeqa.utils.commands import runCmd, bitbake, get_bb_var
@@ -103,6 +104,31 @@ class OEGitproxyTests(OESelftestTestCase):
             self.skipTest("No \"dash\" found on test system.")
         self.run_oegitproxy(custom_shell=dash)
 
+class OEInitBuildEnvTests(OESelftestTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        super().setUpClass()
+        cls.corebase = get_bb_var('COREBASE')
+
+    def run_oe_init_build_env(self, shell):
+        # The environment oe-selftest runs in already sets some of the
+        # variables the script reads, so start from an empty one
+        with tempfile.TemporaryDirectory(prefix="oe-init-build-env-") as builddir:
+            script = 'set -u; . ./oe-init-build-env && echo "BUILDDIR=$BUILDDIR"'
+            result = runCmd([shell, '-c', script, shell, builddir],
+                            cwd=self.corebase, env={'PATH': os.environ['PATH']})
+            self.assertIn('BUILDDIR=' + os.path.realpath(builddir), result.output)
+
+    def test_oe_init_build_env_nounset_bash(self):
+        self.run_oe_init_build_env('bash')
+
+    def test_oe_init_build_env_nounset_dash(self):
+        dash = shutil.which("dash")
+        if dash is None:
+            self.skipTest("No \"dash\" found on test system.")
+        self.run_oe_init_build_env(dash)
+
 class OeRunNativeTest(OESelftestTestCase):
     def test_oe_run_native(self):
         bitbake("qemu-helper-native -c addto_recipe_sysroot")
-- 
2.43.0


      reply	other threads:[~2026-11-24 19:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 19:56 [PATCH] oe-init-build-env: fix unbound variable errors under 'set -u' Babanpreet Singh
2026-11-23  9:25 ` Paul Barker
2026-11-24 19:10   ` Babanpreet Singh [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124191032.7-1-bbnpreetsingh@gmail.com \
    --to=bbnpreetsingh@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=paul@pbarker.dev \
    --cc=ross.burton@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.