diff options
Diffstat (limited to 'scripts/lib/resulttool')
-rw-r--r-- | scripts/lib/resulttool/resultutils.py | 39 | ||||
-rw-r--r-- | scripts/lib/resulttool/store.py | 2 |
2 files changed, 32 insertions, 9 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 @@ | |||
15 | import os | 15 | import os |
16 | import json | 16 | import json |
17 | import scriptpath | 17 | import scriptpath |
18 | import copy | ||
18 | scriptpath.add_oe_lib_path() | 19 | scriptpath.add_oe_lib_path() |
19 | 20 | ||
20 | flatten_map = { | 21 | flatten_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 | ||
96 | def save_resultsdata(results, destdir, fn="testresults.json"): | 91 | def 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 | |||
106 | def 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 | ||
106 | def git_get_result(repo, tags): | 129 | def git_get_result(repo, tags): |
107 | git_objs = [] | 130 | git_objs = [] |
diff --git a/scripts/lib/resulttool/store.py b/scripts/lib/resulttool/store.py index 3a81933242..e4a0807528 100644 --- a/scripts/lib/resulttool/store.py +++ b/scripts/lib/resulttool/store.py | |||
@@ -68,7 +68,7 @@ def store(args, logger): | |||
68 | results = revisions[r] | 68 | results = revisions[r] |
69 | keywords = {'commit': r[0], 'branch': r[1], "commit_count": r[2]} | 69 | keywords = {'commit': r[0], 'branch': r[1], "commit_count": r[2]} |
70 | subprocess.check_call(["find", tempdir, "!", "-path", "./.git/*", "-delete"]) | 70 | subprocess.check_call(["find", tempdir, "!", "-path", "./.git/*", "-delete"]) |
71 | resultutils.save_resultsdata(results, tempdir) | 71 | resultutils.save_resultsdata(results, tempdir, ptestlogs=True) |
72 | 72 | ||
73 | logger.info('Storing test result into git repository %s' % args.git_dir) | 73 | logger.info('Storing test result into git repository %s' % args.git_dir) |
74 | 74 | ||