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
16
Issues
16
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
b847c15e
Commit
b847c15e
authored
Sep 07, 2018
by
Martin Jeřábek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
testfw: hardening
parent
a22352aa
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
6 deletions
+11
-6
test/testfw/__init__.py
test/testfw/__init__.py
+2
-2
test/testfw/test_unit.py
test/testfw/test_unit.py
+2
-1
test/testfw/vunit_ifc.py
test/testfw/vunit_ifc.py
+7
-3
No files found.
test/testfw/__init__.py
View file @
b847c15e
...
...
@@ -15,7 +15,7 @@ func_cov_dir = d.parent / "build/functional_coverage"
def
setup_logging
()
->
None
:
with
Path
(
d
/
'logging.yaml'
).
open
(
'rt'
,
encoding
=
'utf-8'
)
as
f
:
cfg
=
yaml
.
load
(
f
)
cfg
=
yaml
.
safe_
load
(
f
)
logging
.
setLogRecordFactory
(
MyLogRecord
)
logging
.
config
.
dictConfig
(
cfg
)
global
log
...
...
@@ -106,7 +106,7 @@ def test(obj, config, strict, create_ghws, vunit_args):
config_file
=
base
/
config
out_basename
=
os
.
path
.
splitext
(
config
)[
0
]
with
config_file
.
open
(
'rt'
,
encoding
=
'utf-8'
)
as
f
:
config
=
yaml
.
load
(
f
)
config
=
yaml
.
safe_
load
(
f
)
build
.
mkdir
(
exist_ok
=
True
)
os
.
chdir
(
str
(
build
))
...
...
test/testfw/test_unit.py
View file @
b847c15e
...
...
@@ -30,7 +30,8 @@ class UnitTests(TestsBase):
pprint
([
x
.
name
for
x
in
unit_tests
])
raise
RuntimeError
(
'Testbench {}_unit_test does not exist'
+
' (but specified in config).'
.
format
(
name
))
assert
len
(
tb
)
==
1
elif
len
(
tb
)
!=
1
:
raise
RuntimeError
(
'Multiple tests matching "{}"'
.
format
(
name
))
tb
=
tb
[
0
]
tb
.
set_generic
(
'timeout'
,
cfg
[
'timeout'
])
tb
.
set_generic
(
'iterations'
,
cfg
[
'iterations'
])
...
...
test/testfw/vunit_ifc.py
View file @
b847c15e
...
...
@@ -4,19 +4,22 @@ import signal
__all__
=
[
'run'
]
def
get_children_pids
(
parent_pid
):
cmd
=
subprocess
.
run
(
"ps -o pid --ppid {} --noheaders"
.
format
(
parent_pid
),
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
check
=
False
)
out
=
cmd
.
stdout
.
decode
(
'ascii'
)
cmd
=
[
'ps'
,
'-o'
,
'pid'
,
'--ppid'
,
parent_pid
,
'--noheaders'
]
res
=
subprocess
.
run
(
cmd
,
stdout
=
subprocess
.
PIPE
,
check
=
False
)
out
=
res
.
stdout
.
decode
(
'ascii'
)
return
[
int
(
pid_str
)
for
pid_str
in
out
.
split
()
if
int
(
pid_str
)
!=
parent_pid
]
def
recursive_kill
(
pid
,
sig
=
signal
.
SIGTERM
):
children
=
get_children_pids
(
pid
)
for
child
in
children
:
recursive_kill
(
child
)
try
:
os
.
kill
(
child
,
sig
)
except
ProcessLookupError
as
e
:
except
ProcessLookupError
:
pass
# ghdl creates a new process group for itself and fails to kill its child when it receives a signal :(
def
sighandler
(
signo
,
frame
):
signal
.
signal
(
signo
,
signal
.
SIG_DFL
)
...
...
@@ -24,6 +27,7 @@ def sighandler(signo, frame):
# restore the handler, because vunit swallows the resulting exception
#signal.signal(signo, sighandler)
def
run
(
ui
):
signal
.
signal
(
signal
.
SIGTERM
,
sighandler
)
signal
.
signal
(
signal
.
SIGINT
,
sighandler
)
...
...
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