summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2018-10-23 13:57:21 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-16 14:31:27 +0000
commite92ebb4295ae65a3dc6c58e81e7c00ed30c1f970 (patch)
tree90f7ea3c9f64c8c25d513ccf4dc731ede91e581a /meta/classes
parent5a99880992b143313dfa14f85c3898ec74e889b1 (diff)
downloadpoky-e92ebb4295ae65a3dc6c58e81e7c00ed30c1f970.tar.gz
testimage.bbclass: write testresult to json files
As part of the solution to replace Testopia to store testresult, OEQA testimage 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: 2b8b47ec8ee835d2e70cc4ff3ec484f9e4e4d02d) 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/testimage.bbclass31
1 files changed, 29 insertions, 2 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 9feb26770a..e95ce0c9e3 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -2,7 +2,7 @@
2# 2#
3# Released under the MIT license (see COPYING.MIT) 3# Released under the MIT license (see COPYING.MIT)
4 4
5 5inherit metadata_scm
6# testimage.bbclass enables testing of qemu images using python unittests. 6# testimage.bbclass enables testing of qemu images using python unittests.
7# Most of the tests are commands run on target image over ssh. 7# Most of the tests are commands run on target image over ssh.
8# To use it add testimage to global inherit and call your target image with -c testimage 8# To use it add testimage to global inherit and call your target image with -c testimage
@@ -132,6 +132,30 @@ def testimage_sanity(d):
132 bb.fatal('When TEST_TARGET is set to "simpleremote" ' 132 bb.fatal('When TEST_TARGET is set to "simpleremote" '
133 'TEST_TARGET_IP and TEST_SERVER_IP are needed too.') 133 'TEST_TARGET_IP and TEST_SERVER_IP are needed too.')
134 134
135def _get_testimage_configuration(d, test_type, pid, machine):
136 import platform
137 configuration = {'TEST_TYPE': test_type,
138 'PROCESS_ID': pid,
139 'MACHINE': machine,
140 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"),
141 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"),
142 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-')}
143 layers = (d.getVar("BBLAYERS") or "").split()
144 for l in layers:
145 configuration['%s_BRANCH_REV' % os.path.basename(l)] = '%s:%s' % (base_get_metadata_git_branch(l, None).strip(),
146 base_get_metadata_git_revision(l, None))
147 return configuration
148
149def _get_testimage_json_result_dir(d):
150 json_result_dir = os.path.join(d.getVar("WORKDIR"), 'oeqa')
151 custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR")
152 if custom_json_result_dir:
153 json_result_dir = custom_json_result_dir
154 return json_result_dir
155
156def _get_testimage_result_id(configuration):
157 return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['MACHINE'])
158
135def testimage_main(d): 159def testimage_main(d):
136 import os 160 import os
137 import json 161 import json
@@ -299,7 +323,10 @@ def testimage_main(d):
299 # Show results (if we have them) 323 # Show results (if we have them)
300 if not results: 324 if not results:
301 bb.fatal('%s - FAILED - tests were interrupted during execution' % pn, forcelog=True) 325 bb.fatal('%s - FAILED - tests were interrupted during execution' % pn, forcelog=True)
302 results.logDetails() 326 configuration = _get_testimage_configuration(d, 'runtime', os.getpid(), machine)
327 results.logDetails(_get_testimage_json_result_dir(d),
328 configuration,
329 _get_testimage_result_id(configuration))
303 results.logSummary(pn) 330 results.logSummary(pn)
304 if not results.wasSuccessful(): 331 if not results.wasSuccessful():
305 bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True) 332 bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True)