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
417558f4
Commit
417558f4
authored
Nov 08, 2023
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tst: allow users to set the slot number
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
78bc0498
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
1 deletion
+48
-1
conftest.py
software/pytest/conftest.py
+48
-1
No files found.
software/pytest/conftest.py
View file @
417558f4
...
...
@@ -3,8 +3,47 @@ SPDX-License-Identifier: LGPL-2.1-or-later
SPDX-FileCopyrightText: 2020 CERN
"""
from
pathlib
import
Path
import
pytest
from
PyFmcFineDelay
import
FmcFineDelay
import
re
def
valid_slot_type
(
slot
):
if
re
.
search
(
r"(VME|PCI)\.[0-9]+-FMC\.[0-9]+"
,
slot
)
is
None
:
raise
ValueError
()
return
slot
def
fmcfd_id_from_slot
(
slot
):
carrier
,
mezzanine
=
slot
.
split
(
"-"
)
carrier_bus
,
carrier_slot
=
carrier
.
split
(
"."
)
carrier_slot
=
int
(
carrier_slot
)
mezzanine_bus
,
mezzanine_slot
=
mezzanine
.
split
(
"."
)
mezzanine_slot
=
int
(
mezzanine_slot
)
if
carrier_bus
==
"PCI"
:
with
open
(
"/run/dynpci"
)
as
f
:
for
line
in
f
.
readlines
():
dynslot
,
pciid
=
line
.
strip
()
.
split
(
" "
)
if
int
(
dynslot
)
==
carrier_slot
:
break
pciid
=
f
"0000:{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}"
)
\
.
glob
(
f
"svec-*/svec-*/id:*/fmc-fdelay-tdc.*.auto/fmc-slot-*.{mezzanine_slot}"
))
else
:
raise
ValueError
()
assert
len
(
pathfmc
)
==
1
devname
=
list
(
Path
(
pathfmc
[
0
])
.
parent
.
glob
(
"hw-fd-*/fd-*/devname"
))
assert
len
(
devname
)
==
1
with
open
(
devname
[
0
])
as
f
:
fd_id
=
int
(
f
.
read
()
.
strip
()
.
split
(
"-"
)[
1
],
16
)
return
fd_id
@
pytest
.
fixture
(
scope
=
"function"
)
...
...
@@ -16,13 +55,21 @@ def fmcfd():
def
pytest_addoption
(
parser
):
parser
.
addoption
(
"--fd-id"
,
type
=
lambda
x
:
int
(
x
,
16
),
required
=
True
,
help
=
"Fmc Fine-Delay Linux Identifier"
)
default
=
None
,
help
=
"Fmc Fine-Delay Linux Identifier"
)
parser
.
addoption
(
"--slot"
,
type
=
valid_slot_type
,
default
=
None
,
help
=
"Fmc Fine-Delay absolute slot (works only for SPEC and SVEC)"
)
parser
.
addoption
(
"--channel"
,
type
=
int
,
default
=
[],
action
=
"append"
,
choices
=
range
(
FmcFineDelay
.
CHANNEL_NUMBER
),
help
=
"Channel(s) to be used for acquisition tests. Default all channels"
)
def
pytest_configure
(
config
):
pytest
.
fd_id
=
config
.
getoption
(
"--fd-id"
)
if
pytest
.
fd_id
is
None
:
pytest
.
slot
=
config
.
getoption
(
"--slot"
)
if
pytest
.
slot
is
None
:
print
(
"Missing argument --fd-id or --slot"
)
raise
Exception
()
pytest
.
fd_id
=
fmcfd_id_from_slot
(
pytest
.
slot
)
pytest
.
channels
=
config
.
getoption
(
"--channel"
)
if
len
(
pytest
.
channels
)
==
0
:
pytest
.
channels
=
range
(
FmcFineDelay
.
CHANNEL_NUMBER
)
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