summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/oetest.py
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-01-28 09:46:25 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 16:06:22 +0000
commit3d1d30b0a38b338aa9e17566c2d8a0298e031edb (patch)
treef15ab8103fb93714eca41d03ebfdc1b13d0a6db8 /meta/lib/oeqa/oetest.py
parent8b5ee367a630027d478aed265ee79a7230e91673 (diff)
downloadpoky-3d1d30b0a38b338aa9e17566c2d8a0298e031edb.tar.gz
testimage: Modularize helper functions for get test lists.
Test lists functions can be used in other parts so modularize it and move to oeqa/oetest.py library. Testimage class was updated to meet the new sign of the functions. (From OE-Core rev: c9f771533af70e7ccb1e7064e58926cfaee7367a) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/oetest.py')
-rw-r--r--meta/lib/oeqa/oetest.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index 6f9edec58d..18b2209656 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -250,3 +250,77 @@ def skipModuleUnless(cond, reason):
250 250
251 if not cond: 251 if not cond:
252 skipModule(reason, 3) 252 skipModule(reason, 3)
253
254# get testcase list from specified file
255# if path is a relative path, then relative to build/conf/
256def read_testlist(fpath, builddir):
257 if not os.path.isabs(fpath):
258 fpath = os.path.join(builddir, "conf", fpath)
259 if not os.path.exists(fpath):
260 bb.fatal("No such manifest file: ", fpath)
261 tcs = []
262 for line in open(fpath).readlines():
263 line = line.strip()
264 if line and not line.startswith("#"):
265 tcs.append(line)
266 return " ".join(tcs)
267
268# get test suites, returns test suites based on d variables
269def get_test_suites(d, type='runtime'):
270 testsuites = []
271
272 if type == "sdk":
273 testsuites = (d.getVar("TEST_SUITES_SDK", True) or "auto").split()
274 else:
275 manifests = (d.getVar("TEST_SUITES_MANIFEST", True) or '').split()
276 if manifests:
277 for manifest in manifests:
278 testsuites.extend(read_testlist(manifest,
279 d.getVar("TOPDIR", True)).split())
280
281 else:
282 testsuites = d.getVar("TEST_SUITES", True).split()
283
284 return testsuites
285
286# return test list by type also filter if TEST_SUITES is specified
287def get_tests_list(testsuites, bbpath, type="runtime"):
288 testslist = []
289
290 # This relies on lib/ under each directory in BBPATH being added to sys.path
291 # (as done by default in base.bbclass)
292 for testname in testsuites:
293 if testname != "auto":
294 if testname.startswith("oeqa."):
295 testslist.append(testname)
296 continue
297 found = False
298 for p in bbpath:
299 if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
300 testslist.append("oeqa." + type + "." + testname)
301 found = True
302 break
303 elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0] + '.py')):
304 testslist.append("oeqa." + type + "." + testname)
305 found = True
306 break
307 if not found:
308 bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
309
310 if "auto" in testsuites:
311 def add_auto_list(path):
312 if not os.path.exists(os.path.join(path, '__init__.py')):
313 bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
314 files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')])
315 for f in files:
316 module = 'oeqa.' + type + '.' + f[:-3]
317 if module not in testslist:
318 testslist.append(module)
319
320 for p in bbpath:
321 testpath = os.path.join(p, 'lib', 'oeqa', type)
322 bb.debug(2, 'Searching for tests in %s' % testpath)
323 if os.path.exists(testpath):
324 add_auto_list(testpath)
325
326 return testslist