Dev/proper free (#1005)

* first draft of fixing the free function available within the class

* removed class member function freeSharedmemory for both Detector and Module; made the free function freeSharedmemory accessible to python interface; setHostname if there is already a module in shm will recreate the Detector object while freeing shm completely and keeping detsize and intitialchecks (previous commit), sethostname called from DetectorClass in virtual command to have one point of entry (previous commit), testing Module class frees shared memory using free function

* Detector class: added copy and move constructor and assignmentoperators due to explicit destructor (DetectorImpl fwd declared), DetectorImpl class: included ZmqSocket to remove destructor (should not be virtual in any case), Module class: removed explciit destructor to allow compiler generated constructor and operators

* formatting

* minor fix for readme autocomplete

* updated client version date
This commit is contained in:
2024-10-21 16:25:07 +02:00
committed by GitHub
parent 76ab0228ac
commit 6add9aad5d
12 changed files with 71 additions and 120 deletions

View File

@ -1,5 +1,6 @@
// 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"
@ -10,7 +11,9 @@ using dt = slsDetectorDefs::detectorType;
TEST_CASE("Construction with a defined detector type") {
Module m(dt::EIGER);
REQUIRE(m.getDetectorType() == dt::EIGER);
m.freeSharedMemory(); // clean up
freeSharedMemory(0, 0); // clean up
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Read back detector type from shm") {
@ -23,7 +26,9 @@ TEST_CASE("Read back detector type from shm") {
// Now both objects point to the same shm so we can only
// free one!
m2.freeSharedMemory();
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
TEST_CASE("Is shm fixed pattern shm compatible") {
@ -41,25 +46,33 @@ TEST_CASE("Is shm fixed pattern shm compatible") {
// Should fail since version is set to 0
REQUIRE(m.isFixedPatternSharedMemoryCompatible() == false);
m.freeSharedMemory();
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);
m.freeSharedMemory();
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);
m.freeSharedMemory();
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);
m.freeSharedMemory();
freeSharedMemory(0, 0);
SharedMemory<sharedModule> moduleShm(0, 0);
REQUIRE(moduleShm.exists() == false);
}
} // namespace sls