1
0
mirror of https://git.yoctoproject.org/poky synced 2026-07-17 04:07:06 +00:00

oeqa/core/case.py: Add OEPTestResultTestCase for ptestresult helpers

Add the OEPTestResultTestCase class as a mix-in class to provide helper
functions for interacting with ptestresults within the extraresults
object generated by the test case.

This class also provides default compression of log text and log files.

Also add support to resulttool for decoding/decompressing log files
embedded in the test results.

(From OE-Core rev: 06cba9883a5964320969301fd05eeb6bec3e786d)

Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Nathan Rossi
2019-09-11 14:13:07 +00:00
committed by Richard Purdie
parent 0c19c09335
commit e08f657220
3 changed files with 108 additions and 27 deletions
+39 -6
View File
@@ -7,6 +7,8 @@
#
import os
import base64
import zlib
import json
import scriptpath
import copy
@@ -117,6 +119,34 @@ def strip_ptestresults(results):
del newresults[res]['result']['ptestresult.sections'][i]['log']
return newresults
def decode_log(logdata):
if isinstance(logdata, str):
return logdata
elif isinstance(logdata, dict):
if "compressed" in logdata:
data = logdata.get("compressed")
data = base64.b64decode(data.encode("utf-8"))
return zlib.decompress(data).decode("utf-8")
return None
def ptestresult_get_log(results, section):
if 'ptestresult.sections' not in results:
return None
if section not in results['ptestresult.sections']:
return None
ptest = results['ptestresult.sections'][section]
if 'log' not in ptest:
return None
return decode_log(ptest['log'])
def ptestresult_get_rawlogs(results):
if 'ptestresult.rawlogs' not in results:
return None
if 'log' not in results['ptestresult.rawlogs']:
return None
return decode_log(results['ptestresult.rawlogs']['log'])
def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False):
for res in results:
if res:
@@ -131,14 +161,17 @@ def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, p
f.write(json.dumps(resultsout, sort_keys=True, indent=4))
for res2 in results[res]:
if ptestlogs and 'result' in results[res][res2]:
if 'ptestresult.rawlogs' in results[res][res2]['result']:
seriesresults = results[res][res2]['result']
rawlogs = ptestresult_get_rawlogs(seriesresults)
if rawlogs is not None:
with open(dst.replace(fn, "ptest-raw.log"), "w+") as f:
f.write(results[res][res2]['result']['ptestresult.rawlogs']['log'])
if 'ptestresult.sections' in results[res][res2]['result']:
for i in results[res][res2]['result']['ptestresult.sections']:
if 'log' in results[res][res2]['result']['ptestresult.sections'][i]:
f.write(rawlogs)
if 'ptestresult.sections' in seriesresults:
for i in seriesresults['ptestresult.sections']:
sectionlog = ptestresult_get_log(seriesresults, i)
if sectionlog is not None:
with open(dst.replace(fn, "ptest-%s.log" % i), "w+") as f:
f.write(results[res][res2]['result']['ptestresult.sections'][i]['log'])
f.write(sectionlog)
def git_get_result(repo, tags):
git_objs = []