diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/core/utils/concurrencytest.py | 23 | ||||
-rw-r--r-- | meta/lib/oeqa/selftest/context.py | 36 |
2 files changed, 37 insertions, 22 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() |
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py index 494e9dbd1e..23f7d71bdb 100644 --- a/meta/lib/oeqa/selftest/context.py +++ b/meta/lib/oeqa/selftest/context.py | |||
@@ -22,6 +22,37 @@ from oeqa.core.exception import OEQAPreRun, OEQATestNotFound | |||
22 | 22 | ||
23 | from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer | 23 | from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer |
24 | 24 | ||
25 | class NonConcurrentTestSuite(unittest.TestSuite): | ||
26 | def __init__(self, suite, processes, setupfunc, removefunc): | ||
27 | super().__init__([suite]) | ||
28 | self.processes = processes | ||
29 | self.suite = suite | ||
30 | self.setupfunc = setupfunc | ||
31 | self.removefunc = removefunc | ||
32 | |||
33 | def run(self, result): | ||
34 | (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite) | ||
35 | ret = super().run(result) | ||
36 | os.chdir(builddir) | ||
37 | if newbuilddir and ret.wasSuccessful(): | ||
38 | self.removefunc(newbuilddir) | ||
39 | |||
40 | def removebuilddir(d): | ||
41 | delay = 5 | ||
42 | while delay and os.path.exists(d + "/bitbake.lock"): | ||
43 | time.sleep(1) | ||
44 | delay = delay - 1 | ||
45 | # Deleting these directories takes a lot of time, use autobuilder | ||
46 | # clobberdir if its available | ||
47 | clobberdir = os.path.expanduser("~/yocto-autobuilder-helper/janitor/clobberdir") | ||
48 | if os.path.exists(clobberdir): | ||
49 | try: | ||
50 | subprocess.check_call([clobberdir, d]) | ||
51 | return | ||
52 | except subprocess.CalledProcessError: | ||
53 | pass | ||
54 | bb.utils.prunedir(d, ionice=True) | ||
55 | |||
25 | class OESelftestTestContext(OETestContext): | 56 | class OESelftestTestContext(OETestContext): |
26 | def __init__(self, td=None, logger=None, machines=None, config_paths=None, newbuilddir=None): | 57 | def __init__(self, td=None, logger=None, machines=None, config_paths=None, newbuilddir=None): |
27 | super(OESelftestTestContext, self).__init__(td, logger) | 58 | super(OESelftestTestContext, self).__init__(td, logger) |
@@ -86,10 +117,9 @@ class OESelftestTestContext(OETestContext): | |||
86 | if processes: | 117 | if processes: |
87 | from oeqa.core.utils.concurrencytest import ConcurrentTestSuite | 118 | from oeqa.core.utils.concurrencytest import ConcurrentTestSuite |
88 | 119 | ||
89 | return ConcurrentTestSuite(suites, processes, self.setup_builddir) | 120 | return ConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir) |
90 | else: | 121 | else: |
91 | self.setup_builddir("-st", None, suites) | 122 | return NonConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir) |
92 | return suites | ||
93 | 123 | ||
94 | def runTests(self, processes=None, machine=None, skips=[]): | 124 | def runTests(self, processes=None, machine=None, skips=[]): |
95 | if machine: | 125 | if machine: |