diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-27 13:42:00 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-28 08:36:00 +0100 |
commit | 79856aaf934f27fd6ff781d9434c0889b4d93652 (patch) | |
tree | 4ff8a4b25ac720c903984da8f8b7c38916b4583c /meta/lib/oeqa/core/utils/concurrencytest.py | |
parent | add3d45c695793a6ce544cf1189d51be0f42d008 (diff) | |
download | poky-79856aaf934f27fd6ff781d9434c0889b4d93652.tar.gz |
oeqa/selftest: Clean up separate builddir in success case when non-threaded
If oe-selftest is run without -j, the separate build directory "build-st"
isn't cleaned up afterwards. Mirror the behaviour of the -j option to
handle this the same way, only preserve upon failure.
To do this, the remove function needs to be moved to the selftest
context module so that it can be accessed without requiring the
testtools and subunit modules the -j option requires.
A dummy wrapper class is used to wrap the tests and clean up afterwards.
[YOCTO #13953]
(From OE-Core rev: 1b376ade430d40d3cfe9c18f200c764d622710e5)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/core/utils/concurrencytest.py')
-rw-r--r-- | meta/lib/oeqa/core/utils/concurrencytest.py | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/meta/lib/oeqa/core/utils/concurrencytest.py b/meta/lib/oeqa/core/utils/concurrencytest.py index 01c39830f9..b2eb68fb02 100644 --- a/meta/lib/oeqa/core/utils/concurrencytest.py +++ b/meta/lib/oeqa/core/utils/concurrencytest.py | |||
@@ -183,10 +183,11 @@ class dummybuf(object): | |||
183 | # | 183 | # |
184 | class ConcurrentTestSuite(unittest.TestSuite): | 184 | class ConcurrentTestSuite(unittest.TestSuite): |
185 | 185 | ||
186 | def __init__(self, suite, processes, setupfunc): | 186 | def __init__(self, suite, processes, setupfunc, removefunc): |
187 | super(ConcurrentTestSuite, self).__init__([suite]) | 187 | super(ConcurrentTestSuite, self).__init__([suite]) |
188 | self.processes = processes | 188 | self.processes = processes |
189 | self.setupfunc = setupfunc | 189 | self.setupfunc = setupfunc |
190 | self.removefunc = removefunc | ||
190 | 191 | ||
191 | def run(self, result): | 192 | def run(self, result): |
192 | tests, totaltests = fork_for_tests(self.processes, self) | 193 | tests, totaltests = fork_for_tests(self.processes, self) |
@@ -237,22 +238,6 @@ class ConcurrentTestSuite(unittest.TestSuite): | |||
237 | finally: | 238 | finally: |
238 | queue.put(test) | 239 | queue.put(test) |
239 | 240 | ||
240 | def removebuilddir(d): | ||
241 | delay = 5 | ||
242 | while delay and os.path.exists(d + "/bitbake.lock"): | ||
243 | time.sleep(1) | ||
244 | delay = delay - 1 | ||
245 | # Deleting these directories takes a lot of time, use autobuilder | ||
246 | # clobberdir if its available | ||
247 | clobberdir = os.path.expanduser("~/yocto-autobuilder-helper/janitor/clobberdir") | ||
248 | if os.path.exists(clobberdir): | ||
249 | try: | ||
250 | subprocess.check_call([clobberdir, d]) | ||
251 | return | ||
252 | except subprocess.CalledProcessError: | ||
253 | pass | ||
254 | bb.utils.prunedir(d, ionice=True) | ||
255 | |||
256 | def fork_for_tests(concurrency_num, suite): | 241 | def fork_for_tests(concurrency_num, suite): |
257 | result = [] | 242 | result = [] |
258 | if 'BUILDDIR' in os.environ: | 243 | if 'BUILDDIR' in os.environ: |
@@ -297,7 +282,7 @@ def fork_for_tests(concurrency_num, suite): | |||
297 | if ourpid != os.getpid(): | 282 | if ourpid != os.getpid(): |
298 | os._exit(0) | 283 | os._exit(0) |
299 | if newbuilddir and unittest_result.wasSuccessful(): | 284 | if newbuilddir and unittest_result.wasSuccessful(): |
300 | removebuilddir(newbuilddir) | 285 | suite.removefunc(newbuilddir) |
301 | except: | 286 | except: |
302 | # Don't do anything with process children | 287 | # Don't do anything with process children |
303 | if ourpid != os.getpid(): | 288 | if ourpid != os.getpid(): |
@@ -313,7 +298,7 @@ def fork_for_tests(concurrency_num, suite): | |||
313 | sys.stderr.write(traceback.format_exc()) | 298 | sys.stderr.write(traceback.format_exc()) |
314 | finally: | 299 | finally: |
315 | if newbuilddir: | 300 | if newbuilddir: |
316 | removebuilddir(newbuilddir) | 301 | suite.removefunc(newbuilddir) |
317 | stream.flush() | 302 | stream.flush() |
318 | os._exit(1) | 303 | os._exit(1) |
319 | stream.flush() | 304 | stream.flush() |