Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CTU CAN FD IP Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
14
Issues
14
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
canbus
CTU CAN FD IP Core
Commits
e54c2c6e
Commit
e54c2c6e
authored
Jun 04, 2018
by
Martin Jeřábek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testfw: restructured, all tests may be in one config
parent
35301574
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
67 deletions
+130
-67
test/testfw/__init__.py
test/testfw/__init__.py
+83
-36
test/tests_fast.yml
test/tests_fast.yml
+47
-0
test/unit_fast.yml
test/unit_fast.yml
+0
-31
No files found.
test/testfw/__init__.py
View file @
e54c2c6e
...
...
@@ -13,8 +13,11 @@ from pprint import pprint
from
.log
import
MyLogRecord
from
.
import
vunit_ifc
from
vunit.ui
import
VUnit
import
re
d
=
Path
(
abspath
(
__file__
)).
parent
base
=
d
.
parent
build
=
base
/
'build'
def
setup_logging
()
->
None
:
with
Path
(
d
/
'logging.yaml'
).
open
(
'rt'
,
encoding
=
'utf-8'
)
as
f
:
...
...
@@ -141,42 +144,102 @@ def create_wrapper(lib, fname):
def
cli
(
ctx
,
compile
):
setup_logging
()
ctx
.
obj
=
{
'compile'
:
compile
}
sys
.
argv
[
0
]
=
abspath
(
sys
.
argv
[
0
])
pass
@
cli
.
command
()
def
create
():
pass
@
cli
.
group
(
cls
=
AliasedGroup
)
def
test
():
sys
.
argv
[
0
]
=
abspath
(
sys
.
argv
[
0
])
pass
def
create_vunit
(
obj
,
vunit_args
):
# fill vunit arguments
args
=
[]
# hack for vunit_compile TCL command
if
obj
[
'compile'
]:
args
+=
[
'--compile'
]
args
+=
[
'--xunit-xml'
,
'../test_unit.xml1'
]
+
list
(
vunit_args
)
ui
=
VUnit
.
from_argv
(
args
)
return
ui
@
test
.
command
()
def
vunit_run
(
ui
,
build
):
try
:
vunit_ifc
.
run
(
ui
)
res
=
None
except
SystemExit
as
e
:
res
=
e
.
code
out
=
build
/
'../test_unit.xml1'
if
out
.
exists
():
with
out
.
open
(
'rt'
,
encoding
=
'utf-8'
)
as
f
:
c
=
f
.
read
()
with
open
(
'../test_unit.xml'
,
'wt'
,
encoding
=
'utf-8'
)
as
f
:
print
(
'<?xml version="1.0" encoding="utf-8"?>'
,
file
=
f
)
print
(
'<?xml-stylesheet href="xunit.xsl" type="text/xsl"?>'
,
file
=
f
)
f
.
write
(
c
)
out
.
unlink
()
sys
.
exit
(
res
)
@
cli
.
command
()
@
click
.
argument
(
'config'
,
type
=
click
.
Path
())
@
click
.
argument
(
'vunit_args'
,
nargs
=-
1
)
@
click
.
pass_obj
def
uni
t
(
obj
,
config
,
vunit_args
):
config_file
=
d
.
parent
/
config
def
tes
t
(
obj
,
config
,
vunit_args
):
config_file
=
base
/
config
with
config_file
.
open
(
'rt'
,
encoding
=
'utf-8'
)
as
f
:
config
=
yaml
.
load
(
f
)
base
=
Path
(
config_file
).
resolve
().
parent
build
=
d
.
parent
/
'build'
build
.
mkdir
(
exist_ok
=
True
)
os
.
chdir
(
str
(
build
))
args
=
[]
if
obj
[
'compile'
]:
args
+=
[
'--compile'
]
args
+=
[
'--xunit-xml'
,
'../test_unit.xml1'
]
+
list
(
vunit_args
)
ui
=
VUnit
.
from_argv
(
args
)
run_unit
=
'unit'
in
config
run_feature
=
'feature'
in
config
run_sanity
=
'sanity'
in
config
ui
=
create_vunit
(
obj
,
vunit_
args
)
lib
=
ui
.
add_library
(
"lib"
)
add_common_sources
(
lib
)
add_sources
(
lib
,
[
'unit/**/*.vhd'
])
create_wrapper
(
lib
,
build
/
"tb_wrappers.vhd"
)
# unit tests
if
run_unit
:
add_sources
(
lib
,
[
'unit/**/*.vhd'
])
create_wrapper
(
lib
,
build
/
"tb_wrappers.vhd"
)
# sanity test
if
run_sanity
:
add_sources
(
lib
,
[
'sanity/*.vhd'
])
# feature tests
if
run_feature
:
add_sources
(
lib
,
[
'feature/*.vhd'
])
add_flags
(
ui
,
lib
,
build
)
if
run_unit
:
configure_unit_tests
(
ui
,
lib
,
config
[
'unit'
])
if
run_sanity
:
configure_sanity_tests
(
ui
,
lib
,
config
[
'sanity'
])
if
run_feature
:
configure_feature_tests
(
ui
,
lib
,
config
[
'feature'
])
# check for unconfigured unit tests
if
run_unit
:
unit_tests
=
lib
.
get_test_benches
(
'*tb_*_unit_test'
)
configured
=
[
'tb_{}_unit_test'
.
format
(
name
)
for
name
in
config
[
'unit'
][
'tests'
].
keys
()]
log
.
debug
(
'Configured unit tests: {}'
.
format
(
', '
.
join
(
configured
)))
unconfigured
=
[
tb
for
tb
in
unit_tests
if
tb
.
name
not
in
configured
]
if
len
(
unconfigured
):
log
.
warn
(
"Unit tests with no configuration found (defaults will be used): {}"
.
format
(
', '
.
join
(
tb
.
name
for
tb
in
unconfigured
)))
# check for unknown tests
all_benches
=
lib
.
get_test_benches
(
'*'
)
unknown_tests
=
[
tb
for
tb
in
all_benches
if
not
re
.
match
(
'tb_.*?_unit_test|tb_sanity'
,
tb
.
name
)]
if
len
(
unknown_tests
):
log
.
warn
(
'Unknown tests (defaults will be used): {}'
.
format
(
', '
.
join
(
tb
.
name
for
tb
in
unknown_tests
)))
vunit_run
(
ui
,
build
)
def
configure_unit_tests
(
ui
,
lib
,
config
):
default
=
config
[
'default'
]
unit_tests
=
lib
.
get_test_benches
(
'*_unit_test'
)
for
name
,
_cfg
in
config
[
'tests'
].
items
():
...
...
@@ -225,27 +288,11 @@ def unit(obj, config, vunit_args):
'''
.
format
(
name
)),
file
=
f
)
tb
.
set_sim_option
(
"modelsim.init_file.gui"
,
str
(
tcl
))
# check for unconfigured testbenches
all_benches
=
lib
.
get_test_benches
(
'*'
)
configured
=
[
'tb_{}_unit_test'
.
format
(
name
)
for
name
in
config
[
'tests'
].
keys
()]
log
.
debug
(
'Configured tests: {}'
.
format
(
', '
.
join
(
configured
)))
unconfigured
=
[
tb
for
tb
in
all_benches
if
tb
.
name
not
in
configured
]
if
len
(
unconfigured
):
log
.
warn
(
"Testbenches with no configuration found: {}"
.
format
(
', '
.
join
(
x
.
name
for
x
in
unconfigured
)))
def
configure_sanity_tests
(
ui
,
lib
,
config
):
pass
try
:
vunit_ifc
.
run
(
ui
)
except
SystemExit
:
pass
out
=
build
/
'../test_unit.xml1'
if
out
.
exists
():
with
out
.
open
(
'rt'
,
encoding
=
'utf-8'
)
as
f
:
c
=
f
.
read
()
with
open
(
'../test_unit.xml'
,
'wt'
,
encoding
=
'utf-8'
)
as
f
:
print
(
'<?xml version="1.0" encoding="utf-8"?>'
,
file
=
f
)
print
(
'<?xml-stylesheet href="xunit.xsl" type="text/xsl"?>'
,
file
=
f
)
f
.
write
(
c
)
out
.
unlink
()
def
configure_feature_tests
(
ui
,
lib
,
config
):
pass
"""
- vunit configurations
...
...
test/tests_fast.yml
0 → 100644
View file @
e54c2c6e
unit
:
default
:
log_level
:
warning
error_tolerance
:
0
iterations
:
50
tests
:
bit_stuffing
:
iterations
:
10
wave
:
unit/Bit_Stuffing/bsdt_unit.tcl
apb
:
iterations
:
1
bus_sync
:
wave
:
unit/Bus_Sampling/bsnc_unit.tcl
crc
:
wave
:
unit/CRC/crct_unit.tcl
fault_confinement
:
wave
:
unit/Fault_confinement/fault_conf_unit.tcl
int_man
:
wave
:
unit/Int_Manager/intm_unit.tcl
mess_filt
:
wave
:
unit/Message_filter/msft_unit.tcl
presc
:
wave
:
unit/Prescaler/prsc_unit.tcl
protocol_control
:
wave
:
unit/Protocol_Control/pctl_unit.tcl
rx_buf
:
wave
:
unit/RX_Buffer/rxbf_unit.tcl
iterations
:
10
tx_arb
:
wave
:
unit/TX_Arbitrator/txar_unit.tcl
tx_buf
:
wave
:
unit/TX_Buffer/txbf_unit.tcl
.sanity
:
default
:
iterations
:
1
tests
:
"
1Mb/10Mb
20
m
Star"
:
topology
:
star
bus_len_v
:
[
10.0
,
10.0
,
10.0
,
10.0
,
0.0
,
0.0
]
trv_del_v
:
[
10
,
10
,
10
,
10
]
osc_tol_v
:
[
0
,
5
,
10
,
15
]
nw_mean
:
70.0
nw_var
:
5.0
ng_mean
:
300000.0
ng_var
:
100000.0
timing_config
:
[
4
,
1
,
8
,
8
,
8
,
3
,
3
,
1
,
5
,
2
]
test/unit_fast.yml
deleted
100644 → 0
View file @
35301574
default
:
log_level
:
warning
error_tolerance
:
0
iterations
:
50
tests
:
bit_stuffing
:
iterations
:
10
wave
:
unit/Bit_Stuffing/bsdt_unit.tcl
apb
:
iterations
:
1
bus_sync
:
wave
:
unit/Bus_Sampling/bsnc_unit.tcl
crc
:
wave
:
unit/CRC/crct_unit.tcl
fault_confinement
:
wave
:
unit/Fault_confinement/fault_conf_unit.tcl
int_man
:
wave
:
unit/Int_Manager/intm_unit.tcl
mess_filt
:
wave
:
unit/Message_filter/msft_unit.tcl
presc
:
wave
:
unit/Prescaler/prsc_unit.tcl
protocol_control
:
wave
:
unit/Protocol_Control/pctl_unit.tcl
rx_buf
:
wave
:
unit/RX_Buffer/rxbf_unit.tcl
iterations
:
10
tx_arb
:
wave
:
unit/TX_Arbitrator/txar_unit.tcl
tx_buf
:
wave
:
unit/TX_Buffer/txbf_unit.tcl
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