@@ -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")
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(+)