mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-02-08 14:58:41 +01:00
readout speed added to json and h5 master files. Also fixed master file inconsistencies Sserver binaries - update server binaries because readoutspeed needs to be sent to receiver with rx_hostname command API - added const to Detector class set/getburstmode Python - updated python bindings (burstmode const and roi arguments) Cmd generation - added pragma once in Caller.in.h as Caller is included in test files m3: num channels due to #counters < 3 * workaround for m3 for messed up num channels (client always assumes all counters enabled and adds them to num channels), fix for hdf5 g2: exptime master file inconsistency - exptime didnt match because of round of when setting burst mode (sets to a different clk divider) - so updating actual time for all timers (exptime, period, subexptime etc, ) in Module class, get timer values from detector when setting it and then send to receiver to write in master file ctb image size incorrect: - write actual size into master file and not the reserved size (digital reduces depending on dbit list and dbit offset) - added a calculate ctb image size free function in generalData.h that is used there as well as for the tests. master file inconsistencies - refactored master attributes writing using templates - names changed to keep it consistent between json and hdf5 master file (Version, Pixels, Exposure Times, GateDelays, Acquisition Period, etc.) - datatypes changed to keep it simple where possible: imageSize, dynamicRange, tengiga, quad, readnrows, analog, analogsamples, digital, digitalsamples, dbitreorder, dbitoffset, transceivermask, transeiver, transceiversamples, countermask, gates =>int - replacing "toString" with arrays, objects etc for eg for scan, rois, etc. - json header always written (empty dataset or empty brackets) - hdf5 needs const char* so have to convert strings to it, but taking care that strings exist prior to push_back - master attributes (redundant string literals->error prone tests for master file - suppressed deprecated functions in rapidjson warnings just for the tests - added slsREceiverSoftware/src to allow access to receiver_defs.h to test binary/hdf5 version - refactored acquire tests by moving all the acquire tests from individual detector type files to a single one=test-Caller-acquire.cpp - set some default settings (loadBasicSettings) for a basic acquire at load config part for the test_simulator python scripts. so minimum number of settings for detector to be set for any acquire tests. - added tests to test master files for json and hdf5= test-Caller-master-attributes.cpp - added option to add '-m' markers for tests using test_simulator python script
92 lines
3.1 KiB
Python
92 lines
3.1 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 run all the tests on them and finally kill the simulators and receivers.
|
|
'''
|
|
import argparse
|
|
import sys, subprocess, time, traceback
|
|
|
|
from slsdet import Detector
|
|
from slsdet.defines import DEFAULT_TCP_RX_PORTNO
|
|
|
|
from utils_for_test import (
|
|
Log,
|
|
LogLevel,
|
|
RuntimeException,
|
|
checkIfProcessRunning,
|
|
killProcess,
|
|
cleanup,
|
|
cleanSharedmemory,
|
|
startProcessInBackground,
|
|
runProcessWithLogFile,
|
|
startDetectorVirtualServer,
|
|
loadConfig,
|
|
loadBasicSettings,
|
|
ParseArguments
|
|
)
|
|
|
|
|
|
LOG_PREFIX_FNAME = '/tmp/slsDetectorPackage_virtual_test'
|
|
MAIN_LOG_FNAME = LOG_PREFIX_FNAME + '_log.txt'
|
|
GENERAL_TESTS_LOG_FNAME = LOG_PREFIX_FNAME + '_results_general.txt'
|
|
CMD_TEST_LOG_PREFIX_FNAME = LOG_PREFIX_FNAME + '_results_cmd_'
|
|
|
|
|
|
def startReceiver(num_mods, fp):
|
|
if num_mods == 1:
|
|
cmd = ['slsReceiver']
|
|
else:
|
|
cmd = ['slsMultiReceiver', str(DEFAULT_TCP_RX_PORTNO), str(num_mods)]
|
|
# in 10.0.0
|
|
#cmd = ['slsMultiReceiver', '-p', str(DEFAULT_TCP_RX_PORTNO), '-n', str(num_mods)]
|
|
startProcessInBackground(cmd, fp)
|
|
time.sleep(1)
|
|
|
|
def startGeneralTests(fp):
|
|
fname = GENERAL_TESTS_LOG_FNAME
|
|
cmd = ['tests', '--abort', '-s']
|
|
try:
|
|
cleanup(fp)
|
|
runProcessWithLogFile('General Tests', cmd, fp, fname)
|
|
except Exception as e:
|
|
raise RuntimeException(f'General tests failed.') from e
|
|
|
|
|
|
def startCmdTestsForAll(args, fp):
|
|
for server in args.servers:
|
|
try:
|
|
num_mods = 2 if server == 'eiger' else 1
|
|
fname = CMD_TEST_LOG_PREFIX_FNAME + server + '.txt'
|
|
cmd = ['tests', '--abort', args.markers, '-s']
|
|
|
|
Log(LogLevel.INFOBLUE, f'Starting Cmd Tests for {server}')
|
|
cleanup(fp)
|
|
startDetectorVirtualServer(name=server, num_mods=num_mods, fp=fp)
|
|
startReceiver(num_mods, fp)
|
|
d = loadConfig(name=server, rx_hostname=args.rx_hostname, settingsdir=args.settingspath, fp=fp, num_mods=num_mods)
|
|
loadBasicSettings(name=server, d=d, fp=fp)
|
|
runProcessWithLogFile('Cmd Tests (' + args.markers + ') for ' + server, cmd, fp, fname)
|
|
except Exception as e:
|
|
raise RuntimeException(f'Cmd Tests failed for {server}.') from e
|
|
|
|
Log(LogLevel.INFOGREEN, 'Passed all tests for all detectors \n' + str(args.servers))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
args = ParseArguments('Automated tests with the virtual detector servers', 1, 1)
|
|
if args.num_mods > 1:
|
|
raise RuntimeException(f'Cannot support multiple modules at the moment (except Eiger).')
|
|
|
|
Log(LogLevel.INFOBLUE, '\nLog File: ' + MAIN_LOG_FNAME + '\n')
|
|
|
|
with open(MAIN_LOG_FNAME, 'w') as fp:
|
|
try:
|
|
startGeneralTests(fp)
|
|
startCmdTestsForAll(args, fp)
|
|
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.')
|