Add an option to specify how many threads will be used for execution, default to 1.
Add OE_SELFTEST_THREAD_NUM environment variable for be able to set thread num into the Yocto Autobuilder and don't need to figure out the version of oe-selftest script. If the thread_num are greater than 1 the OESelftestContextThreaded will be used, this is due to compatibility reasons. Signed-off-by: Aníbal Limón <anibal.li...@linux.intel.com> --- meta/lib/oeqa/selftest/context.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py index 697ea0b4933..daef8823bf5 100644 --- a/meta/lib/oeqa/selftest/context.py +++ b/meta/lib/oeqa/selftest/context.py @@ -11,11 +11,12 @@ from shutil import copyfile import tempfile from random import choice -import oeqa +from argparse_oe import int_positive -from oeqa.core.context import OETestContext, OETestContextExecutor +import oeqa +from oeqa.core.context import OETestContext, OETestContextExecutor from oeqa.core.exception import OEQAPreRun - +from oeqa.core.threaded import OETestContextThreaded from oeqa.utils.commands import runCmd, get_bb_vars, get_test_layer class OESelftestTestContext(OETestContext): @@ -38,14 +39,19 @@ class OESelftestTestContext(OETestContext): def listTests(self, display_type, machine=None): return super(OESelftestTestContext, self).listTests(display_type) +class OESelftestTestContextThreaded(OESelftestTestContext, OETestContextThreaded): + pass + class OESelftestTestContextExecutor(OETestContextExecutor): - _context_class = OESelftestTestContext + _context_class = OESelftestTestContextThreaded _script_executor = 'oe-selftest' name = 'oe-selftest' help = 'oe-selftest test component' description = 'Executes selftest tests' + DEFAULT_THREADS = 1 + def register_commands(self, logger, parser): group = parser.add_mutually_exclusive_group(required=True) @@ -66,6 +72,11 @@ class OESelftestTestContextExecutor(OETestContextExecutor): action="store_true", default=False, help='List all available tests.') + parser.add_argument('-t', '--thread-num', required=False, action='store', + dest="thread_num", default=self.DEFAULT_THREADS, type=int_positive, + help='Number of threads to use for execute selftests,'\ + ' default: %d' % self.DEFAULT_THREADS) + parser.add_argument('--machine', required=False, choices=['random', 'all'], help='Run tests on different machines (random/all).') @@ -137,6 +148,11 @@ class OESelftestTestContextExecutor(OETestContextExecutor): self.tc_kwargs['init']['config_paths']['base_builddir'] = \ tempfile.mkdtemp(prefix='build-selftest-', dir=builddir) + self.tc_kwargs['load']['process_num'] = args.thread_num + if 'OE_SELFTEST_THREAD_NUM' in os.environ: + self.tc_kwargs['load']['process_num'] = \ + int(os.environ['OE_SELFTEST_THREAD_NUM']) + def _pre_run(self): def _check_required_env_variables(vars): for var in vars: @@ -199,6 +215,11 @@ class OESelftestTestContextExecutor(OETestContextExecutor): self.module_paths = self._get_cases_paths( self.tc_kwargs['init']['td']['BBPATH'].split(':')) + if self.tc_kwargs['load']['process_num'] == 1: + self._context_class = OESelftestTestContext + # OESelftestTestContext class doesn't expect process_num + del self.tc_kwargs['load']['process_num'] + self.tc = self._context_class(**self.tc_kwargs['init']) self.tc.loadTests(self.module_paths, **self.tc_kwargs['load']) -- 2.11.0 -- _______________________________________________ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core