summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2021-10-20 18:30:07 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-03 11:18:56 +0000
commit62c874086a9f3f335f879264f14fb5d10226800e (patch)
tree801faba06fa28930afa7f3b4e003a002c3795a01
parent03a5e65cdd702e942c0a10097e00b8e58628fea8 (diff)
downloadpoky-62c874086a9f3f335f879264f14fb5d10226800e.tar.gz
oeqa/runtime: search sys.path explicitly for modules
The controller module loading code needs to be told what directories to search for modules via the target_modules_path keyword argument, which is set to BBPATH. However, as the actual module loading is done via importlib this relies on the paths being on sys.path, which it is as base.bbclass puts each layer's lib/ in sys.path. Simplify the code by removing this indirection, and simply search sys.path directly. (From OE-Core rev: f2736f9a1156e23efbb20ea44a4aa81775ccbeba) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 570a19581f582f77e04d6892adb647cd649a6943) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/lib/oeqa/runtime/context.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 7908ce1fd4..d707ab263a 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
@@ -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