summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/context.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/runtime/context.py')
-rw-r--r--meta/lib/oeqa/runtime/context.py33
1 files changed, 14 insertions, 19 deletions
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 3826f27642..8a0dbd0736 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -5,6 +5,7 @@
5# 5#
6 6
7import os 7import os
8import sys
8 9
9from oeqa.core.context import OETestContext, OETestContextExecutor 10from oeqa.core.context import OETestContext, OETestContextExecutor
10from oeqa.core.target.ssh import OESSHTarget 11from oeqa.core.target.ssh import OESSHTarget
@@ -66,11 +67,11 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
66 % self.default_target_type) 67 % self.default_target_type)
67 runtime_group.add_argument('--target-ip', action='store', 68 runtime_group.add_argument('--target-ip', action='store',
68 default=self.default_target_ip, 69 default=self.default_target_ip,
69 help="IP address of device under test, default: %s" \ 70 help="IP address and optionally ssh port (default 22) of device under test, for example '192.168.0.7:22'. Default: %s" \
70 % self.default_target_ip) 71 % self.default_target_ip)
71 runtime_group.add_argument('--server-ip', action='store', 72 runtime_group.add_argument('--server-ip', action='store',
72 default=self.default_target_ip, 73 default=self.default_target_ip,
73 help="IP address of device under test, default: %s" \ 74 help="IP address of the test host from test target machine, default: %s" \
74 % self.default_server_ip) 75 % self.default_server_ip)
75 76
76 runtime_group.add_argument('--host-dumper-dir', action='store', 77 runtime_group.add_argument('--host-dumper-dir', action='store',
@@ -119,8 +120,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
119 # XXX: Don't base your targets on this code it will be refactored 120 # XXX: Don't base your targets on this code it will be refactored
120 # in the near future. 121 # in the near future.
121 # Custom target module loading 122 # Custom target module loading
122 target_modules_path = kwargs.get('target_modules_path', '') 123 controller = OERuntimeTestContextExecutor.getControllerModule(target_type)
123 controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
124 target = controller(logger, target_ip, server_ip, **kwargs) 124 target = controller(logger, target_ip, server_ip, **kwargs)
125 125
126 return target 126 return target
@@ -130,15 +130,15 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
130 # AttributeError raised if not found. 130 # AttributeError raised if not found.
131 # ImportError raised if a provided module can not be imported. 131 # ImportError raised if a provided module can not be imported.
132 @staticmethod 132 @staticmethod
133 def getControllerModule(target, target_modules_path): 133 def getControllerModule(target):
134 controllerslist = OERuntimeTestContextExecutor._getControllerModulenames(target_modules_path) 134 controllerslist = OERuntimeTestContextExecutor._getControllerModulenames()
135 controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist) 135 controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist)
136 return controller 136 return controller
137 137
138 # Return a list of all python modules in lib/oeqa/controllers for each 138 # Return a list of all python modules in lib/oeqa/controllers for each
139 # layer in bbpath 139 # layer in bbpath
140 @staticmethod 140 @staticmethod
141 def _getControllerModulenames(target_modules_path): 141 def _getControllerModulenames():
142 142
143 controllerslist = [] 143 controllerslist = []
144 144
@@ -153,9 +153,8 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
153 else: 153 else:
154 raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module) 154 raise RuntimeError("Duplicate controller module found for %s. Layers should create unique controller module names" % module)
155 155
156 extpath = target_modules_path.split(':') 156 for p in sys.path:
157 for p in extpath: 157 controllerpath = os.path.join(p, 'oeqa', 'controllers')
158 controllerpath = os.path.join(p, 'lib', 'oeqa', 'controllers')
159 if os.path.exists(controllerpath): 158 if os.path.exists(controllerpath):
160 add_controller_list(controllerpath) 159 add_controller_list(controllerpath)
161 return controllerslist 160 return controllerslist
@@ -175,16 +174,12 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
175 # Search for and return a controller or None from given module name 174 # Search for and return a controller or None from given module name
176 @staticmethod 175 @staticmethod
177 def _loadControllerFromModule(target, modulename): 176 def _loadControllerFromModule(target, modulename):
178 obj = None
179 # import module, allowing it to raise import exception
180 module = __import__(modulename, globals(), locals(), [target])
181 # look for target class in the module, catching any exceptions as it
182 # is valid that a module may not have the target class.
183 try: 177 try:
184 obj = getattr(module, target) 178 import importlib
185 except: 179 module = importlib.import_module(modulename)
186 obj = None 180 return getattr(module, target)
187 return obj 181 except AttributeError:
182 return None
188 183
189 @staticmethod 184 @staticmethod
190 def readPackagesManifest(manifest): 185 def readPackagesManifest(manifest):