summaryrefslogtreecommitdiffstats
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-25 15:01:21 +0100
commit7999c7d556a58de7712fb0e37fd24e42dda914b8 (patch)
tree88bda2934ee0a3c965822e59e5570c6d17b3b1a8
parent59fe0384335ec615fa190affd758eb8c4446bfdc (diff)
downloadpoky-7999c7d556a58de7712fb0e37fd24e42dda914b8.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: 08c5471c5abd95616af8df862e96072d022a6f42) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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