summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/context.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-27 13:42:00 +0100
committerSteve Sakoman <steve@sakoman.com>2020-06-29 05:17:44 -1000
commit20e7b1eeeb12f1cf4bd9934e0a5733c6bbe64372 (patch)
tree003b88b68a90abdd27bc8f68e9e5f7ed9b91e4cf /meta/lib/oeqa/selftest/context.py
parent819f41906197bb712af37349c0865002bfbd7c9b (diff)
downloadopenembedded-core-contrib-20e7b1eeeb12f1cf4bd9934e0a5733c6bbe64372.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] Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 1b376ade430d40d3cfe9c18f200c764d622710e5) Signed-off-by: Steve Sakoman <steve@sakoman.com>
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 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
from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer
+class NonConcurrentTestSuite(unittest.TestSuite):
+ def __init__(self, suite, processes, setupfunc, removefunc):
+ super().__init__([suite])
+ self.processes = processes
+ self.suite = suite
+ self.setupfunc = setupfunc
+ self.removefunc = removefunc
+
+ def run(self, result):
+ (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite)
+ ret = super().run(result)
+ os.chdir(builddir)
+ if newbuilddir and ret.wasSuccessful():
+ self.removefunc(newbuilddir)
+
+def removebuilddir(d):
+ delay = 5
+ while delay and os.path.exists(d + "/bitbake.lock"):
+ time.sleep(1)
+ delay = delay - 1
+ # Deleting these directories takes a lot of time, use autobuilder
+ # clobberdir if its available
+ clobberdir = os.path.expanduser("~/yocto-autobuilder-helper/janitor/clobberdir")
+ if os.path.exists(clobberdir):
+ try:
+ subprocess.check_call([clobberdir, d])
+ return
+ except subprocess.CalledProcessError:
+ pass
+ bb.utils.prunedir(d, ionice=True)
+
class OESelftestTestContext(OETestContext):
def __init__(self, td=None, logger=None, machines=None, config_paths=None, newbuilddir=None):
super(OESelftestTestContext, self).__init__(td, logger)
@@ -86,10 +117,9 @@ class OESelftestTestContext(OETestContext):
if processes:
from oeqa.core.utils.concurrencytest import ConcurrentTestSuite
- return ConcurrentTestSuite(suites, processes, self.setup_builddir)
+ return ConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir)
else:
- self.setup_builddir("-st", None, suites)
- return suites
+ return NonConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir)
def runTests(self, processes=None, machine=None, skips=[]):
if machine: