diff options
Diffstat (limited to 'meta/classes')
-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 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 | 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 |
@@ -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 | ||
135 | def _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 | |||
149 | def _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 | |||
156 | def _get_testimage_result_id(configuration): | ||
157 | return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['IMAGE_BASENAME'], configuration['MACHINE']) | ||
158 | |||
135 | def testimage_main(d): | 159 | def 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) |