diff options
author | Nathan Rossi <nathan@nathanrossi.com> | 2019-09-11 14:13:07 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-09-16 23:02:43 +0100 |
commit | e08f657220fa119793949e26b2837026956d4238 (patch) | |
tree | ddc35ec5e3468daeec7446a8d8f1b2307785b325 /scripts/lib/resulttool/log.py | |
parent | 0c19c093358fa65d93c86cc8978fa50b5bd97026 (diff) | |
download | poky-e08f657220fa119793949e26b2837026956d4238.tar.gz |
oeqa/core/case.py: Add OEPTestResultTestCase for ptestresult helpers
Add the OEPTestResultTestCase class as a mix-in class to provide helper
functions for interacting with ptestresults within the extraresults
object generated by the test case.
This class also provides default compression of log text and log files.
Also add support to resulttool for decoding/decompressing log files
embedded in the test results.
(From OE-Core rev: 06cba9883a5964320969301fd05eeb6bec3e786d)
Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/resulttool/log.py')
-rw-r--r-- | scripts/lib/resulttool/log.py | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/scripts/lib/resulttool/log.py b/scripts/lib/resulttool/log.py index 2352c767d9..f1bfd99500 100644 --- a/scripts/lib/resulttool/log.py +++ b/scripts/lib/resulttool/log.py | |||
@@ -8,12 +8,12 @@ import os | |||
8 | import resulttool.resultutils as resultutils | 8 | import resulttool.resultutils as resultutils |
9 | 9 | ||
10 | def show_ptest(result, ptest, logger): | 10 | def show_ptest(result, ptest, logger): |
11 | if 'ptestresult.sections' in result: | 11 | logdata = resultutils.ptestresult_get_log(result, ptest) |
12 | if ptest in result['ptestresult.sections'] and 'log' in result['ptestresult.sections'][ptest]: | 12 | if logdata is not None: |
13 | print(result['ptestresult.sections'][ptest]['log']) | 13 | print(logdata) |
14 | return 0 | 14 | return 0 |
15 | 15 | ||
16 | print("ptest '%s' not found" % ptest) | 16 | print("ptest '%s' log not found" % ptest) |
17 | return 1 | 17 | return 1 |
18 | 18 | ||
19 | def show_reproducible(result, reproducible, logger): | 19 | def show_reproducible(result, reproducible, logger): |
@@ -25,7 +25,6 @@ def show_reproducible(result, reproducible, logger): | |||
25 | print("reproducible '%s' not found" % reproducible) | 25 | print("reproducible '%s' not found" % reproducible) |
26 | return 1 | 26 | return 1 |
27 | 27 | ||
28 | |||
29 | def log(args, logger): | 28 | def log(args, logger): |
30 | results = resultutils.load_resultsdata(args.source) | 29 | results = resultutils.load_resultsdata(args.source) |
31 | 30 | ||
@@ -35,24 +34,24 @@ def log(args, logger): | |||
35 | return 1 | 34 | return 1 |
36 | 35 | ||
37 | for _, run_name, _, r in resultutils.test_run_results(results): | 36 | for _, run_name, _, r in resultutils.test_run_results(results): |
38 | if args.dump_ptest: | 37 | if args.dump_ptest and 'ptestresult.sections' in r: |
39 | if 'ptestresult.sections' in r: | 38 | for name, ptest in r['ptestresult.sections'].items(): |
40 | for name, ptest in r['ptestresult.sections'].items(): | 39 | logdata = resultutils.ptestresult_get_log(r, name) |
41 | if 'log' in ptest: | 40 | if logdata is not None: |
42 | dest_dir = args.dump_ptest | 41 | dest_dir = args.dump_ptest |
43 | if args.prepend_run: | 42 | if args.prepend_run: |
44 | dest_dir = os.path.join(dest_dir, run_name) | 43 | dest_dir = os.path.join(dest_dir, run_name) |
45 | 44 | ||
46 | os.makedirs(dest_dir, exist_ok=True) | 45 | os.makedirs(dest_dir, exist_ok=True) |
47 | 46 | dest = os.path.join(dest_dir, '%s.log' % name) | |
48 | dest = os.path.join(dest_dir, '%s.log' % name) | 47 | print(dest) |
49 | print(dest) | 48 | with open(dest, 'w') as f: |
50 | with open(dest, 'w') as f: | 49 | f.write(logdata) |
51 | f.write(ptest['log']) | ||
52 | 50 | ||
53 | if args.raw_ptest: | 51 | if args.raw_ptest: |
54 | if 'ptestresult.rawlogs' in r: | 52 | rawlog = resultutils.ptestresult_get_rawlogs(r) |
55 | print(r['ptestresult.rawlogs']['log']) | 53 | if rawlog is not None: |
54 | print(rawlog) | ||
56 | else: | 55 | else: |
57 | print('Raw ptest logs not found') | 56 | print('Raw ptest logs not found') |
58 | return 1 | 57 | return 1 |