-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_report.py
75 lines (63 loc) · 1.68 KB
/
generate_report.py
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
import re
import sys
rgx= '.+(:PASS|:FAIL:)?.+'
data = open('qemu_output.log', "r+")
report = open('qemu_report.xml', 'a')
lines = data.readlines()
pattern = re.compile(r"^.+(:PASS|:FAIL)")
successs_test = []
failed_test = []
for i, line in enumerate(lines):
for match in re.findall(pattern, line):
if match == ':PASS':
successs_test.append(lines[i].rstrip())
if match == ':FAIL':
failed_test.append(lines[i].rstrip())
total_test = len(successs_test) + len(failed_test)
failures = len(failed_test)
report.write('<?xml version="1.0" encoding="UTF-8"?>')
report.write(f"""
<testsuites
disabled="0"
errors="0"
failures="{failures}"
name="OpenEFI Testing results"
tests="{total_test}"
time="15s"
>
<testsuite name="openefi" errors="0" failures="0" skipped="0" time="2" tests="0">
""")
if len(failed_test):
for test_case in failed_test:
test_data = test_case.split(':')
report.write(f"""
<testcase name="{test_data[2]}"
assertions="1"
classname="{test_data[2]}"
status="{test_data[3]}"
time="1s"
>
<failure
message="{test_data[4]}"
type="FULL ASSERT"
>
FAIL: {test_data[4]}
{test_data[2]} on file {test_data[0]} , on line {test_data[1]}
</failure>
</testcase>
""")
if len(successs_test):
for test_case in successs_test:
test_data = test_case.split(':')
report.write(f"""
<testcase name="{test_data[2]}"
assertions="1"
classname="{test_data[2]}"
status="{test_data[3]}"
time="1s"
>
</testcase>
""")
report.write('</testsuite>')
report.write('</testsuites>')
report.close()