summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils/logparser.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-29 13:24:45 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-31 23:23:26 +0000
commit88f390bcb68650df08d8d636cba1aaf7b69b2999 (patch)
treecb8d88e15bb48a63e432550b0b230537970bb169 /meta/lib/oeqa/utils/logparser.py
parent4ee85b1cd63f8c6c9d057faab0935c0e6763996b (diff)
downloadpoky-88f390bcb68650df08d8d636cba1aaf7b69b2999.tar.gz
oeqa/logparser: Reform the ptest results parser
Now we have a dedicated ptest parser, merge in the remaining ptest specific pieces to further clarify and simplify the code, moving to a point where we can consider extending/enhancing it. (From OE-Core rev: 05991bb5bc8018275d03fdeecee3d5a757840c7c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/logparser.py')
-rw-r--r--meta/lib/oeqa/utils/logparser.py58
1 files changed, 33 insertions, 25 deletions
diff --git a/meta/lib/oeqa/utils/logparser.py b/meta/lib/oeqa/utils/logparser.py
index 0807093fda..f8d1c03630 100644
--- a/meta/lib/oeqa/utils/logparser.py
+++ b/meta/lib/oeqa/utils/logparser.py
@@ -7,32 +7,40 @@ from . import ftools
7 7
8# A parser that can be used to identify weather a line is a test result or a section statement. 8# A parser that can be used to identify weather a line is a test result or a section statement.
9class PtestParser(object): 9class PtestParser(object):
10
11 def __init__(self): 10 def __init__(self):
12 11 self.results = Result()
13 self.test_regex = {} 12
14 self.test_regex['pass'] = re.compile(r"^PASS:(.+)") 13 def parse(self, logfile):
15 self.test_regex['fail'] = re.compile(r"^FAIL:(.+)") 14 test_regex = {}
16 self.test_regex['skip'] = re.compile(r"^SKIP:(.+)") 15 test_regex['pass'] = re.compile(r"^PASS:(.+)")
17 16 test_regex['fail'] = re.compile(r"^FAIL:(.+)")
18 self.section_regex = {} 17 test_regex['skip'] = re.compile(r"^SKIP:(.+)")
19 self.section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest") 18
20 self.section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest") 19 section_regex = {}
21 20 section_regex['begin'] = re.compile(r"^BEGIN: .*/(.+)/ptest")
22 # Parse a line and return a tuple containing the type of result (test/section) and its category, status and name 21 section_regex['end'] = re.compile(r"^END: .*/(.+)/ptest")
23 def parse_line(self, line): 22
24 23 with open(logfile, errors='replace') as f:
25 for test_status, status_regex in test_status_list.items(): 24 for line in f:
26 test_name = status_regex.search(line) 25 result = section_regex['begin'].search(line)
27 if test_name: 26 if result:
28 return ['test', test_category, test_status, test_name.group(1)] 27 current_section = result.group(1)
29 28 continue
30 for section_status, status_regex in section_status_list.items(): 29
31 section_name = status_regex.search(line) 30 result = section_regex['end'].search(line)
32 if section_name: 31 if result:
33 return ['section', section_category, section_status, section_name.group(1)] 32 if current_section != result.group(1):
34 return None 33 bb.warn("Ptest log section mismatch %s vs. %s" % (current_section, result.group(1)))
35 34 current_section = None
35 continue
36
37 for t in test_regex:
38 result = test_regex[t].search(line)
39 if result:
40 self.results.store(current_section, result.group(1), t)
41
42 self.results.sort_tests()
43 return self.results
36 44
37class Result(object): 45class Result(object):
38 46