diff options
Diffstat (limited to 'scripts/lib/resulttool/resultutils.py')
| -rw-r--r-- | scripts/lib/resulttool/resultutils.py | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/scripts/lib/resulttool/resultutils.py b/scripts/lib/resulttool/resultutils.py index e595c185df..177fb25f93 100644 --- a/scripts/lib/resulttool/resultutils.py +++ b/scripts/lib/resulttool/resultutils.py | |||
| @@ -7,6 +7,8 @@ | |||
| 7 | # | 7 | # |
| 8 | 8 | ||
| 9 | import os | 9 | import os |
| 10 | import base64 | ||
| 11 | import zlib | ||
| 10 | import json | 12 | import json |
| 11 | import scriptpath | 13 | import scriptpath |
| 12 | import copy | 14 | import copy |
| @@ -117,6 +119,34 @@ def strip_ptestresults(results): | |||
| 117 | del newresults[res]['result']['ptestresult.sections'][i]['log'] | 119 | del newresults[res]['result']['ptestresult.sections'][i]['log'] |
| 118 | return newresults | 120 | return newresults |
| 119 | 121 | ||
| 122 | def decode_log(logdata): | ||
| 123 | if isinstance(logdata, str): | ||
| 124 | return logdata | ||
| 125 | elif isinstance(logdata, dict): | ||
| 126 | if "compressed" in logdata: | ||
| 127 | data = logdata.get("compressed") | ||
| 128 | data = base64.b64decode(data.encode("utf-8")) | ||
| 129 | return zlib.decompress(data).decode("utf-8") | ||
| 130 | return None | ||
| 131 | |||
| 132 | def ptestresult_get_log(results, section): | ||
| 133 | if 'ptestresult.sections' not in results: | ||
| 134 | return None | ||
| 135 | if section not in results['ptestresult.sections']: | ||
| 136 | return None | ||
| 137 | |||
| 138 | ptest = results['ptestresult.sections'][section] | ||
| 139 | if 'log' not in ptest: | ||
| 140 | return None | ||
| 141 | return decode_log(ptest['log']) | ||
| 142 | |||
| 143 | def ptestresult_get_rawlogs(results): | ||
| 144 | if 'ptestresult.rawlogs' not in results: | ||
| 145 | return None | ||
| 146 | if 'log' not in results['ptestresult.rawlogs']: | ||
| 147 | return None | ||
| 148 | return decode_log(results['ptestresult.rawlogs']['log']) | ||
| 149 | |||
| 120 | def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False): | 150 | def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False): |
| 121 | for res in results: | 151 | for res in results: |
| 122 | if res: | 152 | if res: |
| @@ -131,14 +161,17 @@ def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, p | |||
| 131 | f.write(json.dumps(resultsout, sort_keys=True, indent=4)) | 161 | f.write(json.dumps(resultsout, sort_keys=True, indent=4)) |
| 132 | for res2 in results[res]: | 162 | for res2 in results[res]: |
| 133 | if ptestlogs and 'result' in results[res][res2]: | 163 | if ptestlogs and 'result' in results[res][res2]: |
| 134 | if 'ptestresult.rawlogs' in results[res][res2]['result']: | 164 | seriesresults = results[res][res2]['result'] |
| 165 | rawlogs = ptestresult_get_rawlogs(seriesresults) | ||
| 166 | if rawlogs is not None: | ||
| 135 | with open(dst.replace(fn, "ptest-raw.log"), "w+") as f: | 167 | with open(dst.replace(fn, "ptest-raw.log"), "w+") as f: |
| 136 | f.write(results[res][res2]['result']['ptestresult.rawlogs']['log']) | 168 | f.write(rawlogs) |
| 137 | if 'ptestresult.sections' in results[res][res2]['result']: | 169 | if 'ptestresult.sections' in seriesresults: |
| 138 | for i in results[res][res2]['result']['ptestresult.sections']: | 170 | for i in seriesresults['ptestresult.sections']: |
| 139 | if 'log' in results[res][res2]['result']['ptestresult.sections'][i]: | 171 | sectionlog = ptestresult_get_log(seriesresults, i) |
| 172 | if sectionlog is not None: | ||
| 140 | with open(dst.replace(fn, "ptest-%s.log" % i), "w+") as f: | 173 | with open(dst.replace(fn, "ptest-%s.log" % i), "w+") as f: |
| 141 | f.write(results[res][res2]['result']['ptestresult.sections'][i]['log']) | 174 | f.write(sectionlog) |
| 142 | 175 | ||
| 143 | def git_get_result(repo, tags): | 176 | def git_get_result(repo, tags): |
| 144 | git_objs = [] | 177 | git_objs = [] |
