diff options
-rw-r--r-- | meta/classes/testimage.bbclass | 31 |
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 | 5 | inherit 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 | ||
145 | def _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 | |||
159 | def _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 | |||
166 | def _get_testimage_result_id(configuration): | ||
167 | return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['MACHINE']) | ||
168 | |||
145 | def testimage_main(d): | 169 | def 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) |