1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

selftest: Add argument to keep build dir

The oe-selftest code already keeps the selftest build directory in place
if any tests failed. By default the build directory is deleted if all
tests pass but there may be cases where it's desirable to keep this
directory around, for example to compare intermediate files between
passing and failing test runs.

(From OE-Core rev: f41c17a155e9bfd233bc2166c6ab7f5e547f39fa)

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 67aa7069dbe8f5f5f186eb67708ece5c4bd42976)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Paul Barker
2021-01-07 14:56:12 +00:00
committed by Richard Purdie
parent dbde090045
commit 2dee41a4fc
+13 -4
View File
@@ -34,7 +34,7 @@ class NonConcurrentTestSuite(unittest.TestSuite):
(builddir, newbuilddir) = self.setupfunc("-st", None, self.suite) (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite)
ret = super().run(result) ret = super().run(result)
os.chdir(builddir) os.chdir(builddir)
if newbuilddir and ret.wasSuccessful(): if newbuilddir and ret.wasSuccessful() and self.removefunc:
self.removefunc(newbuilddir) self.removefunc(newbuilddir)
def removebuilddir(d): def removebuilddir(d):
@@ -54,7 +54,7 @@ def removebuilddir(d):
bb.utils.prunedir(d, ionice=True) bb.utils.prunedir(d, ionice=True)
class OESelftestTestContext(OETestContext): class OESelftestTestContext(OETestContext):
def __init__(self, td=None, logger=None, machines=None, config_paths=None, newbuilddir=None): def __init__(self, td=None, logger=None, machines=None, config_paths=None, newbuilddir=None, keep_builddir=None):
super(OESelftestTestContext, self).__init__(td, logger) super(OESelftestTestContext, self).__init__(td, logger)
self.machines = machines self.machines = machines
@@ -62,6 +62,11 @@ class OESelftestTestContext(OETestContext):
self.config_paths = config_paths self.config_paths = config_paths
self.newbuilddir = newbuilddir self.newbuilddir = newbuilddir
if keep_builddir:
self.removebuilddir = None
else:
self.removebuilddir = removebuilddir
def setup_builddir(self, suffix, selftestdir, suite): def setup_builddir(self, suffix, selftestdir, suite):
builddir = os.environ['BUILDDIR'] builddir = os.environ['BUILDDIR']
if not selftestdir: if not selftestdir:
@@ -119,9 +124,9 @@ class OESelftestTestContext(OETestContext):
if processes: if processes:
from oeqa.core.utils.concurrencytest import ConcurrentTestSuite from oeqa.core.utils.concurrencytest import ConcurrentTestSuite
return ConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir) return ConcurrentTestSuite(suites, processes, self.setup_builddir, self.removebuilddir)
else: else:
return NonConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir) return NonConcurrentTestSuite(suites, processes, self.setup_builddir, self.removebuilddir)
def runTests(self, processes=None, machine=None, skips=[]): def runTests(self, processes=None, machine=None, skips=[]):
if machine: if machine:
@@ -179,6 +184,9 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
action='append', default=None, action='append', default=None,
help='Exclude all (unhidden) tests that match any of the specified tag(s). (exclude applies before select)') help='Exclude all (unhidden) tests that match any of the specified tag(s). (exclude applies before select)')
parser.add_argument('-K', '--keep-builddir', action='store_true',
help='Keep the test build directory even if all tests pass')
parser.add_argument('-B', '--newbuilddir', help='New build directory to use for tests.') parser.add_argument('-B', '--newbuilddir', help='New build directory to use for tests.')
parser.add_argument('-v', '--verbose', action='store_true') parser.add_argument('-v', '--verbose', action='store_true')
parser.set_defaults(func=self.run) parser.set_defaults(func=self.run)
@@ -236,6 +244,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
self.tc_kwargs['init']['config_paths']['localconf'] = os.path.join(builddir, "conf/local.conf") self.tc_kwargs['init']['config_paths']['localconf'] = os.path.join(builddir, "conf/local.conf")
self.tc_kwargs['init']['config_paths']['bblayers'] = os.path.join(builddir, "conf/bblayers.conf") self.tc_kwargs['init']['config_paths']['bblayers'] = os.path.join(builddir, "conf/bblayers.conf")
self.tc_kwargs['init']['newbuilddir'] = args.newbuilddir self.tc_kwargs['init']['newbuilddir'] = args.newbuilddir
self.tc_kwargs['init']['keep_builddir'] = args.keep_builddir
def tag_filter(tags): def tag_filter(tags):
if args.exclude_tags: if args.exclude_tags: