summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Stephan <jstephan@baylibre.com>2024-04-15 14:03:17 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-04-22 22:05:57 +0100
commita45e29917ea845b3e037d5bde253fb9dff0688a9 (patch)
tree966a2da90a1bab0ea6992b9221c2ba804a2a7d40
parent22c626c4f61feb34ffc4b66e469195d275a693e5 (diff)
downloadpoky-a45e29917ea845b3e037d5bde253fb9dff0688a9.tar.gz
oeqa: selftest: context: run tests serially if testtools/subunit modules are not found
If testtools and/or subunit modules are not found we get the following backtrace (example for testtools): NOTE: Starting bitbake server... Traceback (most recent call last): File "<..>/poky/scripts/oe-selftest", line 60, in <module> ret = main() File "<..>/poky/scripts/oe-selftest", line 47, in main results = args.func(logger, args) File "<..>/poky/meta/lib/oeqa/selftest/context.py", line 391, in run rc = self._internal_run(logger, args) File "<..>/poky/meta/lib/oeqa/selftest/context.py", line 377, in _internal_run rc = self.tc.runTests(**self.tc_kwargs['run']) File "<..>/poky/meta/lib/oeqa/selftest/context.py", line 161, in runTests return super(OESelftestTestContext, self).runTests(processes, skips) File "<..>/poky/meta/lib/oeqa/core/context.py", line 91, in runTests result = self.runner.run(self.prepareSuite(self.suites, processes)) File "<..>/poky/meta/lib/oeqa/selftest/context.py", line 154, in prepareSuite from oeqa.core.utils.concurrencytest import ConcurrentTestSuite File "<..>/poky/meta/lib/oeqa/core/utils/concurrencytest.py", line 22, in <module> import testtools ModuleNotFoundError: No module named 'testtools' Fix this by adding a custom callback on -j/--num-processes parameter to check testtools and subunit modules. Fallback to serial testing if missing. This strategy is already used in sdk/context.py (From OE-Core rev: 7bbf9c77950a1149bdc6cfb603edb6c2dcd5a957) Signed-off-by: Julien Stephan <jstephan@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/selftest/context.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index 57844b289a..99186175e5 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -194,8 +194,23 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
194 parser.add_argument('-R', '--skip-tests', required=False, action='store', 194 parser.add_argument('-R', '--skip-tests', required=False, action='store',
195 nargs='+', dest="skips", default=None, 195 nargs='+', dest="skips", default=None,
196 help='Skip the tests specified. Format should be <module>[.<class>[.<test_method>]]') 196 help='Skip the tests specified. Format should be <module>[.<class>[.<test_method>]]')
197
198 def check_parallel_support(parameter):
199 if not parameter.isdigit():
200 import argparse
201 raise argparse.ArgumentTypeError("argument -j/--num-processes: invalid int value: '%s' " % str(parameter))
202
203 processes = int(parameter)
204 if processes:
205 try:
206 import testtools, subunit
207 except ImportError:
208 print("Failed to import testtools or subunit, the testcases will run serially")
209 processes = None
210 return processes
211
197 parser.add_argument('-j', '--num-processes', dest='processes', action='store', 212 parser.add_argument('-j', '--num-processes', dest='processes', action='store',
198 type=int, help="number of processes to execute in parallel with") 213 type=check_parallel_support, help="number of processes to execute in parallel with")
199 214
200 parser.add_argument('-t', '--select-tag', dest="select_tags", 215 parser.add_argument('-t', '--select-tag', dest="select_tags",
201 action='append', default=None, 216 action='append', default=None,