summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorYeoh Ee Peng <ee.peng.yeoh@intel.com>2018-10-23 13:57:20 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-12-16 14:31:27 +0000
commit5a99880992b143313dfa14f85c3898ec74e889b1 (patch)
treec744e84eb15704c50214749b22e2e81a290e55b7 /meta
parent3f2c5e0e24cc767ec023b5c54935a1dfc6306b81 (diff)
downloadpoky-5a99880992b143313dfa14f85c3898ec74e889b1.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: a95218525a4c8228fff9908ffbda85c6b85e101c) 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.py30
1 files changed, 29 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/context.py b/meta/lib/oeqa/selftest/context.py
index 33316d3179..964a46c45a 100644
--- a/meta/lib/oeqa/selftest/context.py
+++ b/meta/lib/oeqa/selftest/context.py
@@ -202,6 +202,31 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
202 self.tc.logger.info("Running bitbake -p") 202 self.tc.logger.info("Running bitbake -p")
203 runCmd("bitbake -p") 203 runCmd("bitbake -p")
204 204
205 def _get_json_result_dir(self, args):
206 json_result_dir = os.path.join(os.path.dirname(os.path.abspath(args.output_log)), 'oeqa')
207 if "OEQA_JSON_RESULT_DIR" in self.tc.td:
208 json_result_dir = self.tc.td["OEQA_JSON_RESULT_DIR"]
209
210 return json_result_dir
211
212 def _get_configuration(self, args):
213 import platform
214 from oeqa.utils.metadata import metadata_from_bb
215 metadata = metadata_from_bb()
216 configuration = {'TEST_TYPE': 'oeselftest',
217 'START_TIME': args.test_start_time,
218 'MACHINE': self.tc.td["MACHINE"],
219 'HOST_DISTRO': ('-'.join(platform.linux_distribution())).replace(' ', '-'),
220 'HOST_NAME': metadata['hostname']}
221 layers = metadata['layers']
222 for l in layers:
223 configuration['%s_BRANCH_REV' % os.path.basename(l)] = '%s:%s' % (metadata['layers'][l]['branch'],
224 metadata['layers'][l]['commit'])
225 return configuration
226
227 def _get_result_id(self, configuration):
228 return '%s_%s_%s' % (configuration['TEST_TYPE'], configuration['HOST_DISTRO'], configuration['MACHINE'])
229
205 def _internal_run(self, logger, args): 230 def _internal_run(self, logger, args):
206 self.module_paths = self._get_cases_paths( 231 self.module_paths = self._get_cases_paths(
207 self.tc_kwargs['init']['td']['BBPATH'].split(':')) 232 self.tc_kwargs['init']['td']['BBPATH'].split(':'))
@@ -218,7 +243,10 @@ class OESelftestTestContextExecutor(OETestContextExecutor):
218 else: 243 else:
219 self._pre_run() 244 self._pre_run()
220 rc = self.tc.runTests(**self.tc_kwargs['run']) 245 rc = self.tc.runTests(**self.tc_kwargs['run'])
221 rc.logDetails() 246 configuration = self._get_configuration(args)
247 rc.logDetails(self._get_json_result_dir(args),
248 configuration,
249 self._get_result_id(configuration))
222 rc.logSummary(self.name) 250 rc.logSummary(self.name)
223 251
224 return rc 252 return rc