mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 10:30:41 +02:00
integration test
This commit is contained in:
parent
04146e683c
commit
d00fd70d6d
@ -45,5 +45,5 @@ deploy:
|
||||
provider: script
|
||||
script: find $HOME/miniconda/conda-bld/${TRAVIS_OS_NAME}-64 -name "*.tar.bz2" -exec anaconda -t $CONDA_TOKEN upload --force {} \;
|
||||
on:
|
||||
all_branches: true
|
||||
branch: refactor
|
||||
|
||||
|
@ -63,20 +63,20 @@ outputs:
|
||||
- {{compiler('cxx')}}
|
||||
- python {{ python }}
|
||||
- setuptools
|
||||
- sls_detector_lib
|
||||
- sls_detector_lib=refactor
|
||||
- pyzmq
|
||||
- pybind11 2.2
|
||||
host:
|
||||
- python
|
||||
- pybind11 2.2
|
||||
- pyzmq
|
||||
- sls_detector_lib
|
||||
- sls_detector_lib=refactor
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
run:
|
||||
- python
|
||||
- numpy
|
||||
- sls_detector_lib
|
||||
- sls_detector_lib=refactor
|
||||
- pyzmq
|
||||
- libstdcxx-ng
|
||||
- libgcc-ng
|
||||
|
@ -1,43 +1,48 @@
|
||||
MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
|
||||
# MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
# MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
|
||||
|
||||
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/catch
|
||||
# include_directories(
|
||||
# ${PROJECT_SOURCE_DIR}/catch
|
||||
# )
|
||||
|
||||
target_sources(tests PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-integrationMulti.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/test-integrationDectector.cpp
|
||||
)
|
||||
|
||||
if(SLS_USE_TESTS)
|
||||
set(TEST_SOURCES
|
||||
src/test-slsDetector.cpp
|
||||
src/test.cpp
|
||||
)
|
||||
add_executable(detector_test ${TEST_SOURCES})
|
||||
# if(SLS_USE_TESTS)
|
||||
# set(TEST_SOURCES
|
||||
# src/test-slsDetector.cpp
|
||||
# src/test.cpp
|
||||
# )
|
||||
# add_executable(detector_test ${TEST_SOURCES})
|
||||
|
||||
target_link_libraries(detector_test
|
||||
slsDetectorShared
|
||||
slsProjectOptions
|
||||
slsProjectWarnings
|
||||
slsSupportLib
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
set_target_properties(detector_test PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
# target_link_libraries(detector_test
|
||||
# slsDetectorShared
|
||||
# slsProjectOptions
|
||||
# slsProjectWarnings
|
||||
# slsSupportLib
|
||||
# pthread
|
||||
# rt
|
||||
# )
|
||||
# set_target_properties(detector_test PROPERTIES
|
||||
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# )
|
||||
|
||||
add_executable(a src/a.cpp)
|
||||
target_link_libraries(a
|
||||
slsProjectOptions
|
||||
slsProjectWarnings
|
||||
slsDetectorShared
|
||||
slsSupportLib
|
||||
pthread
|
||||
rt
|
||||
)
|
||||
set_target_properties(a PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
)
|
||||
# add_executable(a src/a.cpp)
|
||||
# target_link_libraries(a
|
||||
# slsProjectOptions
|
||||
# slsProjectWarnings
|
||||
# slsDetectorShared
|
||||
# slsSupportLib
|
||||
# pthread
|
||||
# rt
|
||||
# )
|
||||
# set_target_properties(a PROPERTIES
|
||||
# RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
# )
|
||||
|
||||
endif()
|
||||
# endif()
|
||||
|
||||
|
9
integrationTests/config.h
Normal file
9
integrationTests/config.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
struct SingleDetectorConfig {
|
||||
slsDetectorDefs::detectorType type_enum =
|
||||
slsDetectorDefs::detectorType::EIGER;
|
||||
const std::string hostname = "beb083";
|
||||
const std::string type_string = "Eiger";
|
||||
const std::string my_ip = "129.129.205.242";
|
||||
};
|
@ -12,25 +12,24 @@
|
||||
#include <vector>
|
||||
#define VERBOSE
|
||||
|
||||
auto type_enum = slsDetectorDefs::detectorType::EIGER;
|
||||
const std::string hostname = "beb083";
|
||||
const std::string type_string = "Eiger";
|
||||
const std::string my_ip = "129.129.205.242";
|
||||
//Header holding all configurations for different detectors
|
||||
#include "config.h"
|
||||
|
||||
TEST_CASE("single EIGER detector no receiver basic set and get") {
|
||||
TEST_CASE("single EIGER detector no receiver basic set and get", "[.integration]") {
|
||||
//TODO! this test should take command line arguments for config
|
||||
SingleDetectorConfig c;
|
||||
|
||||
//Read type by connecting to the detector
|
||||
auto type = slsDetector::getTypeFromDetector(hostname);
|
||||
CHECK(type == type_enum);
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
CHECK(type == c.type_enum);
|
||||
|
||||
//Create slsDetector of said type and set hostname and detector online
|
||||
slsDetector d(type);
|
||||
CHECK(d.getDetectorTypeAsEnum() == type);
|
||||
CHECK(d.getDetectorTypeAsString() == type_string);
|
||||
CHECK(d.getDetectorTypeAsString() == c.type_string);
|
||||
|
||||
d.setHostname(hostname);
|
||||
CHECK(d.getHostname() == hostname);
|
||||
d.setHostname(c.hostname);
|
||||
CHECK(d.getHostname() == c.hostname);
|
||||
|
||||
d.setOnline(true);
|
||||
CHECK(d.getOnlineFlag() == true);
|
||||
@ -65,7 +64,8 @@ TEST_CASE("single EIGER detector no receiver basic set and get") {
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Set control port then create a new object with this control port") {
|
||||
TEST_CASE("Set control port then create a new object with this control port",
|
||||
"[.integration]") {
|
||||
/*
|
||||
TODO!
|
||||
Standard port but should not be hardcoded
|
||||
@ -76,12 +76,12 @@ TEST_CASE("Set control port then create a new object with this control port") {
|
||||
int old_sport = DEFAULT_PORTNO + 1;
|
||||
int new_cport = 1993;
|
||||
int new_sport = 2000;
|
||||
|
||||
SingleDetectorConfig c;
|
||||
{
|
||||
auto type = slsDetector::getTypeFromDetector(hostname);
|
||||
CHECK(type == type_enum);
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
CHECK(type == c.type_enum);
|
||||
slsDetector d(type);
|
||||
d.setHostname(hostname);
|
||||
d.setHostname(c.hostname);
|
||||
d.setOnline(true);
|
||||
CHECK(d.getControlPort() == old_cport);
|
||||
d.setControlPort(new_cport);
|
||||
@ -90,10 +90,10 @@ TEST_CASE("Set control port then create a new object with this control port") {
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
{
|
||||
auto type = slsDetector::getTypeFromDetector(hostname, new_cport);
|
||||
CHECK(type == type_enum);
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname, new_cport);
|
||||
CHECK(type == c.type_enum);
|
||||
slsDetector d(type);
|
||||
d.setHostname(hostname);
|
||||
d.setHostname(c.hostname);
|
||||
d.setControlPort(new_cport);
|
||||
d.setStopPort(new_sport);
|
||||
CHECK(d.getControlPort() == new_cport);
|
||||
@ -107,18 +107,20 @@ TEST_CASE("Set control port then create a new object with this control port") {
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
auto type = slsDetector::getTypeFromDetector(hostname);
|
||||
CHECK(type == type_enum);
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
CHECK(type == c.type_enum);
|
||||
slsDetector d(type);
|
||||
d.setHostname(hostname);
|
||||
d.setHostname(c.hostname);
|
||||
d.setOnline(true);
|
||||
CHECK(d.getStopPort() == DEFAULT_PORTNO + 1);
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Locking mechanism and last ip") {
|
||||
auto type = slsDetector::getTypeFromDetector(hostname);
|
||||
TEST_CASE("Locking mechanism and last ip", "[.integration]") {
|
||||
SingleDetectorConfig c;
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
slsDetector d(type);
|
||||
d.setHostname(hostname);
|
||||
d.setHostname(c.hostname);
|
||||
d.setOnline(true);
|
||||
|
||||
//Check that detector server is unlocked then lock
|
||||
@ -126,19 +128,20 @@ TEST_CASE("Locking mechanism and last ip") {
|
||||
d.lockServer(1);
|
||||
CHECK(d.lockServer() == 1);
|
||||
|
||||
//Can we do things while it is locked
|
||||
//Can we still access the detector while it's locked
|
||||
auto t = 1300000000;
|
||||
d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t);
|
||||
CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t);
|
||||
|
||||
//unlock again
|
||||
//unlock again and free
|
||||
d.lockServer(0);
|
||||
CHECK(d.lockServer() == 0);
|
||||
|
||||
CHECK(d.getLastClientIP() == my_ip);
|
||||
CHECK(d.getLastClientIP() == c.my_ip);
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
TEST_CASE("Excersise all possible set timer functions") {
|
||||
TEST_CASE("Excersise all possible set timer functions", "[.integration]") {
|
||||
// FRAME_NUMBER, /**< number of real time frames: total number of acquisitions is number or frames*number of cycles */
|
||||
// ACQUISITION_TIME, /**< exposure time */
|
||||
// FRAME_PERIOD, /**< period between exposures */
|
||||
@ -159,10 +162,10 @@ TEST_CASE("Excersise all possible set timer functions") {
|
||||
// MEASURED_PERIOD, /**< measured period */
|
||||
// MEASURED_SUBPERIOD, /**< measured subperiod */
|
||||
// MAX_TIMERS
|
||||
|
||||
auto type = slsDetector::getTypeFromDetector(hostname);
|
||||
SingleDetectorConfig c;
|
||||
auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
slsDetector d(type);
|
||||
d.setHostname(hostname);
|
||||
d.setHostname(c.hostname);
|
||||
d.setOnline(true);
|
||||
|
||||
//Number of frames
|
||||
@ -194,6 +197,28 @@ TEST_CASE("Excersise all possible set timer functions") {
|
||||
auto subtime = 200;
|
||||
d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME, subtime);
|
||||
CHECK(d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) == subtime);
|
||||
|
||||
d.freeSharedMemory();
|
||||
}
|
||||
|
||||
// TEST_CASE()
|
||||
// TEST_CASE("Aquire", "[.integration][eiger]"){
|
||||
// SingleDetectorConfig c;
|
||||
// auto type = slsDetector::getTypeFromDetector(c.hostname);
|
||||
// slsDetector d(type);
|
||||
// d.setHostname(c.hostname);
|
||||
// d.setOnline(true);
|
||||
|
||||
// auto period = 1000000000;
|
||||
// auto exptime = 100000000;
|
||||
// d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, 5);
|
||||
// d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, exptime);
|
||||
// d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period);
|
||||
// d.startAndReadAll();
|
||||
|
||||
|
||||
|
||||
// auto rperiod = d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD);
|
||||
// CHECK(rperiod == 0.1);
|
||||
|
||||
// d.freeSharedMemory();
|
||||
// }
|
@ -845,7 +845,7 @@ int slsDetector::execCommand(const std::string &cmd) {
|
||||
if (detector_shm()->onlineFlag == ONLINE_FLAG) {
|
||||
auto client = DetectorSocket(detector_shm()->hostname, detector_shm()->controlPort);
|
||||
ret = client.sendCommandThenRead(fnum, arg, sizeof(arg), retval, sizeof(retval));
|
||||
if (strlen(retval)) {
|
||||
if (strlen(retval) != 0u) {
|
||||
FILE_LOG(logINFO) << "Detector " << detId << " returned:\n" << retval;
|
||||
}
|
||||
}
|
||||
@ -871,7 +871,7 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
|
||||
if ((detector_shm()->myDetectorType != CHIPTESTBOARD) &&
|
||||
(detector_shm()->myDetectorType != MOENCH)) {
|
||||
n += client.receiveData(&i32, sizeof(i32));
|
||||
detector_shm()->currentSettings = (detectorSettings)i32;
|
||||
detector_shm()->currentSettings = static_cast<detectorSettings>(i32);
|
||||
}
|
||||
|
||||
// threshold
|
||||
@ -925,7 +925,7 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
|
||||
if (detector_shm()->myDetectorType == EIGER ||
|
||||
detector_shm()->myDetectorType == CHIPTESTBOARD) {
|
||||
n += client.receiveData(&i32, sizeof(i32));
|
||||
detector_shm()->roFlags = (readOutFlags)i32;
|
||||
detector_shm()->roFlags = static_cast<readOutFlags>(i32);
|
||||
}
|
||||
|
||||
// samples
|
||||
@ -965,7 +965,7 @@ int slsDetector::updateDetectorNoWait(sls::ClientSocket &client) {
|
||||
updateTotalNumberOfChannels();
|
||||
}
|
||||
|
||||
if (!n) {
|
||||
if (n == 0) {
|
||||
FILE_LOG(logERROR) << "Could not update detector, received 0 bytes";
|
||||
}
|
||||
|
||||
@ -2973,7 +2973,7 @@ int slsDetector::writeAdcRegister(int addr, int val) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
int slsDetector::activate(int const enable) {
|
||||
int slsDetector::activate(int enable) {
|
||||
int fnum = F_ACTIVATE;
|
||||
int ret = FAIL;
|
||||
int arg = enable;
|
||||
@ -3400,7 +3400,7 @@ int slsDetector::powerChip(int ival) {
|
||||
FILE_LOG(logDEBUG1) << "Power chip: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateDetector();
|
||||
updateDetector();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -3418,7 +3418,7 @@ int slsDetector::setAutoComparatorDisableMode(int ival) {
|
||||
FILE_LOG(logDEBUG1) << "Auto comp disable: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateDetector();
|
||||
updateDetector();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -3430,7 +3430,7 @@ int slsDetector::getChanRegs(double *retval) {
|
||||
|
||||
if (myMod != nullptr) {
|
||||
// the original array has 0 initialized
|
||||
if (myMod->chanregs) {
|
||||
if (myMod->chanregs != nullptr) {
|
||||
for (int i = 0; i < n; ++i) {
|
||||
retval[i] = (double)(myMod->chanregs[i] & TRIMBITMASK);
|
||||
}
|
||||
@ -3529,7 +3529,7 @@ int64_t slsDetector::getRateCorrection() {
|
||||
FILE_LOG(logDEBUG1) << "Rate correction: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateDetector();
|
||||
updateDetector();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -3549,20 +3549,18 @@ void slsDetector::printReceiverConfiguration(TLogLevel level) {
|
||||
int slsDetector::setReceiverOnline(int value) {
|
||||
if (value != GET_ONLINE_FLAG) {
|
||||
// no receiver
|
||||
if (!strcmp(detector_shm()->receiver_hostname, "none")) {
|
||||
if (strcmp(detector_shm()->receiver_hostname, "none") == 0) {
|
||||
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
||||
} else {
|
||||
detector_shm()->receiverOnlineFlag = OFFLINE_FLAG;
|
||||
|
||||
// set online
|
||||
if (value == ONLINE_FLAG) {
|
||||
|
||||
// connect and set offline flag
|
||||
auto receiver = ReceiverSocket(detector_shm()->receiver_hostname,
|
||||
detector_shm()->receiverTCPPort);
|
||||
receiver.close();
|
||||
detector_shm()->receiverOnlineFlag = ONLINE_FLAG;
|
||||
// check for version compatibility
|
||||
if (detector_shm()->receiverAPIVersion == 0) {
|
||||
checkReceiverVersionCompatibility();
|
||||
}
|
||||
@ -3600,7 +3598,7 @@ int slsDetector::lockReceiver(int lock) {
|
||||
FILE_LOG(logDEBUG1) << "Receiver Lock: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateCachedReceiverVariables();
|
||||
updateCachedReceiverVariables();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -3618,7 +3616,7 @@ std::string slsDetector::getReceiverLastClientIP() {
|
||||
FILE_LOG(logDEBUG1) << "Last client IP to receiver: " << retval;
|
||||
}
|
||||
if (ret == FORCE_UPDATE) {
|
||||
ret = updateCachedReceiverVariables();
|
||||
updateCachedReceiverVariables();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@ -3690,7 +3688,7 @@ int slsDetector::updateCachedReceiverVariables() const {
|
||||
|
||||
// file format
|
||||
n += receiver.receiveData(&i32, sizeof(i32));
|
||||
detector_shm()->rxFileFormat = (fileFormat)i32;
|
||||
detector_shm()->rxFileFormat = static_cast<fileFormat>(i32);
|
||||
|
||||
// frames per file
|
||||
n += receiver.receiveData(&i32, sizeof(i32));
|
||||
@ -3698,7 +3696,7 @@ int slsDetector::updateCachedReceiverVariables() const {
|
||||
|
||||
// frame discard policy
|
||||
n += receiver.receiveData(&i32, sizeof(i32));
|
||||
detector_shm()->receiver_frameDiscardMode = (frameDiscardPolicy)i32;
|
||||
detector_shm()->receiver_frameDiscardMode = static_cast<frameDiscardPolicy>(i32);
|
||||
|
||||
// frame padding
|
||||
n += receiver.receiveData(&i32, sizeof(i32));
|
||||
|
Loading…
x
Reference in New Issue
Block a user