summaryrefslogtreecommitdiffstats
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-10-29 17:26:47 +0000
commite73bcdd0590fbc82da515b37e5cf32726f231cf9 (patch)
tree71076d6fdf55872fffee4a6e31d6f352621d2926
parent1418c0ea24acc3d8d3a26b7a1cf21db06ac22491 (diff)
downloadpoky-e73bcdd0590fbc82da515b37e5cf32726f231cf9.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: 5d135d4769b6bb60d575eb6ed196367f9e077cc4) Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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 2d6976f9f9..4057f497c4 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
@@ -142,6 +142,30 @@ def testimage_sanity(d):
142 bb.fatal('When TEST_TARGET is set to "simpleremote" ' 142 bb.fatal('When TEST_TARGET is set to "simpleremote" '
143 'TEST_TARGET_IP and TEST_SERVER_IP are needed too.') 143 'TEST_TARGET_IP and TEST_SERVER_IP are needed too.')
144 144
145def _get_testimage_configuration(d, test_type, pid, machine):
146 import platform
147 configuration = {'TEST_TYPE': test_type,
148 'PROCESS_ID': pid,
149 'MACHINE': machine,
150 'IMAGE_BASENAME': d.getVar("IMAGE_BASENAME"),
151 'IMAGE_PKGTYPE': d.getVar("IMAGE_PKGTYPE"),
152 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-')}
153 layers = (d.getVar("BBLAYERS") or "").split()
154 for l in layers:
155 configuration['%s_BRANCH_REV' % os.path.basename(l)] = '%s:%s' % (base_get_metadata_git_branch(l, None).strip(),
156 base_get_metadata_git_revision(l, None))
157 return configuration
158
159def _get_testimage_json_result_dir(d):
160 json_result_dir = os.path.join(d.getVar("WORKDIR"), 'oeqa')
161 custom_json_result_dir = d.getVar("OEQA_JSON_RESULT_DIR")
162 if custom_json_result_dir:
163 json_result_dir = custom_json_result_dir
164 return json_result_dir
165
166def _get_testimage_result_id(configuration):
167 return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['MACHINE'])
168
145def testimage_main(d): 169def testimage_main(d):
146 import os 170 import os
147 import json 171 import json
@@ -309,7 +333,10 @@ def testimage_main(d):
309 # Show results (if we have them) 333 # Show results (if we have them)
310 if not results: 334 if not results:
311 bb.fatal('%s - FAILED - tests were interrupted during execution' % pn, forcelog=True) 335 bb.fatal('%s - FAILED - tests were interrupted during execution' % pn, forcelog=True)
312 results.logDetails() 336 configuration = _get_testimage_configuration(d, 'runtime', os.getpid(), machine)
337 results.logDetails(_get_testimage_json_result_dir(d),
338 configuration,
339 _get_testimage_result_id(configuration))
313 results.logSummary(pn) 340 results.logSummary(pn)
314 if not results.wasSuccessful(): 341 if not results.wasSuccessful():
315 bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True) 342 bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True)