[oe-commits] [openembedded-core] 38/39: oeqa/selftest/context: Enable support for threaded runs

git at git.openembedded.org git at git.openembedded.org
Thu Jul 20 16:30:22 UTC 2017


This is an automated email from the git hooks/post-receive script.

rpurdie pushed a commit to branch master-next
in repository openembedded-core.

commit 2657141836c1bb2096b7ecdefac37eb78d982a7d
Author: Aníbal Limón <anibal.limon at linux.intel.com>
AuthorDate: Fri Jun 9 13:36:50 2017 -0700

    oeqa/selftest/context: Enable support for threaded runs
    
    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.limon at 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 697ea0b..daef882 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'])
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Openembedded-commits mailing list