diff options
Diffstat (limited to 'scripts/lib')
| -rw-r--r-- | scripts/lib/resulttool/resultutils.py | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/scripts/lib/resulttool/resultutils.py b/scripts/lib/resulttool/resultutils.py index 8fd4e0a9cf..b9b93afaa6 100644 --- a/scripts/lib/resulttool/resultutils.py +++ b/scripts/lib/resulttool/resultutils.py | |||
| @@ -14,8 +14,11 @@ import scriptpath | |||
| 14 | import copy | 14 | import copy |
| 15 | import urllib.request | 15 | import urllib.request |
| 16 | import posixpath | 16 | import posixpath |
| 17 | import logging | ||
| 17 | scriptpath.add_oe_lib_path() | 18 | scriptpath.add_oe_lib_path() |
| 18 | 19 | ||
| 20 | logger = logging.getLogger('resulttool') | ||
| 21 | |||
| 19 | flatten_map = { | 22 | flatten_map = { |
| 20 | "oeselftest": [], | 23 | "oeselftest": [], |
| 21 | "runtime": [], | 24 | "runtime": [], |
| @@ -38,6 +41,12 @@ store_map = { | |||
| 38 | "manual": ['TEST_TYPE', 'TEST_MODULE', 'MACHINE', 'IMAGE_BASENAME'] | 41 | "manual": ['TEST_TYPE', 'TEST_MODULE', 'MACHINE', 'IMAGE_BASENAME'] |
| 39 | } | 42 | } |
| 40 | 43 | ||
| 44 | rawlog_sections = { | ||
| 45 | "ptestresult.rawlogs": "ptest", | ||
| 46 | "ltpresult.rawlogs": "ltp", | ||
| 47 | "ltpposixresult.rawlogs": "ltpposix" | ||
| 48 | } | ||
| 49 | |||
| 41 | def is_url(p): | 50 | def is_url(p): |
| 42 | """ | 51 | """ |
| 43 | Helper for determining if the given path is a URL | 52 | Helper for determining if the given path is a URL |
| @@ -108,15 +117,14 @@ def filter_resultsdata(results, resultid): | |||
| 108 | newresults[r][i] = results[r][i] | 117 | newresults[r][i] = results[r][i] |
| 109 | return newresults | 118 | return newresults |
| 110 | 119 | ||
| 111 | def strip_ptestresults(results): | 120 | def strip_logs(results): |
| 112 | newresults = copy.deepcopy(results) | 121 | newresults = copy.deepcopy(results) |
| 113 | #for a in newresults2: | ||
| 114 | # newresults = newresults2[a] | ||
| 115 | for res in newresults: | 122 | for res in newresults: |
| 116 | if 'result' not in newresults[res]: | 123 | if 'result' not in newresults[res]: |
| 117 | continue | 124 | continue |
| 118 | if 'ptestresult.rawlogs' in newresults[res]['result']: | 125 | for logtype in rawlog_sections: |
| 119 | del newresults[res]['result']['ptestresult.rawlogs'] | 126 | if logtype in newresults[res]['result']: |
| 127 | del newresults[res]['result'][logtype] | ||
| 120 | if 'ptestresult.sections' in newresults[res]['result']: | 128 | if 'ptestresult.sections' in newresults[res]['result']: |
| 121 | for i in newresults[res]['result']['ptestresult.sections']: | 129 | for i in newresults[res]['result']['ptestresult.sections']: |
| 122 | if 'log' in newresults[res]['result']['ptestresult.sections'][i]: | 130 | if 'log' in newresults[res]['result']['ptestresult.sections'][i]: |
| @@ -155,9 +163,6 @@ def generic_get_rawlogs(sectname, results): | |||
| 155 | return None | 163 | return None |
| 156 | return decode_log(results[sectname]['log']) | 164 | return decode_log(results[sectname]['log']) |
| 157 | 165 | ||
| 158 | def ptestresult_get_rawlogs(results): | ||
| 159 | return generic_get_rawlogs('ptestresult.rawlogs', results) | ||
| 160 | |||
| 161 | def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False): | 166 | def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False): |
| 162 | for res in results: | 167 | for res in results: |
| 163 | if res: | 168 | if res: |
| @@ -167,16 +172,18 @@ def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, p | |||
| 167 | os.makedirs(os.path.dirname(dst), exist_ok=True) | 172 | os.makedirs(os.path.dirname(dst), exist_ok=True) |
| 168 | resultsout = results[res] | 173 | resultsout = results[res] |
| 169 | if not ptestjson: | 174 | if not ptestjson: |
| 170 | resultsout = strip_ptestresults(results[res]) | 175 | resultsout = strip_logs(results[res]) |
| 171 | with open(dst, 'w') as f: | 176 | with open(dst, 'w') as f: |
| 172 | f.write(json.dumps(resultsout, sort_keys=True, indent=1)) | 177 | f.write(json.dumps(resultsout, sort_keys=True, indent=1)) |
| 173 | for res2 in results[res]: | 178 | for res2 in results[res]: |
| 174 | if ptestlogs and 'result' in results[res][res2]: | 179 | if ptestlogs and 'result' in results[res][res2]: |
| 175 | seriesresults = results[res][res2]['result'] | 180 | seriesresults = results[res][res2]['result'] |
| 176 | rawlogs = ptestresult_get_rawlogs(seriesresults) | 181 | for logtype in rawlog_sections: |
| 177 | if rawlogs is not None: | 182 | logdata = generic_get_rawlogs(logtype, seriesresults) |
| 178 | with open(dst.replace(fn, "ptest-raw.log"), "w+") as f: | 183 | if logdata is not None: |
| 179 | f.write(rawlogs) | 184 | logger.info("Extracting " + rawlog_sections[logtype] + "-raw.log") |
| 185 | with open(dst.replace(fn, rawlog_sections[logtype] + "-raw.log"), "w+") as f: | ||
| 186 | f.write(logdata) | ||
| 180 | if 'ptestresult.sections' in seriesresults: | 187 | if 'ptestresult.sections' in seriesresults: |
| 181 | for i in seriesresults['ptestresult.sections']: | 188 | for i in seriesresults['ptestresult.sections']: |
| 182 | sectionlog = ptestresult_get_log(seriesresults, i) | 189 | sectionlog = ptestresult_get_log(seriesresults, i) |
