summaryrefslogtreecommitdiffstats
path: root/scripts/lib/resulttool/resultutils.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/resulttool/resultutils.py')
-rw-r--r--scripts/lib/resulttool/resultutils.py39
1 files changed, 31 insertions, 8 deletions
diff --git a/scripts/lib/resulttool/resultutils.py b/scripts/lib/resulttool/resultutils.py
index 153f2b8e10..ad40ac8499 100644
--- a/scripts/lib/resulttool/resultutils.py
+++ b/scripts/lib/resulttool/resultutils.py
@@ -15,6 +15,7 @@
15import os 15import os
16import json 16import json
17import scriptpath 17import scriptpath
18import copy
18scriptpath.add_oe_lib_path() 19scriptpath.add_oe_lib_path()
19 20
20flatten_map = { 21flatten_map = {
@@ -60,12 +61,6 @@ def append_resultsdata(results, f, configmap=store_map):
60 testpath = "/".join(data[res]["configuration"].get(i) for i in configmap[testtype]) 61 testpath = "/".join(data[res]["configuration"].get(i) for i in configmap[testtype])
61 if testpath not in results: 62 if testpath not in results:
62 results[testpath] = {} 63 results[testpath] = {}
63 if 'ptestresult.rawlogs' in data[res]['result']:
64 del data[res]['result']['ptestresult.rawlogs']
65 if 'ptestresult.sections' in data[res]['result']:
66 for i in data[res]['result']['ptestresult.sections']:
67 if 'log' in data[res]['result']['ptestresult.sections'][i]:
68 del data[res]['result']['ptestresult.sections'][i]['log']
69 results[testpath][res] = data[res] 64 results[testpath][res] = data[res]
70 65
71# 66#
@@ -93,15 +88,43 @@ def filter_resultsdata(results, resultid):
93 newresults[r][i] = results[r][i] 88 newresults[r][i] = results[r][i]
94 return newresults 89 return newresults
95 90
96def save_resultsdata(results, destdir, fn="testresults.json"): 91def strip_ptestresults(results):
92 newresults = copy.deepcopy(results)
93 #for a in newresults2:
94 # newresults = newresults2[a]
95 for res in newresults:
96 if 'result' not in newresults[res]:
97 continue
98 if 'ptestresult.rawlogs' in newresults[res]['result']:
99 del newresults[res]['result']['ptestresult.rawlogs']
100 if 'ptestresult.sections' in newresults[res]['result']:
101 for i in newresults[res]['result']['ptestresult.sections']:
102 if 'log' in newresults[res]['result']['ptestresult.sections'][i]:
103 del newresults[res]['result']['ptestresult.sections'][i]['log']
104 return newresults
105
106def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False):
97 for res in results: 107 for res in results:
98 if res: 108 if res:
99 dst = destdir + "/" + res + "/" + fn 109 dst = destdir + "/" + res + "/" + fn
100 else: 110 else:
101 dst = destdir + "/" + fn 111 dst = destdir + "/" + fn
102 os.makedirs(os.path.dirname(dst), exist_ok=True) 112 os.makedirs(os.path.dirname(dst), exist_ok=True)
113 resultsout = results[res]
114 if not ptestjson:
115 resultsout = strip_ptestresults(results[res])
103 with open(dst, 'w') as f: 116 with open(dst, 'w') as f:
104 f.write(json.dumps(results[res], sort_keys=True, indent=4)) 117 f.write(json.dumps(resultsout, sort_keys=True, indent=4))
118 for res2 in results[res]:
119 if ptestlogs and 'result' in results[res][res2]:
120 if 'ptestresult.rawlogs' in results[res][res2]['result']:
121 with open(dst.replace(fn, "ptest-raw.log"), "w+") as f:
122 f.write(results[res][res2]['result']['ptestresult.rawlogs']['log'])
123 if 'ptestresult.sections' in results[res][res2]['result']:
124 for i in results[res][res2]['result']['ptestresult.sections']:
125 if 'log' in results[res][res2]['result']['ptestresult.sections'][i]:
126 with open(dst.replace(fn, "ptest-%s.log" % i), "w+") as f:
127 f.write(results[res][res2]['result']['ptestresult.sections'][i]['log'])
105 128
106def git_get_result(repo, tags): 129def git_get_result(repo, tags):
107 git_objs = [] 130 git_objs = []