From c99622e38b0a08dcdbe096a41732fef732bb1207 Mon Sep 17 00:00:00 2001 From: Sipke Vriend Date: Thu, 30 Jan 2014 16:25:54 +1000 Subject: 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 Signed-off-by: Richard Purdie --- meta/lib/oeqa/targetcontrol.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'meta/lib/oeqa/targetcontrol.py') 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 import traceback from oeqa.utils.sshcontrol import SSHControl from oeqa.utils.qemurunner import QemuRunner - +from oeqa.controllers.testtargetloader import TestTargetLoader def get_target_controller(d): testtarget = d.getVar("TEST_TARGET", True) @@ -28,12 +28,13 @@ def get_target_controller(d): except AttributeError: # nope, perhaps a layer defined one try: - module = __import__("oeqa.utils.controllers", globals(), locals(), [testtarget]) - controller = getattr(module, testtarget) + bbpath = d.getVar("BBPATH", True).split(':') + testtargetloader = TestTargetLoader() + controller = testtargetloader.get_controller_module(testtarget, bbpath) 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) + bb.fatal("Failed to import {0} from available controller modules:\n{1}".format(testtarget,traceback.format_exc())) + except AttributeError as e: + bb.fatal("Invalid TEST_TARGET - " + str(e)) return controller(d) -- cgit v1.2.3-54-g00ecf