summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/classes/testimage.bbclass78
-rw-r--r--meta/lib/oeqa/oetest.py74
2 files changed, 78 insertions, 74 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 3986340f46..3fe27a27db 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -106,74 +106,6 @@ do_testsdk[nostamp] = "1"
106do_testsdk[depends] += "${TESTIMAGEDEPENDS}" 106do_testsdk[depends] += "${TESTIMAGEDEPENDS}"
107do_testsdk[lockfiles] += "${TESTIMAGELOCK}" 107do_testsdk[lockfiles] += "${TESTIMAGELOCK}"
108 108
109# get testcase list from specified file
110# if path is a relative path, then relative to build/conf/
111def read_testlist(d, fpath):
112 if not os.path.isabs(fpath):
113 builddir = d.getVar("TOPDIR", True)
114 fpath = os.path.join(builddir, "conf", fpath)
115 if not os.path.exists(fpath):
116 bb.fatal("No such manifest file: ", fpath)
117 tcs = []
118 for line in open(fpath).readlines():
119 line = line.strip()
120 if line and not line.startswith("#"):
121 tcs.append(line)
122 return " ".join(tcs)
123
124def get_tests_list(d, type="runtime"):
125 testsuites = []
126 testslist = []
127 manifests = d.getVar("TEST_SUITES_MANIFEST", True)
128 if manifests is not None:
129 manifests = manifests.split()
130 for manifest in manifests:
131 testsuites.extend(read_testlist(d, manifest).split())
132 else:
133 testsuites = d.getVar("TEST_SUITES", True).split()
134 if type == "sdk":
135 testsuites = (d.getVar("TEST_SUITES_SDK", True) or "auto").split()
136 bbpath = d.getVar("BBPATH", True).split(':')
137
138 # This relies on lib/ under each directory in BBPATH being added to sys.path
139 # (as done by default in base.bbclass)
140 for testname in testsuites:
141 if testname != "auto":
142 if testname.startswith("oeqa."):
143 testslist.append(testname)
144 continue
145 found = False
146 for p in bbpath:
147 if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
148 testslist.append("oeqa." + type + "." + testname)
149 found = True
150 break
151 elif os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname.split(".")[0] + '.py')):
152 testslist.append("oeqa." + type + "." + testname)
153 found = True
154 break
155 if not found:
156 bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
157
158 if "auto" in testsuites:
159 def add_auto_list(path):
160 if not os.path.exists(os.path.join(path, '__init__.py')):
161 bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
162 files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')])
163 for f in files:
164 module = 'oeqa.' + type + '.' + f[:-3]
165 if module not in testslist:
166 testslist.append(module)
167
168 for p in bbpath:
169 testpath = os.path.join(p, 'lib', 'oeqa', type)
170 bb.debug(2, 'Searching for tests in %s' % testpath)
171 if os.path.exists(testpath):
172 add_auto_list(testpath)
173
174 return testslist
175
176
177def exportTests(d,tc): 109def exportTests(d,tc):
178 import json 110 import json
179 import shutil 111 import shutil
@@ -272,7 +204,7 @@ def testimage_main(d):
272 import oeqa.runtime 204 import oeqa.runtime
273 import time 205 import time
274 import signal 206 import signal
275 from oeqa.oetest import loadTests, runTests 207 from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list
276 from oeqa.targetcontrol import get_target_controller 208 from oeqa.targetcontrol import get_target_controller
277 from oeqa.utils.dump import get_host_dumper 209 from oeqa.utils.dump import get_host_dumper
278 210
@@ -286,7 +218,7 @@ def testimage_main(d):
286 # tests in TEST_SUITES become required tests 218 # tests in TEST_SUITES become required tests
287 # they won't be skipped even if they aren't suitable for a image (like xorg for minimal) 219 # they won't be skipped even if they aren't suitable for a image (like xorg for minimal)
288 # testslist is what we'll actually pass to the unittest loader 220 # testslist is what we'll actually pass to the unittest loader
289 testslist = get_tests_list(d) 221 testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':'))
290 testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] 222 testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"]
291 223
292 tagexp = d.getVar("TEST_SUITES_TAGS", True) 224 tagexp = d.getVar("TEST_SUITES_TAGS", True)
@@ -368,7 +300,6 @@ def testimage_main(d):
368 300
369testimage_main[vardepsexclude] =+ "BB_ORIGENV" 301testimage_main[vardepsexclude] =+ "BB_ORIGENV"
370 302
371
372def testsdk_main(d): 303def testsdk_main(d):
373 import unittest 304 import unittest
374 import os 305 import os
@@ -377,7 +308,7 @@ def testsdk_main(d):
377 import oeqa.sdk 308 import oeqa.sdk
378 import time 309 import time
379 import subprocess 310 import subprocess
380 from oeqa.oetest import loadTests, runTests 311 from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list
381 312
382 pn = d.getVar("PN", True) 313 pn = d.getVar("PN", True)
383 bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) 314 bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
@@ -385,7 +316,7 @@ def testsdk_main(d):
385 # tests in TEST_SUITES become required tests 316 # tests in TEST_SUITES become required tests
386 # they won't be skipped even if they aren't suitable. 317 # they won't be skipped even if they aren't suitable.
387 # testslist is what we'll actually pass to the unittest loader 318 # testslist is what we'll actually pass to the unittest loader
388 testslist = get_tests_list(d, "sdk") 319 testslist = get_tests_list(get_test_suites(d, "sdk"), d.getVar("BBPATH", True).split(':'), "sdk")
389 testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"] 320 testsrequired = [t for t in (d.getVar("TEST_SUITES_SDK", True) or "auto").split() if t != "auto"]
390 321
391 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh") 322 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
@@ -457,4 +388,3 @@ def testsdk_main(d):
457 bb.utils.remove(sdktestdir, True) 388 bb.utils.remove(sdktestdir, True)
458 389
459testsdk_main[vardepsexclude] =+ "BB_ORIGENV" 390testsdk_main[vardepsexclude] =+ "BB_ORIGENV"
460
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