diff options
author | Stefan Stanacar <stefanx.stanacar@intel.com> | 2014-01-16 14:48:59 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-01-19 16:32:09 +0000 |
commit | bf7383de87cdb12c857a5577c89acf6855d96dfa (patch) | |
tree | 9fb1c64f2352cd14c186b17f642b05fc760cd820 | |
parent | 650ee5e27521489c2907cf592cdd9161af844e68 (diff) | |
download | ast2050-yocto-poky-bf7383de87cdb12c857a5577c89acf6855d96dfa.zip ast2050-yocto-poky-bf7383de87cdb12c857a5577c89acf6855d96dfa.tar.gz |
lib/oeqa: allow a layer to provide it's own TEST_TARGET class
Allows a layer to define new classes in <layer>/lib/oeqa/utils/controllers.py
and completely control or extend deployment of a target. (core currently
has QemuTarget and SimpleRemoteTarget).
The value of TEST_TARGET must be the name of the new class.
(From OE-Core rev: 9b81aff0aca42353d448b1e9522f89842e23c7b2)
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/targetcontrol.py | 23 | ||||
-rw-r--r-- | meta/lib/oeqa/utils/__init__.py | 3 |
2 files changed, 22 insertions, 4 deletions
diff --git a/meta/lib/oeqa/targetcontrol.py b/meta/lib/oeqa/targetcontrol.py index dee38ec..757f9d3 100644 --- a/meta/lib/oeqa/targetcontrol.py +++ b/meta/lib/oeqa/targetcontrol.py @@ -8,18 +8,33 @@ import os import shutil import subprocess import bb - +import traceback from oeqa.utils.sshcontrol import SSHControl from oeqa.utils.qemurunner import QemuRunner def get_target_controller(d): - if d.getVar("TEST_TARGET", True) == "qemu": + testtarget = d.getVar("TEST_TARGET", True) + # old, simple names + if testtarget == "qemu": return QemuTarget(d) - elif d.getVar("TEST_TARGET", True) == "simpleremote": + elif testtarget == "simpleremote": return SimpleRemoteTarget(d) else: - bb.fatal("Please set a valid TEST_TARGET") + # use the class name + try: + # is it a core class defined here? + controller = getattr(__name__, testtarget) + except AttributeError: + # nope, perhaps a layer defined one + try: + module = __import__("oeqa.utils.controllers", globals(), locals(), [testtarget]) + controller = getattr(module, testtarget) + except ImportError as e: + bb.fatal("Failed to import oeqa.utils.controllers:\n%s" % traceback.format_exc()) + except AttributeError: + bb.fatal("\"%s\" is not a valid value for TEST_TARGET" % testtarget) + return controller(d) class BaseTarget(object): diff --git a/meta/lib/oeqa/utils/__init__.py b/meta/lib/oeqa/utils/__init__.py index e69de29..8eda927 100644 --- a/meta/lib/oeqa/utils/__init__.py +++ b/meta/lib/oeqa/utils/__init__.py @@ -0,0 +1,3 @@ +# Enable other layers to have modules in the same named directory +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) |