summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-06 14:09:02 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-10-09 09:26:35 +0100
commit4ede48f660dd360a39cbb9e156d3638c89e9301d (patch)
tree04a3cbd2f50e83c251e21e4d35c641b396737dbf
parent3c1ef0d520273835f89981bb336ce9dd6e23b9fd (diff)
downloadpoky-4ede48f660dd360a39cbb9e156d3638c89e9301d.tar.gz
oeqa/selftest: Fix single threaded race issue
oe-selftest sets up separate build directories to run the tests in. To to this, environment paths pointing at the previous build directory are updated. In the multi-threaded case this is fine as the thread is destroyed and the parent remains unchanged but in the single threaded case, the environment is broken afterwards. This can mean we try and access a directory which is in the process of being deleted (e.g. by clobberdir). Restore the environment afterwards regardless to ensure the single threaded case doesn't try and access the build directory which is now being deleted. (From OE-Core rev: a165bec28ffc75fd44b1fdb02a0d3a80c5a4769b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/context.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index 16f82c6737..c9eb481725 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -44,9 +44,13 @@ class NonConcurrentTestSuite(unittest.TestSuite):
44 self.bb_vars = bb_vars 44 self.bb_vars = bb_vars
45 45
46 def run(self, result): 46 def run(self, result):
47 origenv = os.environ.copy()
47 (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite) 48 (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite)
48 ret = super().run(result) 49 ret = super().run(result)
50 # In forks we don't have to restore but in a single process, restore cwd and the env
49 os.chdir(builddir) 51 os.chdir(builddir)
52 for e in origenv:
53 os.environ[e] = origenv[e]
50 if newbuilddir and ret.wasSuccessful() and self.removefunc: 54 if newbuilddir and ret.wasSuccessful() and self.removefunc:
51 self.removefunc(newbuilddir) 55 self.removefunc(newbuilddir)
52 56