aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib
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
parent8b5ee367a630027d478aed265ee79a7230e91673 (diff)
downloadopenembedded-core-contrib-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')
-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):
if not cond:
skipModule(reason, 3)
+
+# get testcase list from specified file
+# if path is a relative path, then relative to build/conf/
+def read_testlist(fpath, builddir):
+ if not os.path.isabs(fpath):
+ fpath = os.path.join(builddir, "conf", fpath)
+ if not os.path.exists(fpath):
+ bb.fatal("No such manifest file: ", fpath)
+ tcs = []
+ for line in open(fpath).readlines():
+ line = line.strip()
+ if line and not line.startswith("#"):
+ tcs.append(line)
+ return " ".join(tcs)
+
+# get test suites, returns test suites based on d variables
+def get_test_suites(d, type='runtime'):
+ testsuites = []
+
+ if type == "sdk":
+ testsuites = (d.getVar("TEST_SUITES_SDK", True) or "auto").split()
+ else:
+ manifests = (d.getVar("TEST_SUITES_MANIFEST", True) or '').split()
+ if manifests:
+ for manifest in manifests:
+ testsuites.extend(read_testlist(manifest,
+ d.getVar("TOPDIR", True)).split())
+
+ else:
+ testsuites = d.getVar("TEST_SUITES", True).split()
+
+ return testsuites
+
+# return test list by type also filter if TEST_SUITES is specified
+def get_tests_list(testsuites, bbpath, type="runtime"):
+ testslist = []
+
+ # This relies on lib/ under each directory in BBPATH being added to sys.path
+ # (as done by default in base.bbclass)
+ for testname in testsuites:
+ if testname != "auto":
+ if testname.startswith("oeqa."):
+ testslist.append(testname)
+ continue
+ found = False
+ for p in bbpath:
+ if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
+ testslist.append("oeqa." + type + "." + testname)
+ found = True
+ break
+ elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0] + '.py')):
+ testslist.append("oeqa." + type + "." + testname)
+ found = True
+ break
+ if not found:
+ bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
+
+ if "auto" in testsuites:
+ def add_auto_list(path):
+ if not os.path.exists(os.path.join(path, '__init__.py')):
+ bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
+ files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')])
+ for f in files:
+ module = 'oeqa.' + type + '.' + f[:-3]
+ if module not in testslist:
+ testslist.append(module)
+
+ for p in bbpath:
+ testpath = os.path.join(p, 'lib', 'oeqa', type)
+ bb.debug(2, 'Searching for tests in %s' % testpath)
+ if os.path.exists(testpath):
+ add_auto_list(testpath)
+
+ return testslist