blob: 758a23ac5532e8c60ae95fb290bc1f1c5f2ced2a [file] [log] [blame]
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05001# Copyright (C) 2013 - 2016 Intel Corporation
2#
3# Released under the MIT license (see COPYING.MIT)
4
5# testsdk.bbclass enables testing for SDK and Extensible SDK
6#
Brad Bishop37a0e4d2017-12-04 01:01:44 -05007# To run SDK tests, run the commands:
8# $ bitbake <image-name> -c populate_sdk
9# $ bitbake <image-name> -c testsdk
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050010#
Brad Bishop37a0e4d2017-12-04 01:01:44 -050011# To run eSDK tests, run the commands:
12# $ bitbake <image-name> -c populate_sdk_ext
13# $ bitbake <image-name> -c testsdkext
14#
15# where "<image-name>" is an image like core-image-sato.
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050016
Brad Bishop977dc1a2019-02-06 16:01:43 -050017TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK"
18TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt"
Brad Bishopf86d0552018-12-04 14:18:15 -080019
Brad Bishop977dc1a2019-02-06 16:01:43 -050020def import_and_run(name, d):
21 import importlib
Brad Bishopf86d0552018-12-04 14:18:15 -080022
Brad Bishop977dc1a2019-02-06 16:01:43 -050023 class_name = d.getVar(name)
24 if class_name:
25 module, cls = class_name.rsplit('.', 1)
26 m = importlib.import_module(module)
27 c = getattr(m, cls)()
28 c.run(d)
29 else:
30 bb.warn('No tests were run because %s did not define a class' % name)
Brad Bishopf86d0552018-12-04 14:18:15 -080031
Brad Bishop977dc1a2019-02-06 16:01:43 -050032import_and_run[vardepsexclude] = "DATETIME BB_ORIGENV"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033
34python do_testsdk() {
Brad Bishop977dc1a2019-02-06 16:01:43 -050035 import_and_run('TESTSDK_CLASS_NAME', d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050036}
37addtask testsdk
38do_testsdk[nostamp] = "1"
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050040python do_testsdkext() {
Brad Bishop977dc1a2019-02-06 16:01:43 -050041 import_and_run('TESTSDKEXT_CLASS_NAME', d)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050042}
43addtask testsdkext
44do_testsdkext[nostamp] = "1"
Brad Bishop6e60e8b2018-02-01 10:27:11 -050045
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080046python () {
47 if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"):
48 bb.build.addtask("testsdk", None, "do_populate_sdk", d)
49 bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d)
50}