summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-03-02 16:34:16 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-04-04 22:57:32 +0100
commit00faa62c4c4a02f6718b36e2fcaf3e1fad5dd0b9 (patch)
treed9472769fb752aac1ff6c16e55430a63aefde09f /scripts
parent803d404bdf69cfcd8ab418a0e3e8709ed0f66911 (diff)
downloadpoky-00faa62c4c4a02f6718b36e2fcaf3e1fad5dd0b9.tar.gz
resulttool: Allow extraction of ptest data
Rather than simply discarding the ptest data, change the code to discard it when writing out the new testresult files, or optionally either preserve it, or write it as seperate discrete logs. This means the autobuilder should start writing out individual ptest log files as well as allowing ueers to extract these manually. (From OE-Core rev: a1e0944bf260ef50dd7dfcb10db248fdd7f45bc9) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/resulttool/resultutils.py39
-rw-r--r--scripts/lib/resulttool/store.py2
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 @@
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 = []
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