1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
import re
class OeqaLogParser(object):
def get_test_status(self, log_file):
regex = ".*RESULTS - (?P<case_name>.*) - Testcase .*: (?P<status>PASSED|FAILED|SKIPPED|ERROR|UNKNOWN).*$"
regex_comp = re.compile(regex)
results = {}
with open(log_file, "r") as f:
for line in f:
line = line.strip()
m = regex_comp.search(line)
if m:
results[m.group('case_name')] = m.group('status')
return results
def get_failed_tests(self, log_file):
regex = ".*RESULTS - (?P<case_name>.*) - Testcase (?P<case_id>\d+): (?P<status>FAILED)$"
regex_comp = re.compile(regex)
results = {}
with open(log_file, "r") as f:
for line in f:
line = line.strip()
m = regex_comp.search(line)
if m:
results[m.group('case_name')] = m.group('status')
return results
def get_runtime_test_image_environment(self, log_file):
regex = "core-image.*().*Ran.*tests in .*s"
regex_comp = re.compile(regex)
image_env = ''
with open(log_file, "r") as f:
for line in f:
line = line.strip()
m = regex_comp.search(line)
if m:
image_env = line[:line.find("(")-1]
image_env = image_env.strip()
break
return image_env
def get_runtime_test_qemu_environment(self, log_file):
regex = "DEBUG: launchcmd=runqemu*"
regex_comp = re.compile(regex)
qemu_env = ''
with open(log_file, "r") as f:
for line in f:
line = line.strip()
m = regex_comp.search(line)
if m:
qemu_list = ['qemuarm', 'qemuarm64', 'qemumips', 'qemumips64', 'qemuppc', 'qemux86', 'qemux86-64']
for qemu in qemu_list:
if qemu in line:
qemu_env = qemu
break
return qemu_env
def _search_log_to_capture(self, logs, line, state, regex_comp_start, regex_comp_end_fail_or, regex_comp_end_error_or, regex_comp_end):
if state == 'Searching':
m = regex_comp_start.search(line)
if m:
logs.append(line)
return 'Found'
else:
return 'Searching'
elif state == 'Found':
m_fail = regex_comp_end_fail_or.search(line)
m_error = regex_comp_end_error_or.search(line)
m_end = regex_comp_end.search(line)
if m_fail or m_error or m_end:
return 'End'
else:
logs.append(line)
return 'Found'
def get_test_log(self, log_file, test_status, testcase_name, testsuite_name):
if test_status == 'FAILED':
test_status = 'FAIL'
regex_search_start = ".*%s: %s \(%s\).*" % (test_status, testcase_name, testsuite_name)
regex_search_end_fail_or = ".*FAIL: test.*"
regex_search_end_error_or = ".*ERROR: test.*"
regex_search_end = ".*Ran.*tests in .*s"
regex_comp_start = re.compile(regex_search_start)
regex_comp_end_fail_or = re.compile(regex_search_end_fail_or)
regex_comp_end_error_or = re.compile(regex_search_end_error_or)
regex_comp_end = re.compile(regex_search_end)
state = 'Searching'
logs = []
with open(log_file, "r") as f:
for line in f:
line = line.strip()
if state == 'End':
return logs
else:
state = self._search_log_to_capture(logs, line, state, regex_comp_start, regex_comp_end_fail_or, regex_comp_end_error_or, regex_comp_end)
|