Files
slsDetectorPackage/slsDetectorSoftware/tests/test-Module.cpp
Dhanya Thattil fff5fa73be
Some checks failed
Build on RHEL9 / build (push) Failing after 3m41s
Build on RHEL8 / build (push) Failing after 5m10s
Dev/verify shm (#1276)
* removed verify, update, fixed getUser to be a free function, generated commands, python bindings yet to do

* python bindings

* fixed tests

* minor

* minor

* format
2025-08-23 10:23:27 +02:00

80 lines
2.3 KiB
C++

// SPDX-License-Identifier: LGPL-3.0-or-other
// Copyright (C) 2021 Contributors to the SLS Detector Package
#include "Detector.h"
#include "Module.h"
#include "SharedMemory.h"
#include "catch.hpp"
namespace sls {
using dt = slsDetectorDefs::detectorType;
TEST_CASE("Construction with a defined detector type") {
freeSharedMemory(0, 0); // clean up to start test
Module m(dt::EIGER);
REQUIRE(m.getDetectorType() == dt::EIGER);
freeSharedMemory(0, 0); // clean up
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Read back detector type from shm") {
// Create specific detector in order to create shm
Module m(dt::JUNGFRAU);
// New detector that reads type from shm
Module m2;
REQUIRE(m2.getDetectorType() == dt::JUNGFRAU);
// Now both objects point to the same shm so we can only
// free one!
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Is shm fixed pattern shm compatible") {
Module m(dt::JUNGFRAU);
// Should be true since we just created the shm
REQUIRE(m.isFixedPatternSharedMemoryCompatible() == true);
// Set shm version to 0
SharedMemory<sharedModule> shm(0, 0);
REQUIRE(shm.exists() == true);
shm.openSharedMemory(true);
shm()->shmversion = 0;
// Should fail since version is set to 0
REQUIRE(m.isFixedPatternSharedMemoryCompatible() == false);
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Get default control port") {
Module m(dt::MYTHEN3);
REQUIRE(m.getControlPort() == 1952);
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Get default stop port") {
Module m(dt::GOTTHARD2);
REQUIRE(m.getStopPort() == 1953);
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Get default receiver TCP port") {
Module m(dt::MYTHEN3);
REQUIRE(m.getReceiverPort() == 1954);
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
} // namespace sls