diff options
| author | Aníbal Limón <anibal.limon@linux.intel.com> | 2017-05-23 15:04:57 -0500 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:02:43 +0100 |
| commit | 7c8f3c398084573d01d70989bd0d35a94058a420 (patch) | |
| tree | eb4b788a8ea5e11b293214df5161810f657b0946 /meta/lib/oeqa/utils/__init__.py | |
| parent | 02417b149623c3042c257d1c1074f915dc02b7c7 (diff) | |
| download | poky-7c8f3c398084573d01d70989bd0d35a94058a420.tar.gz | |
scripts/oe-test: Move load_test_components to oeqa.utils
In order to maintain compatibility with oe-selftest, the
load_test_components needs to be re-used, so the script
executor needs to pass to only load components supported
by certain script (oe-test, oe-selftest).
(From OE-Core rev: d6b78ae711b93b4059690320cb8d821aaadd1684)
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/__init__.py')
| -rw-r--r-- | meta/lib/oeqa/utils/__init__.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/__init__.py b/meta/lib/oeqa/utils/__init__.py index 485de031a9..d38a323013 100644 --- a/meta/lib/oeqa/utils/__init__.py +++ b/meta/lib/oeqa/utils/__init__.py | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | from pkgutil import extend_path | 2 | from pkgutil import extend_path |
| 3 | __path__ = extend_path(__path__, __name__) | 3 | __path__ = extend_path(__path__, __name__) |
| 4 | 4 | ||
| 5 | |||
| 6 | # Borrowed from CalledProcessError | 5 | # Borrowed from CalledProcessError |
| 7 | 6 | ||
| 8 | class CommandError(Exception): | 7 | class CommandError(Exception): |
| @@ -66,3 +65,39 @@ def make_logger_bitbake_compatible(logger): | |||
| 66 | logger.info = _bitbake_log_info | 65 | logger.info = _bitbake_log_info |
| 67 | 66 | ||
| 68 | return logger | 67 | return logger |
| 68 | |||
| 69 | def load_test_components(logger, executor): | ||
| 70 | import sys | ||
| 71 | import os | ||
| 72 | import importlib | ||
| 73 | |||
| 74 | from oeqa.core.context import OETestContextExecutor | ||
| 75 | |||
| 76 | components = {} | ||
| 77 | |||
| 78 | for path in sys.path: | ||
| 79 | base_dir = os.path.join(path, 'oeqa') | ||
| 80 | if os.path.exists(base_dir) and os.path.isdir(base_dir): | ||
| 81 | for file in os.listdir(base_dir): | ||
| 82 | comp_name = file | ||
| 83 | comp_context = os.path.join(base_dir, file, 'context.py') | ||
| 84 | if os.path.exists(comp_context): | ||
| 85 | comp_plugin = importlib.import_module('oeqa.%s.%s' % \ | ||
| 86 | (comp_name, 'context')) | ||
| 87 | try: | ||
| 88 | if not issubclass(comp_plugin._executor_class, | ||
| 89 | OETestContextExecutor): | ||
| 90 | raise TypeError("Component %s in %s, _executor_class "\ | ||
| 91 | "isn't derived from OETestContextExecutor."\ | ||
| 92 | % (comp_name, comp_context)) | ||
| 93 | |||
| 94 | if comp_plugin._executor_class._script_executor \ | ||
| 95 | != executor: | ||
| 96 | continue | ||
| 97 | |||
| 98 | components[comp_name] = comp_plugin._executor_class() | ||
| 99 | except AttributeError: | ||
| 100 | raise AttributeError("Component %s in %s don't have "\ | ||
| 101 | "_executor_class defined." % (comp_name, comp_context)) | ||
| 102 | |||
| 103 | return components | ||
