summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/resulttool/log.py21
-rw-r--r--scripts/lib/resulttool/resultutils.py22
2 files changed, 28 insertions, 15 deletions
diff --git a/scripts/lib/resulttool/log.py b/scripts/lib/resulttool/log.py
index f1bfd99500..eb3927ec82 100644
--- a/scripts/lib/resulttool/log.py
+++ b/scripts/lib/resulttool/log.py
@@ -34,13 +34,17 @@ def log(args, logger):
34 return 1 34 return 1
35 35
36 for _, run_name, _, r in resultutils.test_run_results(results): 36 for _, run_name, _, r in resultutils.test_run_results(results):
37 if args.dump_ptest and 'ptestresult.sections' in r: 37 if args.dump_ptest:
38 for name, ptest in r['ptestresult.sections'].items(): 38 for sectname in ['ptestresult.sections', 'ltpposixresult.sections', 'ltpresult.sections']:
39 logdata = resultutils.ptestresult_get_log(r, name) 39 if sectname in r:
40 for name, ptest in r[sectname].items():
41 logdata = resultutils.generic_get_log(sectname, r, name)
40 if logdata is not None: 42 if logdata is not None:
41 dest_dir = args.dump_ptest 43 dest_dir = args.dump_ptest
42 if args.prepend_run: 44 if args.prepend_run:
43 dest_dir = os.path.join(dest_dir, run_name) 45 dest_dir = os.path.join(dest_dir, run_name)
46 if not sectname.startswith("ptest"):
47 dest_dir = os.path.join(dest_dir, sectname.split(".")[0])
44 48
45 os.makedirs(dest_dir, exist_ok=True) 49 os.makedirs(dest_dir, exist_ok=True)
46 dest = os.path.join(dest_dir, '%s.log' % name) 50 dest = os.path.join(dest_dir, '%s.log' % name)
@@ -49,10 +53,13 @@ def log(args, logger):
49 f.write(logdata) 53 f.write(logdata)
50 54
51 if args.raw_ptest: 55 if args.raw_ptest:
52 rawlog = resultutils.ptestresult_get_rawlogs(r) 56 found = False
53 if rawlog is not None: 57 for sectname in ['ptestresult.rawlogs', 'ltpposixresult.rawlogs', 'ltpresult.rawlogs']:
54 print(rawlog) 58 rawlog = resultutils.generic_get_rawlogs(sectname, r)
55 else: 59 if rawlog is not None:
60 print(rawlog)
61 found = True
62 if not found:
56 print('Raw ptest logs not found') 63 print('Raw ptest logs not found')
57 return 1 64 return 1
58 65
diff --git a/scripts/lib/resulttool/resultutils.py b/scripts/lib/resulttool/resultutils.py
index 5fec01f6f3..8917022d36 100644
--- a/scripts/lib/resulttool/resultutils.py
+++ b/scripts/lib/resulttool/resultutils.py
@@ -130,23 +130,29 @@ def decode_log(logdata):
130 return data.decode("utf-8", errors='ignore') 130 return data.decode("utf-8", errors='ignore')
131 return None 131 return None
132 132
133def ptestresult_get_log(results, section): 133def generic_get_log(sectionname, results, section):
134 if 'ptestresult.sections' not in results: 134 if sectionname not in results:
135 return None 135 return None
136 if section not in results['ptestresult.sections']: 136 if section not in results[sectionname]:
137 return None 137 return None
138 138
139 ptest = results['ptestresult.sections'][section] 139 ptest = results[sectionname][section]
140 if 'log' not in ptest: 140 if 'log' not in ptest:
141 return None 141 return None
142 return decode_log(ptest['log']) 142 return decode_log(ptest['log'])
143 143
144def ptestresult_get_rawlogs(results): 144def ptestresult_get_log(results, section):
145 if 'ptestresult.rawlogs' not in results: 145 return generic_get_log('ptestresuls.sections', results, section)
146
147def generic_get_rawlogs(sectname, results):
148 if sectname not in results:
146 return None 149 return None
147 if 'log' not in results['ptestresult.rawlogs']: 150 if 'log' not in results[sectname]:
148 return None 151 return None
149 return decode_log(results['ptestresult.rawlogs']['log']) 152 return decode_log(results[sectname]['log'])
153
154def ptestresult_get_rawlogs(results):
155 return generic_get_rawlogs('ptestresult.rawlogs', results)
150 156
151def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False): 157def save_resultsdata(results, destdir, fn="testresults.json", ptestjson=False, ptestlogs=False):
152 for res in results: 158 for res in results: