mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
oeqa/core/runner: dump stdout and stderr of each test case
Some CI pipelines might perform further processing of the test output (for instance, to plot some metrics into a chart). However, Since `thud` we switched away from the XML-based jUnit reporting, and at the same time we lost the ability of collecting the stdout and stderr of the various tests. We now restore this functionality by adding `stdout` and `stderr` keys to the JSON reports. This behavior is off by default; in order to enable it, one must set the `TESTREPORT_FULLLOGS` variable in the bitbake configuration. (From OE-Core rev: fd0048630ece5b21efb3a79e97046be0ab2a1514) Signed-off-by: Alberto Mardegan <amardegan@luxoft.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
9d997dff7b
commit
e03d103e10
@@ -316,7 +316,8 @@ def testimage_main(d):
|
|||||||
configuration = get_testimage_configuration(d, 'runtime', machine)
|
configuration = get_testimage_configuration(d, 'runtime', machine)
|
||||||
results.logDetails(get_testimage_json_result_dir(d),
|
results.logDetails(get_testimage_json_result_dir(d),
|
||||||
configuration,
|
configuration,
|
||||||
get_testimage_result_id(configuration))
|
get_testimage_result_id(configuration),
|
||||||
|
dump_streams=d.getVar('TESTREPORT_FULLLOGS'))
|
||||||
results.logSummary(pn)
|
results.logSummary(pn)
|
||||||
if not results.wasSuccessful():
|
if not results.wasSuccessful():
|
||||||
bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True)
|
bb.fatal('%s - FAILED - check the task log and the ssh log' % pn, forcelog=True)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import unittest
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
from unittest import TextTestResult as _TestResult
|
from unittest import TextTestResult as _TestResult
|
||||||
from unittest import TextTestRunner as _TestRunner
|
from unittest import TextTestRunner as _TestRunner
|
||||||
@@ -45,6 +46,9 @@ class OETestResult(_TestResult):
|
|||||||
|
|
||||||
self.tc = tc
|
self.tc = tc
|
||||||
|
|
||||||
|
# stdout and stderr for each test case
|
||||||
|
self.logged_output = {}
|
||||||
|
|
||||||
def startTest(self, test):
|
def startTest(self, test):
|
||||||
# May have been set by concurrencytest
|
# May have been set by concurrencytest
|
||||||
if test.id() not in self.starttime:
|
if test.id() not in self.starttime:
|
||||||
@@ -53,6 +57,9 @@ class OETestResult(_TestResult):
|
|||||||
|
|
||||||
def stopTest(self, test):
|
def stopTest(self, test):
|
||||||
self.endtime[test.id()] = time.time()
|
self.endtime[test.id()] = time.time()
|
||||||
|
if self.buffer:
|
||||||
|
self.logged_output[test.id()] = (
|
||||||
|
sys.stdout.getvalue(), sys.stderr.getvalue())
|
||||||
super(OETestResult, self).stopTest(test)
|
super(OETestResult, self).stopTest(test)
|
||||||
if test.id() in self.progressinfo:
|
if test.id() in self.progressinfo:
|
||||||
self.tc.logger.info(self.progressinfo[test.id()])
|
self.tc.logger.info(self.progressinfo[test.id()])
|
||||||
@@ -118,7 +125,8 @@ class OETestResult(_TestResult):
|
|||||||
self.successes.append((test, None))
|
self.successes.append((test, None))
|
||||||
super(OETestResult, self).addSuccess(test)
|
super(OETestResult, self).addSuccess(test)
|
||||||
|
|
||||||
def logDetails(self, json_file_dir=None, configuration=None, result_id=None):
|
def logDetails(self, json_file_dir=None, configuration=None, result_id=None,
|
||||||
|
dump_streams=False):
|
||||||
self.tc.logger.info("RESULTS:")
|
self.tc.logger.info("RESULTS:")
|
||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
@@ -144,10 +152,14 @@ class OETestResult(_TestResult):
|
|||||||
if status not in logs:
|
if status not in logs:
|
||||||
logs[status] = []
|
logs[status] = []
|
||||||
logs[status].append("RESULTS - %s - Testcase %s: %s%s" % (case.id(), oeid, status, t))
|
logs[status].append("RESULTS - %s - Testcase %s: %s%s" % (case.id(), oeid, status, t))
|
||||||
|
report = {'status': status}
|
||||||
if log:
|
if log:
|
||||||
result[case.id()] = {'status': status, 'log': log}
|
report['log'] = log
|
||||||
else:
|
if dump_streams and case.id() in self.logged_output:
|
||||||
result[case.id()] = {'status': status}
|
(stdout, stderr) = self.logged_output[case.id()]
|
||||||
|
report['stdout'] = stdout
|
||||||
|
report['stderr'] = stderr
|
||||||
|
result[case.id()] = report
|
||||||
|
|
||||||
for i in ['PASSED', 'SKIPPED', 'EXPECTEDFAIL', 'ERROR', 'FAILED', 'UNKNOWN']:
|
for i in ['PASSED', 'SKIPPED', 'EXPECTEDFAIL', 'ERROR', 'FAILED', 'UNKNOWN']:
|
||||||
if i not in logs:
|
if i not in logs:
|
||||||
|
|||||||
Reference in New Issue
Block a user