From ffbb84e7787b2e4ee157d35a04004f4183f62f59 Mon Sep 17 00:00:00 2001 From: mazzol_a Date: Wed, 30 Apr 2025 17:24:40 +0200 Subject: [PATCH] added some tests --- slsDetectorSoftware/tests/CMakeLists.txt | 1 + .../tests/Caller/test-Caller-rx-running.cpp | 71 +++++++++++++++++++ .../tests/test-ReceiverActions.cpp | 19 +++++ 3 files changed, 91 insertions(+) create mode 100644 slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp create mode 100644 slsReceiverSoftware/tests/test-ReceiverActions.cpp diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt index d87f17ed0..4be0af781 100755 --- a/slsDetectorSoftware/tests/CMakeLists.txt +++ b/slsDetectorSoftware/tests/CMakeLists.txt @@ -8,6 +8,7 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-rx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-rx-running.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-pattern.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-eiger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Caller/test-Caller-jungfrau.cpp diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp new file mode 100644 index 000000000..34163d416 --- /dev/null +++ b/slsDetectorSoftware/tests/Caller/test-Caller-rx-running.cpp @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2025 Contributors to the SLS Detector Package +#include "Caller.h" +#include "catch.hpp" +#include "sls/Detector.h" +#include "tests/globals.h" + +#include + +namespace sls { + +using test::PUT; + +/* +detfuncs::F_RECEIVER_SET_NUM_FRAMES +detfuncs::F_RECEIVER_SET_NUM_TRIGGERS +detfuncs::F_RECEIVER_SET_NUM_BURSTS +detfuncs::F_RECEIVER_SET_TIMING_MODE +detfuncs::F_RECEIVER_SET_BURST_MODE +detfuncs::F_RECEIVER_SET_NUM_ANALOG_SAMPLES +detfuncs::F_RECEIVER_SET_NUM_DIGITAL_SAMPLES +detfuncs::F_RECEIVER_SET_NUM_TRANSCEIVER_SAMPLES +detfuncs::F_RECEIVER_SET_DYNAMIC_RANGE +detfuncs::F_RECEIVER_SET_STREAMING_FREQUENCY +detfuncs::F_RECEIVER_SET_FILE_INDEX +detfuncs::F_RECEIVER_SET_FILE_WRITE +detfuncs::F_RECEIVER_SET_MASTER_FILE_WRITE +detfuncs::F_RECEIVER_SET_OVERWRITE +detfuncs::F_RECEIVER_ENABLE_TENGIGA +detfuncs::F_RECEIVER_SET_FIFO_DEPTH +detfuncs::F_RECEIVER_SET_ACTIVATE +detfuncs::F_RECEIVER_SET_STREAMING +detfuncs::F_RECEIVER_SET_STREAMING_TIMER +detfuncs::F_RECEIVER_SET_FLIP_ROWS +detfuncs::F_RECEIVER_SET_DBIT_LIST +detfuncs::F_RECEIVER_SET_DBIT_OFFSET +detfuncs::F_RECEIVER_SET_DBIT_REORDE +*/ + +auto get_test_parameters() { + return GENERATE( + std::make_tuple("asamples", std::vector{"5"}), + std::make_tuple("tsamples", std::vector{"2"}), + std::make_tuple("dsamples", std::vector{"100"}), + std::make_tuple("frames", std::vector{"10"}), + std::make_tuple("triggers", std::vector{"5"}), + std::make_tuple("rx_dbitlist", std::vector{"{1,2,10}"}), + std::make_tuple("rx_dbitreorder", std::vector{"false"}), + std::make_tuple("rx_dbitoffset", std::vector{"5"}), + std::make_tuple("findex", std::vector{"2"}), + std::make_tuple("fwrite", std::vector{"false"}), + std::make_tuple("bursts", std::vector{"20"})); +} + +TEST_CASE("cant put if receiver is not idle", "[.cmdcall][.rx]") { + Detector det; + Caller caller(&det); + det.setFileWrite(false); // avoid writing or error on file creation + + auto [command, function_arguments] = get_test_parameters(); + // start receiver + std::ostringstream oss; + caller.call("rx_start", {}, -1, PUT, + oss); // why is there no receiver id passed + + REQUIRE(oss.str() == "rx_start successful\n"); + + REQUIRE_THROWS(caller.call(command, function_arguments, -1, PUT, oss, -1)); +} + +} // namespace sls \ No newline at end of file diff --git a/slsReceiverSoftware/tests/test-ReceiverActions.cpp b/slsReceiverSoftware/tests/test-ReceiverActions.cpp new file mode 100644 index 000000000..bae3fb518 --- /dev/null +++ b/slsReceiverSoftware/tests/test-ReceiverActions.cpp @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: LGPL-3.0-or-other +// Copyright (C) 2025 Contributors to the SLS Detector Package +/************************************************ + * @file test-ReceiverActions.cpp + * @short test cases to test receiver actions + ***********************************************/ + +#include "DataProcessor.h" +#include "GeneralData.h" +#include "catch.hpp" +#include + +namespace sls { + +TEST_CASE("cannot set analog/digital and transceiver samples when " + "reciever is running", + "[.recieveraction][.chiptestboard]") {} + +} // namespace sls \ No newline at end of file