Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 4cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 4cha
Commits
a11ec120
Commit
a11ec120
authored
Nov 22, 2023
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci: check python style
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
4c8be336
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
64 deletions
+81
-64
.gitlab-ci.yml
.gitlab-ci.yml
+11
-0
conftest.py
pytest/conftest.py
+9
-5
test_fmcfd_getter_setter.py
pytest/test-00-basic/test_fmcfd_getter_setter.py
+5
-5
test_fmcfd_loop.py
pytest/test-01-functionalities/test_fmcfd_loop.py
+23
-25
test_fmcfd_temperature.py
pytest/test-01-functionalities/test_fmcfd_temperature.py
+1
-0
test_fmcfd_time.py
pytest/test-01-functionalities/test_fmcfd_time.py
+3
-2
test_fmcfd_input.py
pytest/test-02-manual/test_fmcfd_input.py
+2
-1
test_fmcfd_output.py
pytest/test-02-manual/test_fmcfd_output.py
+27
-26
No files found.
.gitlab-ci.yml
View file @
a11ec120
...
...
@@ -13,6 +13,17 @@ include:
file
:
-
'
edl-gitlab-ci.yml'
python-style
:
variables
:
FF_KUBERNETES_HONOR_ENTRYPOINT
:
1
# Make Gitlab K8s executors to respect entrypoint in Acc-Py images, https://cern.service-now.com/service-portal?id=ticket&table=incident&n=INC3570437
stage
:
analyse
image
:
name
:
gitlab-registry.cern.ch/acc-co/devops/python/distribution-images/acc-py_cc7:pro
before_script
:
-
pip install pycodestyle
script
:
-
pycodestyle --ignore=E501,W503 pytest/
# W503 because I think is bug in pycodestyle
cppcheck
:
stage
:
analyse
image
:
...
...
pytest/conftest.py
View file @
a11ec120
...
...
@@ -28,12 +28,12 @@ def id_from_slot(slot):
if
int
(
dynslot
)
==
carrier_slot
:
break
pciid
=
f
"0000:{pciid}"
pathfmc
=
list
(
Path
(
"/sys/bus/pci/devices"
)
.
joinpath
(
pciid
)
\
pathfmc
=
list
(
Path
(
"/sys/bus/pci/devices"
)
.
joinpath
(
pciid
)
.
glob
(
f
"spec-*/id:*/fmc-fdelay-tdc.*.auto/fmc-slot-*.{mezzanine_slot}"
))
elif
carrier_bus
==
"VME"
:
pathfmc
=
list
(
Path
(
"/sys/bus/vme/devices"
)
.
joinpath
(
f
"slot.{carrier_slot:02d}"
)
\
.
joinpath
(
f
"vme.{carrier_slot:02d}"
)
\
pathfmc
=
list
(
Path
(
"/sys/bus/vme/devices"
)
.
joinpath
(
f
"slot.{carrier_slot:02d}"
)
.
joinpath
(
f
"vme.{carrier_slot:02d}"
)
.
glob
(
f
"svec-*/svec-*/id:*/fmc-fdelay-tdc.*.auto/fmc-slot-*.{mezzanine_slot}"
))
else
:
raise
ValueError
()
...
...
@@ -45,10 +45,12 @@ def id_from_slot(slot):
dev_id
=
int
(
f
.
read
()
.
strip
()
.
split
(
"-"
)[
1
],
16
)
return
dev_id
def
pytest_generate_tests
(
metafunc
):
if
"dev_id"
in
metafunc
.
fixturenames
:
metafunc
.
parametrize
(
"dev_id"
,
pytest
.
dev_id
)
@
pytest
.
fixture
(
scope
=
"function"
)
def
fmcfd
(
dev_id
):
fd
=
FmcFineDelay
(
dev_id
)
...
...
@@ -58,8 +60,9 @@ def fmcfd(dev_id):
for
chan
in
fd
.
chan
:
chan
.
disable
()
def
pytest_addoption
(
parser
):
parser
.
addoption
(
"--id"
,
type
=
lambda
x
:
int
(
x
,
16
),
action
=
'append'
,
parser
.
addoption
(
"--id"
,
type
=
lambda
x
:
int
(
x
,
16
),
action
=
'append'
,
default
=
[],
help
=
"Fmc Fine-Delay Linux Identifier"
)
parser
.
addoption
(
"--slot"
,
type
=
valid_slot_type
,
action
=
'append'
,
default
=
[],
help
=
"Fmc Fine-Delay absolute slot (works only for SPEC and SVEC)"
)
...
...
@@ -67,6 +70,7 @@ def pytest_addoption(parser):
action
=
"append"
,
choices
=
range
(
FmcFineDelay
.
CHANNEL_NUMBER
),
help
=
"Channel(s) to be used for acquisition tests. Default all channels"
)
def
pytest_configure
(
config
):
pytest
.
dev_id
=
config
.
getoption
(
"--id"
)
if
len
(
pytest
.
dev_id
)
==
0
:
...
...
pytest/test-00-basic/test_fmcfd_getter_setter.py
View file @
a11ec120
...
...
@@ -8,17 +8,17 @@ import random
from
PyFmcFineDelay
import
FmcFineDelay
,
FmcFineDelayTime
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
range
(
0
,
FmcFineDelay
.
CHANNEL_NUMBER
))
def
fmcfd_chan
(
request
,
fmcfd
):
yield
fmcfd
.
chan
[
request
.
param
]
class
TestFmcfdGetterSetter
(
object
):
def
test_disable
(
self
,
fmcfd
):
for
chan
in
fmcfd
.
chan
:
chan
.
disable
()
assert
chan
.
disabled
==
True
assert
chan
.
disabled
is
True
@
pytest
.
mark
.
parametrize
(
"enable"
,
[
True
,
False
])
def
test_tdc_disable_input
(
self
,
fmcfd
,
enable
):
...
...
pytest/test-01-functionalities/test_fmcfd_loop.py
View file @
a11ec120
...
...
@@ -62,9 +62,9 @@ class TestFmcfdLoop(object):
fmcfd_tdc
.
flush
()
assert
len
(
fmcfd_tdc
.
poll
(
1000
))
==
0
@
pytest
.
mark
.
parametrize
(
"count, period_ps"
,
[(
i
+
1
,
1000000
)
for
i
in
range
(
15
)]
+
[(
100
,
4500000000
),
(
MAX_COUNT
,
4500000000
)])
@
pytest
.
mark
.
parametrize
(
"count, period_ps"
,
[(
i
+
1
,
1000000
)
for
i
in
range
(
15
)]
+
[(
100
,
4500000000
),
(
MAX_COUNT
,
4500000000
)])
def
test_output_counter
(
self
,
fmcfd
,
fmcfd_chan
,
fmcfd_tdc
,
count
,
period_ps
):
"""In pulse mode, the Fine-Delay generates the exact number of
required pulses and we are able to read them all from the input
...
...
@@ -97,13 +97,10 @@ class TestFmcfdLoop(object):
prev_ts
=
ts
[
i
]
del
ts
@
pytest
.
mark
.
parametrize
(
"start_rel"
,
[
FmcFineDelayTime
(
0
,
random
.
randrange
(
1
,
125000000
),
0
)
for
i
in
range
(
50
)]
+
[
FmcFineDelayTime
(
1
,
random
.
randrange
(
1
,
125000000
),
0
)
for
i
in
range
(
5
)]
+
[
FmcFineDelayTime
(
2
,
random
.
randrange
(
1
,
125000000
),
0
)
for
i
in
range
(
5
)])
@
pytest
.
mark
.
parametrize
(
"start_rel"
,
[
FmcFineDelayTime
(
0
,
random
.
randrange
(
1
,
125000000
),
0
)
for
i
in
range
(
50
)]
+
[
FmcFineDelayTime
(
1
,
random
.
randrange
(
1
,
125000000
),
0
)
for
i
in
range
(
5
)]
+
[
FmcFineDelayTime
(
2
,
random
.
randrange
(
1
,
125000000
),
0
)
for
i
in
range
(
5
)])
@
pytest
.
mark
.
parametrize
(
"wr"
,
[
False
,
True
])
def
test_output_input_start
(
self
,
fmcfd_chan
,
fmcfd_tdc
,
wr
,
start_rel
):
"""
...
...
@@ -125,13 +122,14 @@ class TestFmcfdLoop(object):
assert
start
.
seconds
==
ts
[
0
]
.
seconds
assert
ts
[
0
]
.
coarse
-
start
.
coarse
<=
3
# there is < 3ns cable
@
pytest
.
mark
.
parametrize
(
"period_ps"
,
[
random
.
randrange
(
1000000
,
10000000
)
for
x
in
range
(
128
)]
+
[
random
.
randrange
(
10000000
,
100000000
)
for
x
in
range
(
64
)]
+
[
random
.
randrange
(
100000000
,
1000000000
)
for
x
in
range
(
32
)]
+
[
random
.
randrange
(
1000000000
,
10000000000
)
for
x
in
range
(
16
)]
+
[
random
.
randrange
(
10000000000
,
100000000000
)
for
x
in
range
(
8
)]
+
[
random
.
randrange
(
100000000000
,
1000000000000
)
for
x
in
range
(
4
)])
@
pytest
.
mark
.
parametrize
(
"period_ps"
,
[
random
.
randrange
(
1000000
,
10000000
)
for
x
in
range
(
128
)]
+
[
random
.
randrange
(
10000000
,
100000000
)
for
x
in
range
(
64
)]
+
[
random
.
randrange
(
100000000
,
1000000000
)
for
x
in
range
(
32
)]
+
[
random
.
randrange
(
1000000000
,
10000000000
)
for
x
in
range
(
16
)]
+
[
random
.
randrange
(
10000000000
,
100000000000
)
for
x
in
range
(
8
)]
+
[
random
.
randrange
(
100000000000
,
1000000000000
)
for
x
in
range
(
4
)]
)
@
pytest
.
mark
.
parametrize
(
"count"
,
[
15
])
def
test_output_period
(
self
,
fmcfd_chan
,
fmcfd_tdc
,
period_ps
,
count
):
"""
...
...
pytest/test-01-functionalities/test_fmcfd_temperature.py
View file @
a11ec120
...
...
@@ -5,6 +5,7 @@ SPDX-FileCopyrightText: 2020 CERN
import
pytest
class
TestFmcfdTemperature
(
object
):
def
test_temperature_read
(
self
,
fmcfd
):
...
...
pytest/test-01-functionalities/test_fmcfd_time.py
View file @
a11ec120
...
...
@@ -8,14 +8,15 @@ import random
import
time
from
PyFmcFineDelay
import
FmcFineDelayTime
class
TestFmcfdTime
(
object
):
def
test_whiterabbit_mode
(
self
,
fmcfd
):
"""It must be possible to toggle the White-Rabbit status"""
fmcfd
.
whiterabbit_mode
=
True
assert
fmcfd
.
whiterabbit_mode
==
True
assert
fmcfd
.
whiterabbit_mode
is
True
fmcfd
.
whiterabbit_mode
=
False
assert
fmcfd
.
whiterabbit_mode
==
False
assert
fmcfd
.
whiterabbit_mode
is
False
def
test_time_set_fail_wr
(
self
,
fmcfd
):
"""Time can't be changed when White-Rabbit is enabled"""
...
...
pytest/test-02-manual/test_fmcfd_input.py
View file @
a11ec120
...
...
@@ -10,6 +10,7 @@ import time
import
os
from
PyFmcFineDelay
import
FmcFineDelay
,
FmcFineDelayTime
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
pytest
.
channels
)
def
fmcfd_tdc
(
request
):
fd
=
FmcFineDelay
(
pytest
.
fd_id
)
...
...
pytest/test-02-manual/test_fmcfd_output.py
View file @
a11ec120
...
...
@@ -8,6 +8,7 @@ import random
import
time
from
PyFmcFineDelay
import
FmcFineDelay
,
FmcFineDelayTime
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
pytest
.
channels
)
def
fmcfd_chan
(
request
):
fd
=
FmcFineDelay
(
pytest
.
fd_id
)
...
...
@@ -29,7 +30,7 @@ class TestFmcfdOutput(object):
print
(
" period : {:d}ps"
.
format
(
period
))
print
(
" count : {:d}"
.
format
(
count
))
@
pytest
.
mark
.
parametrize
(
"width"
,[
50000
,
# 50ns
@
pytest
.
mark
.
parametrize
(
"width"
,
[
50000
,
# 50ns
60000
,
# 60ns
70000
,
# 70ns
80000
,
# 80ns
...
...
@@ -84,7 +85,7 @@ class TestFmcfdOutput(object):
while
True
:
fmcfd_chan
.
pulse_delay
(
delay
,
250000
,
500000
,
1
)
time
.
sleep
(
1
+
delay
/
1000000000000.0
)
time
.
sleep
(
1
+
delay
/
1000000000000.0
)
ret
=
self
.
__process_outcome
(
fmcfd_chan
.
idx
+
1
,
delay
,
250000
,
500000
,
1
)
if
ret
in
[
"y"
,
"n"
,
"q"
]:
break
...
...
@@ -92,7 +93,7 @@ class TestFmcfdOutput(object):
pytest
.
skip
(
"Quit test"
)
assert
ret
==
"y"
@
pytest
.
mark
.
parametrize
(
"width"
,[
250000
,
# 250ns
@
pytest
.
mark
.
parametrize
(
"width"
,
[
250000
,
# 250ns
260000
,
# 260ns
270000
,
# 270ns
280000
,
# 280ns
...
...
@@ -119,7 +120,7 @@ class TestFmcfdOutput(object):
while
True
:
fmcfd_chan
.
pulse_delay
(
width
,
width
,
500000
,
1
)
time
.
sleep
(
1
+
delay
/
1000000000000.0
)
time
.
sleep
(
1
+
delay
/
1000000000000.0
)
ret
=
self
.
__process_outcome
(
fmcfd_chan
.
idx
+
1
,
600000
,
width
,
500000
,
1
)
if
ret
in
[
"y"
,
"n"
,
"q"
]:
break
...
...
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