summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorPaul Barker <pbarker@konsulko.com>2021-01-07 14:56:12 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-01-08 10:10:15 +0000
commit9efd66ad10d1ca4ba941ee23b212ab7c5d42f42d (patch)
tree9fffa51839ddba9c4591ff9d2baad12a91d07248 /meta
parent46845d62ff9e635efca53f28450da710d600ce0f (diff)
downloadpoky-9efd66ad10d1ca4ba941ee23b212ab7c5d42f42d.tar.gz
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: 67aa7069dbe8f5f5f186eb67708ece5c4bd42976) Signed-off-by: Paul Barker <pbarker@konsulko.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/context.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index dd3609c1d6..1659926975 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -34,7 +34,7 @@ class NonConcurrentTestSuite(unittest.TestSuite):
34 (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite) 34 (builddir, newbuilddir) = self.setupfunc("-st", None, self.suite)
35 ret = super().run(result) 35 ret = super().run(result)
36 os.chdir(builddir) 36 os.chdir(builddir)
37 if newbuilddir and ret.wasSuccessful(): 37 if newbuilddir and ret.wasSuccessful() and self.removefunc:
38 self.removefunc(newbuilddir) 38 self.removefunc(newbuilddir)
39 39
40def removebuilddir(d): 40def removebuilddir(d):
@@ -54,7 +54,7 @@ def removebuilddir(d):
54 bb.utils.prunedir(d, ionice=True) 54 bb.utils.prunedir(d, ionice=True)
55 55
56class OESelftestTestContext(OETestContext): 56class OESelftestTestContext(OETestContext):
57 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, keep_builddir=None):
58 super(OESelftestTestContext, self).__init__(td, logger) 58 super(OESelftestTestContext, self).__init__(td, logger)
59 59
60 self.machines = machines 60 self.machines = machines
@@ -62,6 +62,11 @@ class OESelftestTestContext(OETestContext):
62 self.config_paths = config_paths 62 self.config_paths = config_paths
63 self.newbuilddir = newbuilddir 63 self.newbuilddir = newbuilddir
64 64
65 if keep_builddir:
66 self.removebuilddir = None
67 else:
68 self.removebuilddir = removebuilddir
69
65 def setup_builddir(self, suffix, selftestdir, suite): 70 def setup_builddir(self, suffix, selftestdir, suite):
66 builddir = os.environ['BUILDDIR'] 71 builddir = os.environ['BUILDDIR']
67 if not selftestdir: 72 if not selftestdir:
@@ -119,9 +124,9 @@ class OESelftestTestContext(OETestContext):
119 if processes: 124 if processes:
120 from oeqa.core.utils.concurrencytest import ConcurrentTestSuite 125 from oeqa.core.utils.concurrencytest import ConcurrentTestSuite
121 126
122 return ConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir) 127 return ConcurrentTestSuite(suites, processes, self.setup_builddir, self.removebuilddir)
123 else: 128 else:
124 return NonConcurrentTestSuite(suites, processes, self.setup_builddir, removebuilddir) 129 return NonConcurrentTestSuite(suites, processes, self.setup_builddir, self.removebuilddir)
125 130
126 def runTests(self, processes=None, machine=None, skips=[]): 131 def runTests(self, processes=None, machine=None, skips=[]):
127 if machine: 132 if machine:
@@ -179,6 +184,9 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
179 action='append', default=None, 184 action='append', default=None,
180 help='Exclude all (unhidden) tests that match any of the specified tag(s). (exclude applies before select)') 185 help='Exclude all (unhidden) tests that match any of the specified tag(s). (exclude applies before select)')
181 186
187 parser.add_argument('-K', '--keep-builddir', action='store_true',
188 help='Keep the test build directory even if all tests pass')
189
182 parser.add_argument('-B', '--newbuilddir', help='New build directory to use for tests.') 190 parser.add_argument('-B', '--newbuilddir', help='New build directory to use for tests.')
183 parser.add_argument('-v', '--verbose', action='store_true') 191 parser.add_argument('-v', '--verbose', action='store_true')
184 parser.set_defaults(func=self.run) 192 parser.set_defaults(func=self.run)
@@ -236,6 +244,7 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
236 self.tc_kwargs['init']['config_paths']['localconf'] = os.path.join(builddir, "conf/local.conf") 244 self.tc_kwargs['init']['config_paths']['localconf'] = os.path.join(builddir, "conf/local.conf")
237 self.tc_kwargs['init']['config_paths']['bblayers'] = os.path.join(builddir, "conf/bblayers.conf") 245 self.tc_kwargs['init']['config_paths']['bblayers'] = os.path.join(builddir, "conf/bblayers.conf")
238 self.tc_kwargs['init']['newbuilddir'] = args.newbuilddir 246 self.tc_kwargs['init']['newbuilddir'] = args.newbuilddir
247 self.tc_kwargs['init']['keep_builddir'] = args.keep_builddir
239 248
240 def tag_filter(tags): 249 def tag_filter(tags):
241 if args.exclude_tags: 250 if args.exclude_tags: