summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCorneliu Stoicescu <corneliux.stoicescu@intel.com>2014-08-09 13:59:06 +0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-18 08:55:54 +0100
commitc8de46cb068ae5fc17301e6f37f5f679ec25e2a0 (patch)
tree07be84eb7bf546c9168f73984d05b94b5128109a
parent59b0f7f01bbac6f1c10ee00382c5136d1f327960 (diff)
downloadpoky-c8de46cb068ae5fc17301e6f37f5f679ec25e2a0.tar.gz
meta/classes/testimage.bbclass: add testsdk task and enable functionality for it.
- add new testsdk task for meta-toolchain testing. - enable the get_tests_list method to work with sdk tests. - add default TEST_SUITES value for meta-toolchain package NOTE: Original patch made by: Richard Purdie <richard.purdie@linuxfoundation.org> (From OE-Core rev: b78bc50904d53d5091729de481b99cc3ac4aaa1e) Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/testimage.bbclass97
1 files changed, 90 insertions, 7 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 285c6a9d42..97d0380153 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -19,7 +19,7 @@
19# Note that order in TEST_SUITES is important (it's the order tests run) and it influences tests dependencies. 19# Note that order in TEST_SUITES is important (it's the order tests run) and it influences tests dependencies.
20# A layer can add its own tests in lib/oeqa/runtime, provided it extends BBPATH as normal in its layer.conf. 20# A layer can add its own tests in lib/oeqa/runtime, provided it extends BBPATH as normal in its layer.conf.
21 21
22# TEST_LOG_DIR contains a ssh log (what command is running, output and return codes) and a qemu boot log till login 22# TEST_LOG_DIR contains a command ssh log and may contain infromation about what command is running, output and return codes and for qemu a boot log till login.
23# Booting is handled by this class, and it's not a test in itself. 23# Booting is handled by this class, and it's not a test in itself.
24# TEST_QEMUBOOT_TIMEOUT can be used to set the maximum time in seconds the launch code will wait for the login prompt. 24# TEST_QEMUBOOT_TIMEOUT can be used to set the maximum time in seconds the launch code will wait for the login prompt.
25 25
@@ -32,6 +32,7 @@ DEFAULT_TEST_SUITES = "ping auto"
32DEFAULT_TEST_SUITES_pn-core-image-minimal = "ping" 32DEFAULT_TEST_SUITES_pn-core-image-minimal = "ping"
33DEFAULT_TEST_SUITES_pn-core-image-sato = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg python" 33DEFAULT_TEST_SUITES_pn-core-image-sato = "ping ssh df connman syslog xorg scp vnc date rpm smart dmesg python"
34DEFAULT_TEST_SUITES_pn-core-image-sato-sdk = "ping ssh df connman syslog xorg scp vnc date perl ldd gcc rpm smart kernelmodule dmesg python" 34DEFAULT_TEST_SUITES_pn-core-image-sato-sdk = "ping ssh df connman syslog xorg scp vnc date perl ldd gcc rpm smart kernelmodule dmesg python"
35DEFAULT_TEST_SUITES_pn-meta-toolchain = "auto"
35TEST_SUITES ?= "${DEFAULT_TEST_SUITES}" 36TEST_SUITES ?= "${DEFAULT_TEST_SUITES}"
36 37
37TEST_QEMUBOOT_TIMEOUT ?= "1000" 38TEST_QEMUBOOT_TIMEOUT ?= "1000"
@@ -53,8 +54,15 @@ do_testimage[nostamp] = "1"
53do_testimage[depends] += "${TESTIMAGEDEPENDS}" 54do_testimage[depends] += "${TESTIMAGEDEPENDS}"
54do_testimage[lockfiles] += "${TESTIMAGELOCK}" 55do_testimage[lockfiles] += "${TESTIMAGELOCK}"
55 56
57python do_testsdk() {
58 testsdk_main(d)
59}
60addtask testsdk
61do_testsdk[nostamp] = "1"
62do_testsdk[depends] += "${TESTIMAGEDEPENDS}"
63do_testsdk[lockfiles] += "${TESTIMAGELOCK}"
56 64
57def get_tests_list(d): 65def get_tests_list(d, type="runtime"):
58 testsuites = d.getVar("TEST_SUITES", True).split() 66 testsuites = d.getVar("TEST_SUITES", True).split()
59 bbpath = d.getVar("BBPATH", True).split(':') 67 bbpath = d.getVar("BBPATH", True).split(':')
60 68
@@ -65,12 +73,12 @@ def get_tests_list(d):
65 if testname != "auto": 73 if testname != "auto":
66 found = False 74 found = False
67 for p in bbpath: 75 for p in bbpath:
68 if os.path.exists(os.path.join(p, 'lib', 'oeqa', 'runtime', testname + '.py')): 76 if os.path.exists(os.path.join(p, 'lib', 'oeqa', type, testname + '.py')):
69 testslist.append("oeqa.runtime." + testname) 77 testslist.append("oeqa." + type + "." + testname)
70 found = True 78 found = True
71 break 79 break
72 if not found: 80 if not found:
73 bb.error('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname) 81 bb.fatal('Test %s specified in TEST_SUITES could not be found in lib/oeqa/runtime under BBPATH' % testname)
74 82
75 if "auto" in testsuites: 83 if "auto" in testsuites:
76 def add_auto_list(path): 84 def add_auto_list(path):
@@ -78,12 +86,12 @@ def get_tests_list(d):
78 bb.fatal('Tests directory %s exists but is missing __init__.py' % path) 86 bb.fatal('Tests directory %s exists but is missing __init__.py' % path)
79 files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')]) 87 files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')])
80 for f in files: 88 for f in files:
81 module = 'oeqa.runtime.' + f[:-3] 89 module = 'oeqa.' + type + '.' + f[:-3]
82 if module not in testslist: 90 if module not in testslist:
83 testslist.append(module) 91 testslist.append(module)
84 92
85 for p in bbpath: 93 for p in bbpath:
86 testpath = os.path.join(p, 'lib', 'oeqa', 'runtime') 94 testpath = os.path.join(p, 'lib', 'oeqa', type)
87 bb.debug(2, 'Searching for tests in %s' % testpath) 95 bb.debug(2, 'Searching for tests in %s' % testpath)
88 if os.path.exists(testpath): 96 if os.path.exists(testpath):
89 add_auto_list(testpath) 97 add_auto_list(testpath)
@@ -230,3 +238,78 @@ def testimage_main(d):
230 target.stop() 238 target.stop()
231 239
232testimage_main[vardepsexclude] =+ "BB_ORIGENV" 240testimage_main[vardepsexclude] =+ "BB_ORIGENV"
241
242
243def testsdk_main(d):
244 import unittest
245 import os
246 import glob
247 import oeqa.runtime
248 import oeqa.sdk
249 import time
250 import subprocess
251 from oeqa.oetest import loadTests, runTests
252
253 pn = d.getVar("PN", True)
254 bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True))
255
256 # tests in TEST_SUITES become required tests
257 # they won't be skipped even if they aren't suitable.
258 # testslist is what we'll actually pass to the unittest loader
259 testslist = get_tests_list(d, "sdk")
260 testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"]
261
262 sdktestdir = d.expand("${WORKDIR}/testimage-sdk/")
263 bb.utils.remove(sdktestdir, True)
264 bb.utils.mkdirhier(sdktestdir)
265
266 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh")
267 if not os.path.exists(tcname):
268 bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake meta-toolchain' .")
269 subprocess.call("cd %s; %s <<EOF\n./tc\nY\nEOF" % (sdktestdir, tcname), shell=True)
270
271 targets = glob.glob(d.expand(sdktestdir + "/tc/sysroots/*${TARGET_VENDOR}-linux*"))
272 if len(targets) > 1:
273 bb.fatal("Error, multiple targets within the SDK found and we don't know which to test? %s" % str(targets))
274 sdkenv = sdktestdir + "/tc/environment-setup-" + os.path.basename(targets[0])
275
276 class TestContext(object):
277 def __init__(self):
278 self.d = d
279 self.testslist = testslist
280 self.testsrequired = testsrequired
281 self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files")
282 self.sdktestdir = sdktestdir
283 self.sdkenv = sdkenv
284
285 # test context
286 tc = TestContext()
287
288 # this is a dummy load of tests
289 # we are doing that to find compile errors in the tests themselves
290 # before booting the image
291 try:
292 loadTests(tc, "sdk")
293 except Exception as e:
294 import traceback
295 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
296
297 try:
298 starttime = time.time()
299 result = runTests(tc, "sdk")
300 stoptime = time.time()
301 if result.wasSuccessful():
302 bb.plain("%s - Ran %d test%s in %.3fs" % (pn, result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
303 msg = "%s - OK - All required tests passed" % pn
304 skipped = len(result.skipped)
305 if skipped:
306 msg += " (skipped=%d)" % skipped
307 bb.plain(msg)
308 else:
309 raise bb.build.FuncFailed("%s - FAILED - check the task log and the commands log" % pn )
310 finally:
311 pass
312 bb.utils.remove(sdktestdir, True)
313
314testsdk_main[vardepsexclude] =+ "BB_ORIGENV"
315