summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorAníbal Limón <anibal.limon@linux.intel.com>2016-11-30 15:11:40 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-23 12:05:19 +0000
commit03d175f1fae52428da8ff43fd3de336dcd761362 (patch)
tree06c4af93fc9945dc35a9b5973c9e2f080c3d01ef /meta/classes
parent14eee4fdf844e70966124bd3b1677e79a76d16a2 (diff)
downloadpoky-03d175f1fae52428da8ff43fd3de336dcd761362.tar.gz
classes/testsdk: Migrate to use the new OESDKExtTestContext
(From OE-Core rev: b254822dad850ce74563c83b7a9e31463501baa7) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/testsdk.bbclass98
1 files changed, 45 insertions, 53 deletions
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 176dafd6b3..69689a1b36 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -16,37 +16,6 @@
16 16
17TESTSDKLOCK = "${TMPDIR}/testsdk.lock" 17TESTSDKLOCK = "${TMPDIR}/testsdk.lock"
18 18
19def run_test_context(CTestContext, d, testdir, tcname, pn, *args):
20 import glob
21 import time
22
23 targets = glob.glob(d.expand(testdir + "/tc/environment-setup-*"))
24 for sdkenv in targets:
25 bb.plain("Testing %s" % sdkenv)
26 tc = CTestContext(d, testdir, sdkenv, tcname, args)
27
28 # this is a dummy load of tests
29 # we are doing that to find compile errors in the tests themselves
30 # before booting the image
31 try:
32 tc.loadTests()
33 except Exception as e:
34 import traceback
35 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
36
37 starttime = time.time()
38 result = tc.runTests()
39 stoptime = time.time()
40 if result.wasSuccessful():
41 bb.plain("%s SDK(%s):%s - Ran %d test%s in %.3fs" % (pn, os.path.basename(tcname), os.path.basename(sdkenv),result.testsRun, result.testsRun != 1 and "s" or "", stoptime - starttime))
42 msg = "%s - OK - All required tests passed" % pn
43 skipped = len(result.skipped)
44 if skipped:
45 msg += " (skipped=%d)" % skipped
46 bb.plain(msg)
47 else:
48 bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
49
50def testsdk_main(d): 19def testsdk_main(d):
51 import os 20 import os
52 import subprocess 21 import subprocess
@@ -122,7 +91,6 @@ addtask testsdk
122do_testsdk[nostamp] = "1" 91do_testsdk[nostamp] = "1"
123do_testsdk[lockfiles] += "${TESTSDKLOCK}" 92do_testsdk[lockfiles] += "${TESTSDKLOCK}"
124 93
125TEST_LOG_SDKEXT_DIR ?= "${WORKDIR}/testsdkext"
126TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock" 94TESTSDKEXTLOCK = "${TMPDIR}/testsdkext.lock"
127 95
128def testsdkext_main(d): 96def testsdkext_main(d):
@@ -132,7 +100,11 @@ def testsdkext_main(d):
132 import logging 100 import logging
133 101
134 from bb.utils import export_proxies 102 from bb.utils import export_proxies
135 from oeqa.utils import avoid_paths_in_environ 103 from oeqa.utils import avoid_paths_in_environ, make_logger_bitbake_compatible
104 from oeqa.sdkext.context import OESDKExtTestContext, OESDKExtTestContextExecutor
105
106 pn = d.getVar("PN", True)
107 logger = make_logger_bitbake_compatible(logging.getLogger("BitBake"))
136 108
137 # extensible sdk use network 109 # extensible sdk use network
138 export_proxies(d) 110 export_proxies(d)
@@ -143,23 +115,27 @@ def testsdkext_main(d):
143 d.getVar('BASE_WORKDIR')] 115 d.getVar('BASE_WORKDIR')]
144 os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid) 116 os.environ['PATH'] = avoid_paths_in_environ(paths_to_avoid)
145 117
146 pn = d.getVar("PN")
147 bb.utils.mkdirhier(d.getVar("TEST_LOG_SDKEXT_DIR"))
148
149 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh") 118 tcname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.sh")
150 if not os.path.exists(tcname): 119 if not os.path.exists(tcname):
151 bb.fatal("The toolchain ext %s is not built. Build it before running the" \ 120 bb.fatal("The toolchain ext %s is not built. Build it before running the" \
152 " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname) 121 " tests: 'bitbake <image> -c populate_sdk_ext' ." % tcname)
153 122
154 testdir = d.expand("${WORKDIR}/testsdkext/") 123 tdname = d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.testdata.json")
155 bb.utils.remove(testdir, True) 124 test_data = json.load(open(tdname, "r"))
156 bb.utils.mkdirhier(testdir) 125
157 sdkdir = os.path.join(testdir, 'tc') 126 target_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
127 d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.target.manifest"))
128 host_pkg_manifest = OESDKExtTestContextExecutor._load_manifest(
129 d.expand("${SDK_DEPLOY}/${TOOLCHAINEXT_OUTPUTNAME}.host.manifest"))
130
131 sdk_dir = d.expand("${WORKDIR}/testsdkext/")
132 bb.utils.remove(sdk_dir, True)
133 bb.utils.mkdirhier(sdk_dir)
158 try: 134 try:
159 subprocess.check_output("%s -y -d %s" % (tcname, sdkdir), shell=True) 135 subprocess.check_output("%s -y -d %s" % (tcname, sdk_dir), shell=True)
160 except subprocess.CalledProcessError as e: 136 except subprocess.CalledProcessError as e:
161 msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8") 137 msg = "Couldn't install the extensible SDK:\n%s" % e.output.decode("utf-8")
162 logfn = os.path.join(sdkdir, 'preparing_build_system.log') 138 logfn = os.path.join(sdk_dir, 'preparing_build_system.log')
163 if os.path.exists(logfn): 139 if os.path.exists(logfn):
164 msg += '\n\nContents of preparing_build_system.log:\n' 140 msg += '\n\nContents of preparing_build_system.log:\n'
165 with open(logfn, 'r') as f: 141 with open(logfn, 'r') as f:
@@ -167,19 +143,35 @@ def testsdkext_main(d):
167 msg += line 143 msg += line
168 bb.fatal(msg) 144 bb.fatal(msg)
169 145
170 try: 146 fail = False
171 bb.plain("Running SDK Compatibility tests ...") 147 sdk_envs = OESDKExtTestContextExecutor._get_sdk_environs(sdk_dir)
172 run_test_context(SDKExtTestContext, d, testdir, tcname, pn, True) 148 for s in sdk_envs:
173 finally: 149 bb.plain("Extensible SDK testing environment: %s" % s)
174 pass
175 150
176 try: 151 sdk_env = sdk_envs[s]
177 bb.plain("Running Extensible SDK tests ...") 152 tc = OESDKExtTestContext(td=test_data, logger=logger, sdk_dir=sdk_dir,
178 run_test_context(SDKExtTestContext, d, testdir, tcname, pn) 153 sdk_env=sdk_env, target_pkg_manifest=target_pkg_manifest,
179 finally: 154 host_pkg_manifest=host_pkg_manifest)
180 pass 155
156 try:
157 tc.loadTests(OESDKExtTestContextExecutor.default_cases)
158 except Exception as e:
159 import traceback
160 bb.fatal("Loading tests failed:\n%s" % traceback.format_exc())
161
162 result = tc.runTests()
181 163
182 bb.utils.remove(testdir, True) 164 component = "%s %s" % (pn, OESDKExtTestContextExecutor.name)
165 context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
166
167 tc.logSummary(result, component, context_msg)
168 tc.logDetails()
169
170 if not result.wasSuccessful():
171 fail = True
172
173 if fail:
174 bb.fatal("%s - FAILED - check the task log and the commands log" % pn)
183 175
184testsdkext_main[vardepsexclude] =+ "BB_ORIGENV" 176testsdkext_main[vardepsexclude] =+ "BB_ORIGENV"
185 177