Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yosys-tests
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
yosys-tests
Commits
a6bd114d
Commit
a6bd114d
authored
Apr 27, 2019
by
Miodrag Milanovic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Script to generate junit report xml
parent
7d2bf663
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
92 additions
and
0 deletions
+92
-0
report.py
+92
-0
No files found.
report.py
0 → 100755
View file @
a6bd114d
#!/usr/bin/env python3
import
os
from
pathlib
import
Path
def
getListOfFiles
(
dirName
):
listOfFile
=
os
.
listdir
(
dirName
)
allFiles
=
list
()
for
entry
in
listOfFile
:
fullPath
=
os
.
path
.
join
(
dirName
,
entry
)
if
os
.
path
.
isdir
(
fullPath
):
allFiles
=
allFiles
+
getListOfFiles
(
fullPath
)
else
:
if
Path
(
fullPath
)
.
suffix
==
".status"
:
allFiles
.
append
(
fullPath
)
return
allFiles
def
main
():
listOfFiles
=
getListOfFiles
(
'.'
)
listOfFiles
.
sort
()
testsuits
=
list
()
casenumber
=
dict
()
errors
=
dict
()
failures
=
dict
()
total_errors
=
0
total_failures
=
0
for
elem
in
listOfFiles
:
st
=
elem
.
split
(
'/'
)
testsuit
=
st
[
1
]
testcase
=
st
[
-
1
]
.
replace
(
'.status'
,
''
)
if
(
testsuit
not
in
testsuits
):
testsuits
.
append
(
testsuit
)
casenumber
[
testsuit
]
=
0
errors
[
testsuit
]
=
0
failures
[
testsuit
]
=
0
casenumber
[
testsuit
]
+=
1
status
=
open
(
elem
,
'r'
)
.
read
()
.
strip
()
if
(
status
==
'ERROR'
):
errors
[
testsuit
]
+=
1
total_errors
+=
1
if
(
status
==
'FAIL'
):
failures
[
testsuit
]
+=
1
total_failures
+=
1
# Creating report
with
open
(
"report.xml"
,
"w"
)
as
f
:
print
(
'<?xml version="1.0" encoding="UTF-8"?>'
,
file
=
f
)
print
(
'<testsuites disabled="0" errors="
%
d" failures="
%
d" tests="
%
d" time="
%
d">'
%
(
total_errors
,
total_failures
,
len
(
listOfFiles
),
0
),
file
=
f
)
for
suite
in
testsuits
:
print
(
' <testsuite disabled="0" errors="
%
d" failures="
%
d" name="
%
s" skipped="0" tests="
%
d" time="
%
d">'
%
(
errors
[
suite
],
failures
[
suite
],
suite
,
casenumber
[
suite
],
0
),
file
=
f
)
for
elem
in
listOfFiles
:
st
=
elem
.
split
(
'/'
)
testsuit
=
st
[
1
]
if
(
testsuit
!=
suite
):
continue
testcase
=
st
[
-
1
]
.
replace
(
'.status'
,
''
)
casenumber
[
testsuit
]
+=
1
status
=
open
(
elem
,
'r'
)
.
read
()
.
strip
()
print
(
' <testcase classname="
%
s.
%
s" name="
%
s" status="
%
s" time="
%
d">'
%
(
testsuit
,
st
[
2
]
.
replace
(
'.status'
,
''
),
testcase
,
status
,
0
),
file
=
f
)
if
(
status
==
'ERROR'
):
print
(
' <error message="
%
s" type="
%
s"/>'
%
(
status
,
status
),
file
=
f
)
if
(
status
==
'FAIL'
):
print
(
' <failure message="
%
s" type="
%
s"/>'
%
(
status
,
status
),
file
=
f
)
file_tb
=
os
.
path
.
join
(
os
.
path
.
dirname
(
elem
),
'testbench.log'
)
file_re
=
os
.
path
.
join
(
os
.
path
.
dirname
(
elem
),
'result.log'
)
file_ys
=
os
.
path
.
join
(
os
.
path
.
dirname
(
elem
),
'yosys.log'
)
if
(
os
.
path
.
isfile
(
file_tb
)):
print
(
'<system-out>'
,
end
=
""
,
file
=
f
)
with
open
(
file_tb
,
"r"
)
as
logf
:
for
line
in
logf
:
print
(
line
.
replace
(
"&"
,
"&"
)
.
replace
(
"<"
,
"<"
)
.
replace
(
">"
,
">"
)
.
replace
(
"
\"
"
,
"""
),
end
=
""
,
file
=
f
)
print
(
'</system-out>'
,
file
=
f
)
elif
(
os
.
path
.
isfile
(
file_re
)):
print
(
'<system-out>'
,
end
=
""
,
file
=
f
)
with
open
(
file_re
,
"r"
)
as
logf
:
for
line
in
logf
:
print
(
line
.
replace
(
"&"
,
"&"
)
.
replace
(
"<"
,
"<"
)
.
replace
(
">"
,
">"
)
.
replace
(
"
\"
"
,
"""
),
end
=
""
,
file
=
f
)
print
(
'</system-out>'
,
file
=
f
)
elif
(
os
.
path
.
isfile
(
file_ys
)):
print
(
'<system-out>'
,
end
=
""
,
file
=
f
)
with
open
(
file_ys
,
"r"
)
as
logf
:
for
line
in
logf
:
print
(
line
.
replace
(
"&"
,
"&"
)
.
replace
(
"<"
,
"<"
)
.
replace
(
">"
,
">"
)
.
replace
(
"
\"
"
,
"""
),
end
=
""
,
file
=
f
)
print
(
'</system-out>'
,
file
=
f
)
print
(
' </testcase>'
,
file
=
f
)
print
(
' </testsuite>'
,
file
=
f
)
print
(
'</testsuites>'
,
file
=
f
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment