diff options
author | Yeoh Ee Peng <ee.peng.yeoh@intel.com> | 2018-10-23 13:57:20 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-10-29 17:26:47 +0000 |
commit | d89e06083eeea1bebdaa64f809e7e0a328e282f5 (patch) | |
tree | 77c6684f6f5cbe01e59a9eeb6ca91f360d0cc76f /meta | |
parent | 4ef72d556f706e301e5155f5f228c38431acafe6 (diff) | |
download | poky-d89e06083eeea1bebdaa64f809e7e0a328e282f5.tar.gz |
oeqa/selftest/context: write testresult to json files
As part of the solution to replace Testopia to store testresult,
OEQA selftest 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 oe-selftest log 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: 10697165c832e3dbb2913b6215164ea75e23ec23)
Signed-off-by: Yeoh Ee Peng <ee.peng.yeoh@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/selftest/context.py | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py index c78947e200..ee83a9142e 100644 --- a/meta/lib/oeqa/selftest/context.py +++ b/meta/lib/oeqa/selftest/context.py | |||
@@ -99,8 +99,8 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
99 | return cases_paths | 99 | return cases_paths |
100 | 100 | ||
101 | def _process_args(self, logger, args): | 101 | def _process_args(self, logger, args): |
102 | args.output_log = '%s-results-%s.log' % (self.name, | 102 | args.test_start_time = time.strftime("%Y%m%d%H%M%S") |
103 | time.strftime("%Y%m%d%H%M%S")) | 103 | args.output_log = '%s-results-%s.log' % (self.name, args.test_start_time) |
104 | args.test_data_file = None | 104 | args.test_data_file = None |
105 | args.CASES_PATHS = None | 105 | args.CASES_PATHS = None |
106 | 106 | ||
@@ -204,6 +204,31 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
204 | self.tc.logger.info("Running bitbake -e to test the configuration is valid/parsable") | 204 | self.tc.logger.info("Running bitbake -e to test the configuration is valid/parsable") |
205 | runCmd("bitbake -e") | 205 | runCmd("bitbake -e") |
206 | 206 | ||
207 | def _get_json_result_dir(self, args): | ||
208 | json_result_dir = os.path.join(os.path.dirname(os.path.abspath(args.output_log)), 'oeqa') | ||
209 | if "OEQA_JSON_RESULT_DIR" in self.tc.td: | ||
210 | json_result_dir = self.tc.td["OEQA_JSON_RESULT_DIR"] | ||
211 | |||
212 | return json_result_dir | ||
213 | |||
214 | def _get_configuration(self, args): | ||
215 | import platform | ||
216 | from oeqa.utils.metadata import metadata_from_bb | ||
217 | metadata = metadata_from_bb() | ||
218 | configuration = {'TEST_TYPE': 'oeselftest', | ||
219 | 'START_TIME': args.test_start_time, | ||
220 | 'MACHINE': self.tc.td["MACHINE"], | ||
221 | 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-'), | ||
222 | 'HOST_NAME': metadata['hostname']} | ||
223 | layers = metadata['layers'] | ||
224 | for l in layers: | ||
225 | configuration['%s_BRANCH_REV' % os.path.basename(l)] = '%s:%s' % (metadata['layers'][l]['branch'], | ||
226 | metadata['layers'][l]['commit']) | ||
227 | return configuration | ||
228 | |||
229 | def _get_result_id(self, configuration): | ||
230 | return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['HOST_DISTRO'], configuration['MACHINE']) | ||
231 | |||
207 | def _internal_run(self, logger, args): | 232 | def _internal_run(self, logger, args): |
208 | self.module_paths = self._get_cases_paths( | 233 | self.module_paths = self._get_cases_paths( |
209 | self.tc_kwargs['init']['td']['BBPATH'].split(':')) | 234 | self.tc_kwargs['init']['td']['BBPATH'].split(':')) |
@@ -220,7 +245,10 @@ class OESelftestTestContextExecutor(OETestContextExecutor): | |||
220 | else: | 245 | else: |
221 | self._pre_run() | 246 | self._pre_run() |
222 | rc = self.tc.runTests(**self.tc_kwargs['run']) | 247 | rc = self.tc.runTests(**self.tc_kwargs['run']) |
223 | rc.logDetails() | 248 | configuration = self._get_configuration(args) |
249 | rc.logDetails(self._get_json_result_dir(args), | ||
250 | configuration, | ||
251 | self._get_result_id(configuration)) | ||
224 | rc.logSummary(self.name) | 252 | rc.logSummary(self.name) |
225 | 253 | ||
226 | return rc | 254 | return rc |