mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-12-22 20:31:19 +01:00
Compare commits
4 Commits
fix/remove
...
fix/pyfixt
| Author | SHA1 | Date | |
|---|---|---|---|
| d137b31776 | |||
| 223355c4b9 | |||
| 7d1d5e9809 | |||
|
|
cfaaf5a973 |
@@ -29,7 +29,6 @@ Checks: '*,
|
|||||||
-llvmlibc-*'
|
-llvmlibc-*'
|
||||||
|
|
||||||
HeaderFilterRegex: \.h
|
HeaderFilterRegex: \.h
|
||||||
AnalyzeTemporaryDtors: false
|
|
||||||
FormatStyle: none
|
FormatStyle: none
|
||||||
CheckOptions:
|
CheckOptions:
|
||||||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
|
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
|
||||||
|
|||||||
@@ -41,15 +41,16 @@ def pytest_collection_modifyitems(config, items):
|
|||||||
#helper fixture for servers
|
#helper fixture for servers
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def servers(request):
|
def servers(request):
|
||||||
|
""" Fixture to get server and num interaface from test marker. """
|
||||||
try:
|
try:
|
||||||
return request.param # comes from @pytest.mark.parametrize(..., indirect=True)
|
return request.param # comes from @pytest.mark.parametrize(..., indirect=True)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
# fallback default if the test did not parametrize
|
# fallback default if the test did not parametrize
|
||||||
return ['eiger', 'jungfrau', 'mythen3', 'gotthard2', 'ctb', 'moench', 'xilinx_ctb']
|
return [['eiger', 1], ['jungfrau', 1], ['jungfrau', 2], ['mythen3',1], ['gotthard2',1], ['ctb',1], ['moench',1], ['moench',2],['xilinx_ctb',1]]
|
||||||
return request.param
|
return request.param
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture()
|
||||||
def test_with_simulators(servers):
|
def test_with_specific_simulator(servers):
|
||||||
""" Fixture to automatically setup virtual detector servers for testing. """
|
""" Fixture to automatically setup virtual detector servers for testing. """
|
||||||
|
|
||||||
LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_PythonAPI_test'
|
LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_PythonAPI_test'
|
||||||
@@ -58,23 +59,50 @@ def test_with_simulators(servers):
|
|||||||
with open(MAIN_LOG_FNAME, 'w') as fp:
|
with open(MAIN_LOG_FNAME, 'w') as fp:
|
||||||
try:
|
try:
|
||||||
nmods = 2
|
nmods = 2
|
||||||
for server in servers:
|
server, ninterface = servers
|
||||||
for ninterfaces in range(1,2):
|
msg = f'Starting Python API Tests for {server}'
|
||||||
if ninterfaces == 2 and server != 'jungfrau' and server != 'moench':
|
|
||||||
continue
|
|
||||||
|
|
||||||
msg = f'Starting Python API Tests for {server}'
|
if server == 'jungfrau' or server == 'moench':
|
||||||
|
msg += f' with {ninterface} interfaces'
|
||||||
|
|
||||||
if server == 'jungfrau' or server == 'moench':
|
Log(LogLevel.INFOBLUE, msg, fp)
|
||||||
msg += f' with {ninterfaces} interfaces'
|
cleanup(fp)
|
||||||
|
startDetectorVirtualServer(server, nmods, fp)
|
||||||
|
startReceiver(nmods, fp)
|
||||||
|
d = loadConfig(name=server, log_file_fp=fp, num_mods=nmods, num_frames=1, num_interfaces=ninterface)
|
||||||
|
loadBasicSettings(name=server, d=d, fp=fp)
|
||||||
|
yield # run test
|
||||||
|
cleanup(fp) # teardown
|
||||||
|
except Exception as e:
|
||||||
|
with open(MAIN_LOG_FNAME, 'a') as fp_error:
|
||||||
|
traceback.print_exc(file=fp_error)
|
||||||
|
Log(LogLevel.ERROR, f'Tests Failed.', fp)
|
||||||
|
cleanup(fp)
|
||||||
|
|
||||||
Log(LogLevel.INFOBLUE, msg, fp)
|
@pytest.fixture(scope="module", params=[['eiger', 1], ['jungfrau', 1], ['jungfrau', 2], ['mythen3',1], ['gotthard2',1], ['ctb',1], ['moench',1], ['moench',2],['xilinx_ctb',1]])
|
||||||
cleanup(fp)
|
def test_with_simulators(request):
|
||||||
startDetectorVirtualServer(server, nmods, fp)
|
""" Fixture to automatically setup virtual detector servers for testing. """
|
||||||
startReceiver(nmods, fp)
|
|
||||||
d = loadConfig(name=server, log_file_fp=fp, num_mods=nmods, num_frames=1, num_interfaces=ninterfaces)
|
LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_PythonAPI_test'
|
||||||
loadBasicSettings(name=server, d=d, fp=fp)
|
MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt'
|
||||||
yield # run test
|
|
||||||
|
server, ninterfaces = request.param
|
||||||
|
|
||||||
|
with open(MAIN_LOG_FNAME, 'w') as fp:
|
||||||
|
try:
|
||||||
|
nmods = 2
|
||||||
|
msg = f'Starting Python API Tests for {server}'
|
||||||
|
|
||||||
|
if server == 'jungfrau' or server == 'moench':
|
||||||
|
msg += f' with {ninterfaces} interfaces'
|
||||||
|
|
||||||
|
Log(LogLevel.INFOBLUE, msg, fp)
|
||||||
|
cleanup(fp)
|
||||||
|
startDetectorVirtualServer(server, nmods, fp)
|
||||||
|
startReceiver(nmods, fp)
|
||||||
|
d = loadConfig(name=server, log_file_fp=fp, num_mods=nmods, num_frames=1, num_interfaces=ninterfaces)
|
||||||
|
loadBasicSettings(name=server, d=d, fp=fp)
|
||||||
|
yield # run test
|
||||||
cleanup(fp) # teardown
|
cleanup(fp) # teardown
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
with open(MAIN_LOG_FNAME, 'a') as fp_error:
|
with open(MAIN_LOG_FNAME, 'a') as fp_error:
|
||||||
|
|||||||
@@ -5,44 +5,67 @@ from conftest import test_with_simulators
|
|||||||
|
|
||||||
from slsdet import Detector
|
from slsdet import Detector
|
||||||
|
|
||||||
@pytest.mark.withdetectorsimulators
|
from slsdet._slsdet import slsDetectorDefs
|
||||||
@pytest.mark.parametrize("servers", [["moench"]], indirect=True)
|
|
||||||
def test_rx_ROI_moench(test_with_simulators, servers):
|
|
||||||
""" Test setting and getting rx_ROI property of Detector class for moench. """
|
|
||||||
|
|
||||||
d = Detector()
|
|
||||||
d.rx_roi = (0, 10, 10, 20)
|
|
||||||
roi = d.rx_roi
|
|
||||||
assert roi == [(0, 10, 10, 20)]
|
|
||||||
|
|
||||||
d.rx_roi = [5,15,15,25]
|
detectorType = slsDetectorDefs.detectorType
|
||||||
|
|
||||||
assert d.rx_roi == [(5,15,15,25)]
|
|
||||||
|
|
||||||
d.rx_roi = [[0,10,0,20], [5,20,410,420]]
|
|
||||||
|
|
||||||
roi = d.rx_roi
|
|
||||||
assert roi == [(0,10,0,20), (5,20,410,420)]
|
|
||||||
|
|
||||||
d.rx_clearroi()
|
|
||||||
roi = d.rx_roi
|
|
||||||
assert roi == [(-1,-1,-1,-1)]
|
|
||||||
|
|
||||||
@pytest.mark.withdetectorsimulators
|
@pytest.mark.withdetectorsimulators
|
||||||
@pytest.mark.parametrize("servers", [["mythen3"]], indirect=True)
|
def test_rx_ROI(test_with_simulators):
|
||||||
def test_rx_ROI_mythen(test_with_simulators, servers):
|
""" Test rx_ROI property of Detector class. """
|
||||||
""" Test setting and getting rx_ROI property of Detector class for mythen. """
|
|
||||||
|
|
||||||
d = Detector()
|
d = Detector()
|
||||||
d.rx_roi = (0, 10)
|
if d.type == detectorType.CHIPTESTBOARD or d.type == detectorType.XILINX_CHIPTESTBOARD:
|
||||||
roi = d.rx_roi
|
pytest.skip("Skipping ROI test for ctb/xilinx_ctb detector types.")
|
||||||
assert roi == [(0, 10, -1, -1)]
|
|
||||||
|
|
||||||
#d.rx_roi = [[5,15, 0, 1]] # not allowed for mythen3
|
if(d.type == detectorType.MYTHEN3 or d.type == detectorType.GOTTHARD2):
|
||||||
|
d.rx_roi = (0, 10)
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(0, 10, -1, -1)]
|
||||||
|
|
||||||
|
#d.rx_roi = [[5,15, 0, 1]] # not allowed for mythen3
|
||||||
|
|
||||||
|
d.rx_roi = [0,10, -1, -1]
|
||||||
|
|
||||||
|
assert d.rx_roi == [(0,10,-1,-1)]
|
||||||
|
d.rx_clearroi()
|
||||||
|
else:
|
||||||
|
|
||||||
|
d.rx_roi = (0, 10, 10, 20)
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(0, 10, 10, 20)]
|
||||||
|
|
||||||
|
d.rx_roi = [5,15,15,25]
|
||||||
|
|
||||||
|
assert d.rx_roi == [(5,15,15,25)]
|
||||||
|
|
||||||
|
if d.type != detectorType.JUNGFRAU and d.numinterfaces != 2:
|
||||||
|
d.rx_roi = [[0,10,0,20], [5,20,410,420]]
|
||||||
|
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(0,10,0,20), (5,20,410,420)] #in same file for jungfrau
|
||||||
|
|
||||||
|
d.rx_clearroi()
|
||||||
|
roi = d.rx_roi
|
||||||
|
assert roi == [(-1,-1,-1,-1)]
|
||||||
|
|
||||||
|
@pytest.mark.withdetectorsimulators
|
||||||
|
@pytest.mark.parametrize("servers", [["moench", 1]], indirect=True)
|
||||||
|
def test_type(test_with_specific_simulator):
|
||||||
|
|
||||||
|
d = Detector()
|
||||||
|
assert d.type == detectorType.MOENCH
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.withdetectorsimulators
|
||||||
|
@pytest.mark.parametrize("servers", [["moench", 1], ["jungfrau", 1]], indirect=True)
|
||||||
|
def test_numinterfaces(test_with_specific_simulator):
|
||||||
|
|
||||||
|
d = Detector()
|
||||||
|
assert d.numinterfaces == 1
|
||||||
|
|
||||||
d.rx_roi = [0,10, -1, -1]
|
|
||||||
|
|
||||||
assert d.rx_roi == [(0,10,-1,-1)]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -804,6 +804,8 @@ typedef struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sls_detector_module &operator=(const sls_detector_module &other) {
|
sls_detector_module &operator=(const sls_detector_module &other) {
|
||||||
|
if(this == &other)
|
||||||
|
return *this;
|
||||||
delete[] dacs;
|
delete[] dacs;
|
||||||
delete[] chanregs;
|
delete[] chanregs;
|
||||||
serialnumber = other.serialnumber;
|
serialnumber = other.serialnumber;
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp
|
|||||||
d.numinterfaces = num_interfaces
|
d.numinterfaces = num_interfaces
|
||||||
|
|
||||||
d.udp_dstport = DEFAULT_UDP_DST_PORTNO
|
d.udp_dstport = DEFAULT_UDP_DST_PORTNO
|
||||||
if name == 'eiger' or name == 'jungfrau' or name == 'moench':
|
if name == 'eiger' or num_interfaces > 1:
|
||||||
d.udp_dstport2 = DEFAULT_UDP_DST_PORTNO + 1
|
d.udp_dstport2 = DEFAULT_UDP_DST_PORTNO + 1
|
||||||
|
|
||||||
d.rx_hostname = rx_hostname
|
d.rx_hostname = rx_hostname
|
||||||
@@ -223,7 +223,7 @@ def loadConfig(name, rx_hostname = 'localhost', settingsdir = None, log_file_fp
|
|||||||
if name != "eiger":
|
if name != "eiger":
|
||||||
d.udp_srcip = 'auto'
|
d.udp_srcip = 'auto'
|
||||||
|
|
||||||
if name == "jungfrau" or name == "moench":
|
if num_interfaces > 1:
|
||||||
d.udp_dstip2 = 'auto'
|
d.udp_dstip2 = 'auto'
|
||||||
|
|
||||||
if name == "jungfrau" or name == "moench" or name == "xilinx_ctb":
|
if name == "jungfrau" or name == "moench" or name == "xilinx_ctb":
|
||||||
|
|||||||
Reference in New Issue
Block a user