Files
slsDetectorPackage/tests/scripts/test_roi.py
Dhanya Thattil ae2e674772
All checks were successful
Build on RHEL9 / build (push) Successful in 3m0s
Build on RHEL8 / build (push) Successful in 5m9s
1001/python cmd for roi (#1362)
* added typecaster for slsdefs::ROI and added setter and getter for ROI

* API also allows single sequence for single ROI

* clear_rx_roi accessible from python API

* added tests

* release notes is a markdown file

* wrapped virtual detector setup in a test fixture

* updated release

* added colorama in github workflows

* disable user id and port test

* changed format to clang-format 17

* formatted with clang format 12

* fixed virtual detector test scripts

* Code Review

* another bug for xilinx in test script

* rx_roi also accepts sequence of 2 ints

* removed tests for eiger

---------

Co-authored-by: Alice <alice.mazzoleni@psi.ch>
2026-01-21 11:06:52 +01:00

83 lines
2.6 KiB
Python

# SPDX-License-Identifier: LGPL-3.0-or-other
# Copyright (C) 2021 Contributors to the SLS Detector Package
'''
This file is used to start up simulators, receivers and test roi for every detector in many configurations.
'''
import sys, time
import traceback
from slsdet import Detector, burstMode
from slsdet.defines import DEFAULT_TCP_RX_PORTNO, DEFAULT_UDP_DST_PORTNO
from datetime import timedelta
from utils_for_test import (
Log,
LogLevel,
RuntimeException,
cleanup,
startProcessInBackground,
startReceiver,
startDetectorVirtualServer,
connectToVirtualServers,
loadBasicSettings,
loadConfig,
runProcessWithLogFile
)
LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_roi_test'
MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt'
ROI_TEST_FNAME = LOG_PREFIX_FNAME + '_results_'
def startTestsForAll(fp):
servers = [
'eiger',
'jungfrau',
'mythen3',
'gotthard2',
'moench',
]
nmods = 2
for server in servers:
for ninterfaces in range(1, 2):
if ninterfaces == 2 and server != 'jungfrau' and server != 'moench':
continue
try:
msg = f'Starting Roi Tests for {server}'
if server == 'jungfrau' or server == 'moench':
msg += f' with {ninterfaces} interfaces'
Log(LogLevel.INFOBLUE, msg)
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=5, num_interfaces=ninterfaces)
loadBasicSettings(name=server, d=d, fp=fp)
fname = ROI_TEST_FNAME + server + '.txt'
cmd = ['tests', 'rx_roi', '--abort', '-s']
runProcessWithLogFile('Roi Tests for ' + server, cmd, fp, fname)
Log(LogLevel.INFO, '\n')
except Exception as e:
raise RuntimeException(f'Roi Tests failed') from e
Log(LogLevel.INFOGREEN, 'Passed all Roi tests for all detectors \n' + str(servers))
if __name__ == '__main__':
Log(LogLevel.INFOBLUE, '\nLog File: ' + MAIN_LOG_FNAME + '\n')
with open(MAIN_LOG_FNAME, 'w') as fp:
try:
startTestsForAll(fp)
#TODO: check master file as well for both json and hdf5 as well
cleanup(fp)
except Exception as e:
with open(MAIN_LOG_FNAME, 'a') as fp_error:
traceback.print_exc(file=fp_error)
cleanup(fp)
Log(LogLevel.ERROR, f'Tests Failed.')