Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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 TDC 1ns 5cha
Commits
55591c20
Commit
55591c20
authored
Nov 09, 2023
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tst: allow multiple devices
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
ef49c269
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
23 deletions
+60
-23
conftest.py
pytest/conftest.py
+58
-21
test_fmctdc_acquisition.py
pytest/test-01-functionalities/test_fmctdc_acquisition.py
+2
-2
No files found.
pytest/conftest.py
View file @
55591c20
...
...
@@ -10,6 +10,12 @@ import re
import
os
from
PyFmcTdc
import
FmcTdc
def
pytest_generate_tests
(
metafunc
):
if
"fd_tdc_id"
in
metafunc
.
fixturenames
:
metafunc
.
parametrize
(
"fd_tdc_id"
,
pytest
.
fd_tdc_id
)
class
PulseGenerator
(
object
):
def
__init__
(
self
,
id
):
self
.
id
=
id
...
...
@@ -99,28 +105,47 @@ class FmcFineDelay(PulseGenerator):
if
sync
:
time
.
sleep
(
1
+
2
*
(
period_ns
*
count
)
/
1000000000.0
)
@
pytest
.
fixture
(
scope
=
"module"
)
def
fmcfd
():
gen
=
FmcFineDelay
(
pytest
.
fd_id
)
yield
gen
@
pytest
.
fixture
(
scope
=
"function"
)
def
tdc_and_gen
(
fd_tdc_id
):
fd_id
,
tdc_id
=
fd_tdc_id
gen
=
FmcFineDelay
(
fd_id
)
for
ch
in
range
(
FmcFineDelay
.
CHANNEL_NUMBER
):
gen
.
disable
(
ch
+
1
)
@
pytest
.
fixture
(
scope
=
"function"
)
def
fmctdc
():
tdc
=
FmcTdc
(
pytest
.
tdc_id
)
tdc
=
FmcTdc
(
tdc_id
)
for
ch
in
tdc
.
chan
:
ch
.
enable
=
False
ch
.
termination
=
False
ch
.
timestamp_mode
=
"post"
ch
.
flush
()
yield
(
gen
,
tdc
)
for
ch
in
range
(
FmcFineDelay
.
CHANNEL_NUMBER
):
gen
.
disable
(
ch
+
1
)
for
ch
in
tdc
.
chan
:
ch
.
enable
=
False
ch
.
termination
=
False
ch
.
timestamp_mode
=
"post"
ch
.
flush
()
@
pytest
.
fixture
(
scope
=
"function"
)
def
fmcfd
(
tdc_and_gen
):
fd
,
tdc
=
tdc_and_gen
yield
fd
@
pytest
.
fixture
(
scope
=
"function"
)
def
fmctdc
(
tdc_and_gen
):
fd
,
tdc
=
tdc_and_gen
yield
tdc
def
pytest_addoption
(
parser
):
parser
.
addoption
(
"--tdc-id"
,
type
=
lambda
x
:
int
(
x
,
16
),
required
=
True
,
help
=
"Fmc TDC Linux Identifier"
)
parser
.
addoption
(
"--fd-id"
,
type
=
lambda
x
:
int
(
x
,
16
),
default
=
None
,
help
=
"Fmc Fine-Delay Linux Identifier"
)
parser
.
addoption
(
"--tdc-id"
,
type
=
lambda
x
:
int
(
x
,
16
),
action
=
"append"
,
default
=
[]
,
help
=
"Fmc TDC Linux Identifier"
)
parser
.
addoption
(
"--fd-id"
,
type
=
lambda
x
:
int
(
x
,
16
),
action
=
"append"
,
default
=
[],
help
=
"Fmc Fine-Delay Linux Identifier"
)
parser
.
addoption
(
"--dump-range"
,
type
=
int
,
default
=
10
,
help
=
"Timestamps to show before and after an error"
)
parser
.
addoption
(
"--channel"
,
type
=
int
,
default
=
[],
...
...
@@ -144,7 +169,7 @@ def pytest_configure(config):
print
(
"For each --fd-id there must be a --tdc-id"
)
raise
Exception
()
pytest
.
fd_tdc_id
=
zip
(
pytest
.
fd_id
,
pytest
.
tdc_id
)
pytest
.
fd_tdc_id
=
list
(
zip
(
pytest
.
fd_id
,
pytest
.
tdc_id
)
)
pytest
.
channels
=
config
.
getoption
(
"--channel"
)
if
len
(
pytest
.
channels
)
==
0
:
...
...
@@ -155,15 +180,27 @@ def pytest_configure(config):
pytest
.
dump_range
=
config
.
getoption
(
"--dump-range"
)
pytest
.
transfer_mode
=
None
with
open
(
"/sys/bus/zio/devices/tdc-1n5c-{:04x}/transfer-mode"
.
format
(
pytest
.
tdc_id
))
as
f_mode
:
mode
=
int
(
f_mode
.
read
()
.
rstrip
())
for
k
,
v
in
FmcTdc
.
TRANSFER_MODE
.
items
():
if
mode
==
v
:
pytest
.
transfer_mode
=
k
modes
=
[]
for
tdc_id
in
pytest
.
tdc_id
:
with
open
(
f
"/sys/bus/zio/devices/tdc-1n5c-{tdc_id:04x}/transfer-mode"
)
as
f_mode
:
modes
.
append
(
int
(
f_mode
.
read
()
.
rstrip
()))
mode
=
set
(
modes
)
if
len
(
mode
)
!=
1
:
print
(
"Inconsistent transfer mode across devices"
)
raise
Exception
()
for
k
,
v
in
FmcTdc
.
TRANSFER_MODE
.
items
():
if
v
in
mode
:
pytest
.
transfer_mode
=
k
pytest
.
carrier
=
None
full_path
=
os
.
readlink
(
"/sys/bus/zio/devices/tdc-1n5c-{:04x}"
.
format
(
pytest
.
tdc_id
))
for
carr
in
[
"spec"
,
"svec"
]:
is_carr
=
re
.
search
(
carr
,
full_path
)
if
is_carr
is
not
None
:
carrs
=
[]
for
tdc_id
in
pytest
.
tdc_id
:
full_path
=
os
.
readlink
(
"/sys/bus/zio/devices/tdc-1n5c-{:04x}"
.
format
(
tdc_id
))
for
carr
in
[
"spec"
,
"svec"
]:
is_carr
=
re
.
search
(
carr
,
full_path
)
if
is_carr
is
None
:
continue
if
pytest
.
carrier
is
not
None
and
pytest
.
carrier
!=
carr
:
print
(
"Inconsistent installation mix of SPEC and SVEC"
)
raise
Exception
()
pytest
.
carrier
=
carr
pytest/test-01-functionalities/test_fmctdc_acquisition.py
View file @
55591c20
...
...
@@ -39,8 +39,8 @@ fmctdc_acq_100ns_svec = [(13333, 8000), # 75 kHz
fmctdc_acq_100ns
=
fmctdc_acq_100ns_svec
if
pytest
.
transfer_mode
==
"fifo"
else
fmctdc_acq_100ns_spec
@
pytest
.
fixture
(
scope
=
"function"
,
params
=
pytest
.
channels
)
def
fmctdc_chan
(
request
):
tdc
=
FmcTdc
(
pytest
.
tdc_id
)
def
fmctdc_chan
(
request
,
fmctdc
):
tdc
=
fmctdc
for
ch
in
tdc
.
chan
:
ch
.
enable
=
False
tdc
.
chan
[
request
.
param
]
.
termination
=
False
...
...
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