summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-27 13:42:00 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-02 16:12:37 +0100
commit3d815d7227607328d95270f87dcd7777e5c4f849 (patch)
tree3cdbf89af57b8aaa7dd4b61d3776383974426fa3 /meta/lib/oeqa/selftest
parenta225c162e6a2097e724e53cb0a0be8d89131148b (diff)
downloadpoky-3d815d7227607328d95270f87dcd7777e5c4f849.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: 20e7b1eeeb12f1cf4bd9934e0a5733c6bbe64372) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 1b376ade430d40d3cfe9c18f200c764d622710e5) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest')
-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 ba13732253..9baad58321 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: