summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/context.py')
-rw-r--r--meta/lib/oeqa/selftest/context.py36
1 files changed, 33 insertions, 3 deletions
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
23from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer 23from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer
24 24
25class 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
40def 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
25class OESelftestTestContext(OETestContext): 56class 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: