Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | # 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 Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 7 | # To run SDK tests, run the commands: |
| 8 | # $ bitbake <image-name> -c populate_sdk |
| 9 | # $ bitbake <image-name> -c testsdk |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10 | # |
Brad Bishop | 37a0e4d | 2017-12-04 01:01:44 -0500 | [diff] [blame] | 11 | # 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 Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 16 | |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 17 | TESTSDK_CLASS_NAME ?= "oeqa.sdk.testsdk.TestSDK" |
| 18 | TESTSDKEXT_CLASS_NAME ?= "oeqa.sdkext.testsdk.TestSDKExt" |
Brad Bishop | f86d055 | 2018-12-04 14:18:15 -0800 | [diff] [blame] | 19 | |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 20 | def import_and_run(name, d): |
| 21 | import importlib |
Brad Bishop | f86d055 | 2018-12-04 14:18:15 -0800 | [diff] [blame] | 22 | |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 23 | 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 Bishop | f86d055 | 2018-12-04 14:18:15 -0800 | [diff] [blame] | 31 | |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 32 | import_and_run[vardepsexclude] = "DATETIME BB_ORIGENV" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 33 | |
| 34 | python do_testsdk() { |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 35 | import_and_run('TESTSDK_CLASS_NAME', d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 36 | } |
| 37 | addtask testsdk |
| 38 | do_testsdk[nostamp] = "1" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 39 | do_testsdk[network] = "1" |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 40 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 41 | python do_testsdkext() { |
Brad Bishop | 977dc1a | 2019-02-06 16:01:43 -0500 | [diff] [blame] | 42 | import_and_run('TESTSDKEXT_CLASS_NAME', d) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 43 | } |
| 44 | addtask testsdkext |
| 45 | do_testsdkext[nostamp] = "1" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 46 | do_testsdkext[network] = "1" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 48 | python () { |
| 49 | if oe.types.boolean(d.getVar("TESTIMAGE_AUTO") or "False"): |
| 50 | bb.build.addtask("testsdk", None, "do_populate_sdk", d) |
| 51 | bb.build.addtask("testsdkext", None, "do_populate_sdk_ext", d) |
| 52 | } |