summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2018-10-23 13:57:22 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-16 14:31:27 +0000
commit8ea47d187dbb211b6caa33e996694ab6be136804 (patch)
tree0f4d1de4693d9950d51ef8d6be9c1dd3f8fe6979 /meta/classes
parente92ebb4295ae65a3dc6c58e81e7c00ed30c1f970 (diff)
downloadpoky-8ea47d187dbb211b6caa33e996694ab6be136804.tar.gz
testsdk.bbclass: write testresult to json files
As part of the solution to replace Testopia to store testresult, OEQA sdk and sdkext need to output testresult into json files, where these json testresult files will be stored into git repository by the future test-case-management tools. By default, json testresult file will be written to "oeqa" directory under the "WORKDIR" directory. To configure multiple instances of bitbake to write json testresult to a single testresult file at custom directory, user will define the variable "OEQA_JSON_RESULT_DIR" with the custom directory for json testresult. (From OE-Core rev: eefb07907873d20f2e66d3784106f6f72030b5b2) Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/testsdk.bbclass36
1 files changed, 32 insertions, 4 deletions
diff --git a/meta/classes/testsdk.bbclass b/meta/classes/testsdk.bbclass
index 103cc56bf5..66170e3377 100644
--- a/meta/classes/testsdk.bbclass
+++ b/meta/classes/testsdk.bbclass
@@ -14,6 +14,30 @@
14# 14#
15# where "<image-name>" is an image like core-image-sato. 15# where "<image-name>" is an image like core-image-sato.
16 16
17def _get_sdk_configuration(d, test_type, pid):
18 import platform
19 configuration = {'TEST_TYPE': test_type,
20 'PROCESS_ID': pid,
21 'SDK_MACHINE': d.getVar("SDKMACHINE"),
22 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"),
23 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"),
24 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-')}
25 layers = (d.getVar("BBLAYERS") or "").split()
26 for l in layers:
27 configuration['%s_BRANCH_REV' % os.path.basename(l)] = '%s:%s' % (base_get_metadata_git_branch(l, None).strip(),
28 base_get_metadata_git_revision(l, None))
29 return configuration
30
31def _get_sdk_json_result_dir(d):
32 json_result_dir = os.path.join(d.getVar("WORKDIR"), 'oeqa')
33 custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR")
34 if custom_json_result_dir:
35 json_result_dir = custom_json_result_dir
36 return json_result_dir
37
38def _get_sdk_result_id(configuration):
39 return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['SDK_MACHINE'])
40
17def testsdk_main(d): 41def testsdk_main(d):
18 import os 42 import os
19 import subprocess 43 import subprocess
@@ -69,8 +93,10 @@ def testsdk_main(d):
69 93
70 component = "%s %s" % (pn, OESDKTestContextExecutor.name) 94 component = "%s %s" % (pn, OESDKTestContextExecutor.name)
71 context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) 95 context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
72 96 configuration = _get_sdk_configuration(d, 'sdk', os.getpid())
73 result.logDetails() 97 result.logDetails(_get_sdk_json_result_dir(d),
98 configuration,
99 _get_sdk_result_id(configuration))
74 result.logSummary(component, context_msg) 100 result.logSummary(component, context_msg)
75 101
76 if not result.wasSuccessful(): 102 if not result.wasSuccessful():
@@ -172,8 +198,10 @@ def testsdkext_main(d):
172 198
173 component = "%s %s" % (pn, OESDKExtTestContextExecutor.name) 199 component = "%s %s" % (pn, OESDKExtTestContextExecutor.name)
174 context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env)) 200 context_msg = "%s:%s" % (os.path.basename(tcname), os.path.basename(sdk_env))
175 201 configuration = _get_sdk_configuration(d, 'sdkext', os.getpid())
176 result.logDetails() 202 result.logDetails(_get_sdk_json_result_dir(d),
203 configuration,
204 _get_sdk_result_id(configuration))
177 result.logSummary(component, context_msg) 205 result.logSummary(component, context_msg)
178 206
179 if not result.wasSuccessful(): 207 if not result.wasSuccessful():