diff options
author | Sipke Vriend <sipke.vriend@xilinx.com> | 2014-01-30 16:25:54 +1000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-02-02 22:37:41 +0000 |
commit | c99622e38b0a08dcdbe096a41732fef732bb1207 (patch) | |
tree | fb63682fdf7d8e3099cef4d066f241baeac2b720 /meta/lib/oeqa/targetcontrol.py | |
parent | 6e59874e886192f1600126eaa0363ffb0f423f21 (diff) | |
download | poky-c99622e38b0a08dcdbe096a41732fef732bb1207.tar.gz |
lib/oeqa: allow multiple layers to provide their own TEST_TARGET class
Use a python module "folder" rather than a single module within
layers to ensure multiple layers can define a TEST_TARGET class.
Current implementation using controllers.py module will only allow
a single layer to define test targets.
Add a controllers folder as well as a TestTargetLoader class whose
job is to load the given TEST_TARGET class from any number of
python modules within the oeqa/controllers/ directory of any
layer.
The only condition will be that layers will need to ensure
the TEST_TARGET class name they provide is unique otherwise there
is no guarantee which class is instantiated. a bb.warn is used
to alude to this if it happens.
(From OE-Core rev: 3f25705f4a986e06cbd397aaea52b841c1a1e054)
Signed-off-by: Sipke Vriend <sipke.vriend@xilinx.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/targetcontrol.py')
-rw-r--r-- | meta/lib/oeqa/targetcontrol.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py index 757f9d3d50..ba5e6e5dc1 100644 --- a/meta/lib/oeqa/targetcontrol.py +++ b/meta/lib/oeqa/targetcontrol.py | |||
@@ -11,7 +11,7 @@ import bb | |||
11 | import traceback | 11 | import traceback |
12 | from oeqa.utils.sshcontrol import SSHControl | 12 | from oeqa.utils.sshcontrol import SSHControl |
13 | from oeqa.utils.qemurunner import QemuRunner | 13 | from oeqa.utils.qemurunner import QemuRunner |
14 | 14 | from oeqa.controllers.testtargetloader import TestTargetLoader | |
15 | 15 | ||
16 | def get_target_controller(d): | 16 | def get_target_controller(d): |
17 | testtarget = d.getVar("TEST_TARGET", True) | 17 | testtarget = d.getVar("TEST_TARGET", True) |
@@ -28,12 +28,13 @@ def get_target_controller(d): | |||
28 | except AttributeError: | 28 | except AttributeError: |
29 | # nope, perhaps a layer defined one | 29 | # nope, perhaps a layer defined one |
30 | try: | 30 | try: |
31 | module = __import__("oeqa.utils.controllers", globals(), locals(), [testtarget]) | 31 | bbpath = d.getVar("BBPATH", True).split(':') |
32 | controller = getattr(module, testtarget) | 32 | testtargetloader = TestTargetLoader() |
33 | controller = testtargetloader.get_controller_module(testtarget, bbpath) | ||
33 | except ImportError as e: | 34 | except ImportError as e: |
34 | bb.fatal("Failed to import oeqa.utils.controllers:\n%s" % traceback.format_exc()) | 35 | bb.fatal("Failed to import {0} from available controller modules:\n{1}".format(testtarget,traceback.format_exc())) |
35 | except AttributeError: | 36 | except AttributeError as e: |
36 | bb.fatal("\"%s\" is not a valid value for TEST_TARGET" % testtarget) | 37 | bb.fatal("Invalid TEST_TARGET - " + str(e)) |
37 | return controller(d) | 38 | return controller(d) |
38 | 39 | ||
39 | 40 | ||