diff options
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/testimage.bbclass | 40 | ||||
-rw-r--r-- | meta/classes/testsdk.bbclass | 29 |
2 files changed, 6 insertions, 63 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass index 6eea3f8a27..bdd6c9de6f 100644 --- a/meta/classes/testimage.bbclass +++ b/meta/classes/testimage.bbclass | |||
@@ -195,7 +195,8 @@ def testimage_main(d): | |||
195 | import oeqa.runtime | 195 | import oeqa.runtime |
196 | import time | 196 | import time |
197 | import signal | 197 | import signal |
198 | from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list | 198 | from oeqa.oetest import loadTests, runTests, \ |
199 | get_test_suites, get_tests_list, ImageTestContext | ||
199 | from oeqa.targetcontrol import get_target_controller | 200 | from oeqa.targetcontrol import get_target_controller |
200 | from oeqa.utils.dump import get_host_dumper | 201 | from oeqa.utils.dump import get_host_dumper |
201 | 202 | ||
@@ -212,48 +213,14 @@ def testimage_main(d): | |||
212 | testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':')) | 213 | testslist = get_tests_list(get_test_suites(d), d.getVar("BBPATH", True).split(':')) |
213 | testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] | 214 | testsrequired = [t for t in d.getVar("TEST_SUITES", True).split() if t != "auto"] |
214 | 215 | ||
215 | tagexp = d.getVar("TEST_SUITES_TAGS", True) | ||
216 | |||
217 | # we need the host dumper in test context | 216 | # we need the host dumper in test context |
218 | host_dumper = get_host_dumper(d) | 217 | host_dumper = get_host_dumper(d) |
219 | 218 | ||
220 | # the robot dance | 219 | # the robot dance |
221 | target = get_target_controller(d) | 220 | target = get_target_controller(d) |
222 | 221 | ||
223 | class TestContext(object): | ||
224 | def __init__(self): | ||
225 | self.d = d | ||
226 | self.testslist = testslist | ||
227 | self.tagexp = tagexp | ||
228 | self.testsrequired = testsrequired | ||
229 | self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files") | ||
230 | self.target = target | ||
231 | self.host_dumper = host_dumper | ||
232 | self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split() | ||
233 | self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split() | ||
234 | manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + ".manifest") | ||
235 | nomanifest = d.getVar("IMAGE_NO_MANIFEST", True) | ||
236 | |||
237 | self.sigterm = False | ||
238 | self.origsigtermhandler = signal.getsignal(signal.SIGTERM) | ||
239 | signal.signal(signal.SIGTERM, self.sigterm_exception) | ||
240 | |||
241 | if nomanifest is None or nomanifest != "1": | ||
242 | try: | ||
243 | with open(manifest) as f: | ||
244 | self.pkgmanifest = f.read() | ||
245 | except IOError as e: | ||
246 | bb.fatal("No package manifest file found. Did you build the image?\n%s" % e) | ||
247 | else: | ||
248 | self.pkgmanifest = "" | ||
249 | |||
250 | def sigterm_exception(self, signum, stackframe): | ||
251 | bb.warn("TestImage received SIGTERM, shutting down...") | ||
252 | self.sigterm = True | ||
253 | self.target.stop() | ||
254 | |||
255 | # test context | 222 | # test context |
256 | tc = TestContext() | 223 | tc = ImageTestContext(d, testslist, testsrequired, target, host_dumper) |
257 | 224 | ||
258 | # this is a dummy load of tests | 225 | # this is a dummy load of tests |
259 | # we are doing that to find compile errors in the tests themselves | 226 | # we are doing that to find compile errors in the tests themselves |
@@ -264,7 +231,6 @@ def testimage_main(d): | |||
264 | import traceback | 231 | import traceback |
265 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) | 232 | bb.fatal("Loading tests failed:\n%s" % traceback.format_exc()) |
266 | 233 | ||
267 | |||
268 | if export: | 234 | if export: |
269 | signal.signal(signal.SIGTERM, tc.origsigtermhandler) | 235 | signal.signal(signal.SIGTERM, tc.origsigtermhandler) |
270 | tc.origsigtermhandler = None | 236 | tc.origsigtermhandler = None |
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass index 104c7a15f4..06e7a77398 100644 --- a/meta/classes/testsdk.bbclass +++ b/meta/classes/testsdk.bbclass | |||
@@ -13,7 +13,8 @@ def testsdk_main(d): | |||
13 | import oeqa.sdk | 13 | import oeqa.sdk |
14 | import time | 14 | import time |
15 | import subprocess | 15 | import subprocess |
16 | from oeqa.oetest import loadTests, runTests, get_test_suites, get_tests_list | 16 | from oeqa.oetest import loadTests, runTests, \ |
17 | get_test_suites, get_tests_list, SDKTestContext | ||
17 | 18 | ||
18 | pn = d.getVar("PN", True) | 19 | pn = d.getVar("PN", True) |
19 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) | 20 | bb.utils.mkdirhier(d.getVar("TEST_LOG_DIR", True)) |
@@ -28,29 +29,6 @@ def testsdk_main(d): | |||
28 | if not os.path.exists(tcname): | 29 | if not os.path.exists(tcname): |
29 | bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' .") | 30 | bb.fatal("The toolchain is not built. Build it before running the tests: 'bitbake <image> -c populate_sdk' .") |
30 | 31 | ||
31 | class TestContext(object): | ||
32 | def __init__(self): | ||
33 | self.d = d | ||
34 | self.testslist = testslist | ||
35 | self.testsrequired = testsrequired | ||
36 | self.filesdir = os.path.join(os.path.dirname(os.path.abspath(oeqa.runtime.__file__)),"files") | ||
37 | self.sdktestdir = sdktestdir | ||
38 | self.sdkenv = sdkenv | ||
39 | self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split() | ||
40 | self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split() | ||
41 | manifest = d.getVar("SDK_TARGET_MANIFEST", True) | ||
42 | try: | ||
43 | with open(manifest) as f: | ||
44 | self.pkgmanifest = f.read() | ||
45 | except IOError as e: | ||
46 | bb.fatal("No package manifest file found. Did you build the sdk image?\n%s" % e) | ||
47 | hostmanifest = d.getVar("SDK_HOST_MANIFEST", True) | ||
48 | try: | ||
49 | with open(hostmanifest) as f: | ||
50 | self.hostpkgmanifest = f.read() | ||
51 | except IOError as e: | ||
52 | bb.fatal("No host package manifest file found. Did you build the sdk image?\n%s" % e) | ||
53 | |||
54 | sdktestdir = d.expand("${WORKDIR}/testimage-sdk/") | 32 | sdktestdir = d.expand("${WORKDIR}/testimage-sdk/") |
55 | bb.utils.remove(sdktestdir, True) | 33 | bb.utils.remove(sdktestdir, True) |
56 | bb.utils.mkdirhier(sdktestdir) | 34 | bb.utils.mkdirhier(sdktestdir) |
@@ -63,8 +41,7 @@ def testsdk_main(d): | |||
63 | targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*")) | 41 | targets = glob.glob(d.expand(sdktestdir + "/tc/environment-setup-*")) |
64 | for sdkenv in targets: | 42 | for sdkenv in targets: |
65 | bb.plain("Testing %s" % sdkenv) | 43 | bb.plain("Testing %s" % sdkenv) |
66 | # test context | 44 | tc = SDKTestContext(d, testslist, testsrequired, sdktestdir, sdkenv) |
67 | tc = TestContext() | ||
68 | 45 | ||
69 | # this is a dummy load of tests | 46 | # this is a dummy load of tests |
70 | # we are doing that to find compile errors in the tests themselves | 47 | # we are doing that to find compile errors in the tests themselves |