summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-29 14:22:07 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-02-25 22:27:39 +0000
commit6cb1b12565b82807cd7af3b9d919af8d25223ca5 (patch)
tree51b228a03dae25d59ddc43207cecba8a12fae680 /meta/lib/oeqa/utils
parentff0a227e4c3e949ab4dca31c60ec693b40b9ce28 (diff)
downloadpoky-6cb1b12565b82807cd7af3b9d919af8d25223ca5.tar.gz
oeqa/utils/logparser: Add in support for duration, exitcode and logs by section
Allow parsing of the ptest duration, exit code and timeout keywords from the logs, returning data on each section. Also include the logs broken out per section. (From OE-Core rev: a9a67dccaa5be0f06eedcab46dcff7cbf9202850) (From OE-Core rev: dc49021f75ed7e82713d1c9a04e045718bb9a548) 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>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/logparser.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index f8d1c03630..dddea14fc9 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -9,6 +9,7 @@ from . import ftools
9class PtestParser(object): 9class PtestParser(object):
10 def __init__(self): 10 def __init__(self):
11 self.results = Result() 11 self.results = Result()
12 self.sections = {}
12 13
13 def parse(self, logfile): 14 def parse(self, logfile):
14 test_regex = {} 15 test_regex = {}
@@ -19,28 +20,55 @@ class PtestParser(object):
19 section_regex = {} 20 section_regex = {}
20 section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest") 21 section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest")
21 section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest") 22 section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest")
23 section_regex['duration'] = re.compile(r"^DURATION: (.+)")
24 section_regex['exitcode'] = re.compile(r"^ERROR: Exit status is (.+)")
25 section_regex['timeout'] = re.compile(r"^TIMEOUT: .*/(.+)/ptest")
26
27 def newsection():
28 return { 'name': "No-section", 'log': "" }
29
30 current_section = newsection()
22 31
23 with open(logfile, errors='replace') as f: 32 with open(logfile, errors='replace') as f:
24 for line in f: 33 for line in f:
25 result = section_regex['begin'].search(line) 34 result = section_regex['begin'].search(line)
26 if result: 35 if result:
27 current_section = result.group(1) 36 current_section['name'] = result.group(1)
28 continue 37 continue
29 38
30 result = section_regex['end'].search(line) 39 result = section_regex['end'].search(line)
31 if result: 40 if result:
32 if current_section != result.group(1): 41 if current_section['name'] != result.group(1):
33 bb.warn("Ptest log section mismatch %s vs. %s" % (current_section, result.group(1))) 42 bb.warn("Ptest END log section mismatch %s vs. %s" % (current_section['name'], result.group(1)))
34 current_section = None 43 if current_section['name'] in self.sections:
44 bb.warn("Ptest duplicate section for %s" % (current_section['name']))
45 self.sections[current_section['name']] = current_section
46 del self.sections[current_section['name']]['name']
47 current_section = newsection()
48 continue
49
50 result = section_regex['timeout'].search(line)
51 if result:
52 if current_section['name'] != result.group(1):
53 bb.warn("Ptest TIMEOUT log section mismatch %s vs. %s" % (current_section['name'], result.group(1)))
54 current_section['timeout'] = True
35 continue 55 continue
36 56
57 for t in ['duration', 'exitcode']:
58 result = section_regex[t].search(line)
59 if result:
60 current_section[t] = result.group(1)
61 continue
62
63 current_section['log'] = current_section['log'] + line
64
37 for t in test_regex: 65 for t in test_regex:
38 result = test_regex[t].search(line) 66 result = test_regex[t].search(line)
39 if result: 67 if result:
40 self.results.store(current_section, result.group(1), t) 68 self.results.store(current_section['name'], result.group(1), t)
41 69
42 self.results.sort_tests() 70 self.results.sort_tests()
43 return self.results 71 return self.results, self.sections
44 72
45class Result(object): 73class Result(object):
46 74