From 02fd4b356ead7da639fb3538f7eb91cf72eb5960 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 23 Apr 2019 17:37:02 +0200 Subject: [PATCH] adding config for tests --- integrationTests/a.cpp | 7 +- .../test-integrationDectector.cpp | 180 +++++++++++------- integrationTests/test-integrationMulti.cpp | 87 ++++++++- slsDetectorSoftware/include/slsDetector.h | 2 + slsDetectorSoftware/src/slsDetector.cpp | 24 ++- tests/CMakeLists.txt | 1 + .../include/tests}/config.h | 3 + tests/include/tests/globals.h | 6 + tests/test.cpp | 39 +++- 9 files changed, 258 insertions(+), 91 deletions(-) rename {integrationTests => tests/include/tests}/config.h (90%) create mode 100644 tests/include/tests/globals.h diff --git a/integrationTests/a.cpp b/integrationTests/a.cpp index 40cc3044a..216fc41a8 100644 --- a/integrationTests/a.cpp +++ b/integrationTests/a.cpp @@ -36,9 +36,10 @@ std::ostream &operator<<(std::ostream &out, const ROI &r) { int main() { - int ret[]{0,0,0}; - for (auto i: ret) - std::cout << i << "\n"; + std::cout << "nullptr: " << sizeof(nullptr) << "\n"; + // int ret[]{0,0,0}; + // for (auto i: ret) + // std::cout << i << "\n"; // uint32_t imageSize = 101; // uint32_t packetSize = 100; // std::cout << "a: " << std::ceil((double)imageSize / (double)packetSize) <<'\n'; diff --git a/integrationTests/test-integrationDectector.cpp b/integrationTests/test-integrationDectector.cpp index 6d4805752..e596933be 100755 --- a/integrationTests/test-integrationDectector.cpp +++ b/integrationTests/test-integrationDectector.cpp @@ -13,18 +13,41 @@ #include #define VERBOSE -//Header holding all configurations for different detectors -#include "config.h" +// Header holding all configurations for different detectors +#include "tests/config.h" -TEST_CASE("single EIGER detector no receiver basic set and get", "[.integration]") { - //TODO! this test should take command line arguments for config +using dt = slsDetectorDefs::detectorType; +extern std::string hostname; +extern std::string detector_type; +extern dt type; + +TEST_CASE("Single detector no receiver", "[.integration][cli]") { + auto t = slsDetector::getTypeFromDetector(hostname); + CHECK(t == type); + + slsDetector d(t); + CHECK(d.getDetectorTypeAsEnum() == t); + CHECK(d.getDetectorTypeAsString() == detector_type); + + d.setHostname(hostname); + CHECK(d.getHostname() == hostname); + + d.setOnline(true); + CHECK(d.getOnlineFlag() == true); + + d.freeSharedMemory(); +} + +TEST_CASE("single EIGER detector no receiver basic set and get", + "[.integration][eiger]") { + // TODO! this test should take command line arguments for config SingleDetectorConfig c; - //Read type by connecting to the detector + // Read type by connecting to the detector auto type = slsDetector::getTypeFromDetector(c.hostname); CHECK(type == c.type_enum); - //Create slsDetector of said type and set hostname and detector online + // Create slsDetector of said type and set hostname and detector online slsDetector d(type); CHECK(d.getDetectorTypeAsEnum() == type); CHECK(d.getDetectorTypeAsString() == c.type_string); @@ -38,19 +61,22 @@ TEST_CASE("single EIGER detector no receiver basic set and get", "[.integration] CHECK(d.getReceiverOnline() == false); CHECK(d.checkDetectorVersionCompatibility() == slsDetectorDefs::OK); - //Setting and reading exposure time + // Setting and reading exposure time auto t = 1000000000; d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t); CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t); - //size of an eiger half module with and without gap pixels + // size of an eiger half module with and without gap pixels CHECK(d.getTotalNumberOfChannels() == 256 * 256 * 4); CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::X) == 1024); CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Y) == 256); // CHECK(d.getTotalNumberOfChannels(slsDetectorDefs::dimension::Z) == 1); - CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::X) == 1024); - CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Y) == 256); - // CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z) == 1); + CHECK(d.getTotalNumberOfChannelsInclGapPixels( + slsDetectorDefs::dimension::X) == 1024); + CHECK(d.getTotalNumberOfChannelsInclGapPixels( + slsDetectorDefs::dimension::Y) == 256); + // CHECK(d.getTotalNumberOfChannelsInclGapPixels(slsDetectorDefs::dimension::Z) + // == 1); CHECK(d.getNChans() == 256 * 256); CHECK(d.getNChans(slsDetectorDefs::dimension::X) == 256); @@ -69,7 +95,7 @@ TEST_CASE("Set control port then create a new object with this control port", "[.integration]") { /* TODO! - Standard port but should not be hardcoded + Standard port but should not be hardcoded Is this the best way to initialize the detectors Using braces to make the object go out of scope */ @@ -102,7 +128,7 @@ TEST_CASE("Set control port then create a new object with this control port", d.setOnline(true); - //Reset standard ports + // Reset standard ports d.setControlPort(old_cport); d.setStopPort(old_sport); d.freeSharedMemory(); @@ -124,17 +150,17 @@ TEST_CASE("Locking mechanism and last ip", "[.integration]") { d.setHostname(c.hostname); d.setOnline(true); - //Check that detector server is unlocked then lock + // Check that detector server is unlocked then lock CHECK(d.lockServer() == 0); d.lockServer(1); CHECK(d.lockServer() == 1); - //Can we still access the detector while it's 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 and free + // unlock again and free d.lockServer(0); CHECK(d.lockServer() == 0); @@ -142,15 +168,17 @@ TEST_CASE("Locking mechanism and last ip", "[.integration]") { d.freeSharedMemory(); } -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 */ - // DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or readout (in triggered mode) */ - // GATES_NUMBER, /**< number of gates per frame (in gated mode) */ - // CYCLES_NUMBER, /**< number of cycles: total number of acquisitions is number or frames*number of cycles */ +TEST_CASE("Timer functions", "[.integration][cli]") { + // 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 */ + // DELAY_AFTER_TRIGGER, /**< delay between trigger and start of exposure or + // readout (in triggered mode) */ GATES_NUMBER, /**< number of gates per + // frame (in gated mode) */ CYCLES_NUMBER, /**< number of cycles: total + // number of acquisitions is number or frames*number of cycles */ // ACTUAL_TIME, /**< Actual time of the detector's internal timer */ - // MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) */ + // MEASUREMENT_TIME, /**< Time of the measurement from the detector (fifo) + // */ // PROGRESS, /**< fraction of measurement elapsed - only get! */ // MEASUREMENTS_NUMBER, @@ -163,43 +191,56 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") { // MEASURED_PERIOD, /**< measured period */ // MEASURED_SUBPERIOD, /**< measured subperiod */ // MAX_TIMERS - SingleDetectorConfig c; - auto type = slsDetector::getTypeFromDetector(c.hostname); + slsDetector d(type); - d.setHostname(c.hostname); + d.setHostname(hostname); d.setOnline(true); - //Number of frames - auto frames = 10; + // Number of frames + auto frames = 5; d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER, frames); CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_NUMBER) == frames); - auto t = 10000000; - d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, t); - CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == t); + auto exptime = 2000000000; + d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME, exptime); + CHECK(d.setTimer(slsDetectorDefs::timerIndex::ACQUISITION_TIME) == exptime); - auto period = 1000000000; + auto period = 2000000000; d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period); CHECK(d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD) == period); - // not implemented for EIGER - // auto delay = 10000; - // d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay); - // CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) == delay); + if (type != dt::EIGER) { + auto delay = 10000; + d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER, delay); + CHECK(d.setTimer(slsDetectorDefs::timerIndex::DELAY_AFTER_TRIGGER) == + delay); + } - // auto gates = 1; - // d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates); - // CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates); + if (type != dt::EIGER) { + auto gates = 1; + d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER, gates); + CHECK(d.setTimer(slsDetectorDefs::timerIndex::GATES_NUMBER) == gates); + } auto cycles = 2; d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER, cycles); CHECK(d.setTimer(slsDetectorDefs::timerIndex::CYCLES_NUMBER) == cycles); - auto subtime = 200; - d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME, subtime); - CHECK(d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) == subtime); + if (type == dt::EIGER) { + auto subtime = 200; + d.setTimer(slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME, + subtime); + CHECK(d.setTimer( + slsDetectorDefs::timerIndex::SUBFRAME_ACQUISITION_TIME) == + subtime); + } + // for (int i =0; i!=frames; ++i) + d.startAndReadAll(); d.freeSharedMemory(); + + // If we add a timer we should add tests for the timer + CHECK(slsDetectorDefs::MAX_TIMERS == 19); } // TEST_CASE("Aquire", "[.integration][eiger]"){ @@ -216,26 +257,27 @@ TEST_CASE("Excersise all possible set timer functions", "[.integration]") { // d.setTimer(slsDetectorDefs::timerIndex::FRAME_PERIOD, period); // d.startAndReadAll(); - - -// auto rperiod = d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD); +// auto rperiod = +// d.getTimeLeft(slsDetectorDefs::timerIndex::MEASURED_PERIOD); // CHECK(rperiod == 0.1); // d.freeSharedMemory(); // } -TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider", "[.eigerintegration]") { +TEST_CASE( + "Eiger Dynamic Range with effect on rate correction and clock divider", + "[.eigerintegration]") { SingleDetectorConfig c; - + int ratecorr = 125; // pick up multi detector from shm id 0 multiSlsDetector m(0); // ensure eiger detector type, hostname and online - REQUIRE(m.getDetectorTypeAsEnum()==c.type_enum); - REQUIRE(m.getHostname()==c.hostname); - REQUIRE(m.setOnline(true)==slsDetectorDefs::ONLINE_FLAG); + REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); + REQUIRE(m.getHostname() == c.hostname); + REQUIRE(m.setOnline(true) == slsDetectorDefs::ONLINE_FLAG); // starting state with rate correction off CHECK(m.setRateCorrection(0) == 0); @@ -267,27 +309,26 @@ TEST_CASE("Eiger Dynamic Range with effect on rate correction and clock divider" // ratecorr fail with dr 4 or 8 CHECK_THROWS_AS(m.setDynamicRange(8), sls::NonCriticalError); - CHECK(m.getRateCorrection()==0); + CHECK(m.getRateCorrection() == 0); m.setDynamicRange(16); m.setDynamicRange(16); m.setRateCorrection(ratecorr); m.setDynamicRange(16); m.setRateCorrection(ratecorr); CHECK_THROWS_AS(m.setDynamicRange(4), sls::NonCriticalError); - CHECK(m.getRateCorrection()==0); + CHECK(m.getRateCorrection() == 0); } - TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") { SingleDetectorConfig c; - - // pick up multi detector from shm id 0 + + // pick up multi detector from shm id 0 multiSlsDetector m(0); // ensure ctb detector type, hostname and online - REQUIRE(m.getDetectorTypeAsEnum()==c.type_enum); - REQUIRE(m.getHostname()==c.hostname); - REQUIRE(m.setOnline(true)==slsDetectorDefs::ONLINE_FLAG); + REQUIRE(m.getDetectorTypeAsEnum() == c.type_enum); + REQUIRE(m.getHostname() == c.hostname); + REQUIRE(m.setOnline(true) == slsDetectorDefs::ONLINE_FLAG); uint64_t word = 0; int addr = 0; @@ -314,25 +355,30 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") { m.setPatternWord(addr, word); CHECK(m.setPatternWord(addr, -1) == word); addr = MAX_ADDR; - CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError); - CHECK_THROWS_WITH(m.setPatternWord(addr, word), Catch::Matchers::Contains( "be between 0 and" )); + CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError); + CHECK_THROWS_WITH(m.setPatternWord(addr, word), + Catch::Matchers::Contains("be between 0 and")); addr = -1; - CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError); - CHECK_THROWS_WITH(m.setPatternWord(addr, word), Catch::Matchers::Contains( "be between 0 and" )); + CHECK_THROWS_AS(m.setPatternWord(addr, word), sls::NonCriticalError); + CHECK_THROWS_WITH(m.setPatternWord(addr, word), + Catch::Matchers::Contains("be between 0 and")); addr = 0x2FF; for (level = 0; level < 3; ++level) { CHECK(m.setPatternWaitAddr(level, addr) == addr); CHECK(m.setPatternWaitAddr(level, -1) == addr); } - CHECK_THROWS_WITH(m.setPatternWaitAddr(-1, addr), Catch::Matchers::Contains( "be between 0 and" )); - CHECK_THROWS_WITH(m.setPatternWaitAddr(0, MAX_ADDR), Catch::Matchers::Contains( "be between 0 and" )); + CHECK_THROWS_WITH(m.setPatternWaitAddr(-1, addr), + Catch::Matchers::Contains("be between 0 and")); + CHECK_THROWS_WITH(m.setPatternWaitAddr(0, MAX_ADDR), + Catch::Matchers::Contains("be between 0 and")); for (level = 0; level < 3; ++level) { CHECK(m.setPatternWaitTime(level, word) == word); CHECK(m.setPatternWaitTime(level, -1) == word); } - CHECK_THROWS_WITH(m.setPatternWaitTime(-1, word), Catch::Matchers::Contains( "be between 0 and" )); + CHECK_THROWS_WITH(m.setPatternWaitTime(-1, word), + Catch::Matchers::Contains("be between 0 and")); { int startaddr = addr; @@ -354,6 +400,6 @@ TEST_CASE("Chiptestboard Loading Patterns", "[.ctbintegration]") { CHECK_THROWS_WITH(m.setPatternLoops(-1, startaddr, MAX_ADDR, nloops), Catch::Matchers::Contains("be less than")); CHECK_THROWS_WITH(m.setPatternLoops(-1, MAX_ADDR, stopaddr, nloops), - Catch::Matchers::Contains("be less than")); + Catch::Matchers::Contains("be less than")); } } \ No newline at end of file diff --git a/integrationTests/test-integrationMulti.cpp b/integrationTests/test-integrationMulti.cpp index ca16cae56..9e6e7a44a 100755 --- a/integrationTests/test-integrationMulti.cpp +++ b/integrationTests/test-integrationMulti.cpp @@ -1,11 +1,78 @@ -// #include "catch.hpp" -// #include "multiSlsDetector.h" +#include "catch.hpp" -// #include -// TEST_CASE("Initialize a detector") { -// multiSlsDetector det(0, true, true); -// std::cout << "Size: " << det.getNumberOfDetectors() << std::endl; -// std::cout << "Hostname: " << det.getHostname() << std::endl; -// REQUIRE(false); - -// } \ No newline at end of file +#include "multiSlsDetector.h" +#include "string_utils.h" + +#include "tests/globals.h" + +#include + +TEST_CASE("Initialize a multi detector", "[.integration][.multi]") { + auto hostnames = sls::split(hostname, '+'); + + multiSlsDetector d(0, true, true); + d.setHostname(hostname.c_str()); + REQUIRE(d.setOnline() == true); // get! + + CHECK(d.getHostname() == hostname); + for (size_t i = 0; i != hostnames.size(); ++i) { + CHECK(d.getHostname(i) == hostnames[i]); + } + + CHECK(d.getDetectorTypeAsEnum() == type); + CHECK(d.getDetectorTypeAsString() == detector_type); + + CHECK(d.getNumberOfDetectors() == hostnames.size()); + d.freeSharedMemory(); +} + +TEST_CASE("Set and get dacs", "[.integration][.multi]"){ + multiSlsDetector d(0, true, true); + d.setHostname(hostname.c_str()); + + switch(type){ + case dt::EIGER: + + d.setDAC(3500, di::E_Vrf, 0); + CHECK(d.setDAC(-1, di::E_Vrf, 0) == 3500); + + + d.setDAC(1500, di::E_Vcmp_ll, 0); + CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == 1500); + d.setDAC(1400, di::E_Vcmp_lr, 0); + CHECK(d.setDAC(-1, di::E_Vcmp_lr, 0) == 1400); + d.setDAC(1300, di::E_Vcmp_rl, 0); + CHECK(d.setDAC(-1, di::E_Vcmp_rl, 0) == 1300); + d.setDAC(1200, di::E_Vcmp_rr, 0); + CHECK(d.setDAC(-1, di::E_Vcmp_rr, 0) == 1200); + + auto th = 1000; + d.setDAC(th, di::THRESHOLD, 0); + CHECK(d.setDAC(-1, di::THRESHOLD, 0) == th); + CHECK(d.setDAC(-1, di::E_Vcmp_ll, 0) == th); + CHECK(d.setDAC(-1, di::E_Vcmp_lr, 0) == th); + CHECK(d.setDAC(-1, di::E_Vcmp_rl, 0) == th); + CHECK(d.setDAC(-1, di::E_Vcmp_rr, 0) == th); + break; + + } + + + d.freeSharedMemory(); +} + +TEST_CASE("Timers", "[.integration][.multi]") { + multiSlsDetector d(0, true, true); + d.setHostname(hostname.c_str()); + + int n_frames = 3; + d.setNumberOfFrames(n_frames); + CHECK(d.setNumberOfFrames() == n_frames); + + double exptime = 1; + d.setExposureTime(exptime, true); + CHECK(d.setExposureTime(-1, true) == exptime); + + + d.freeSharedMemory(); +} \ No newline at end of file diff --git a/slsDetectorSoftware/include/slsDetector.h b/slsDetectorSoftware/include/slsDetector.h index 1b7fdf57c..6ee11c826 100755 --- a/slsDetectorSoftware/include/slsDetector.h +++ b/slsDetectorSoftware/include/slsDetector.h @@ -291,6 +291,8 @@ class slsDetector : public virtual slsDetectorDefs{ */ int64_t getId(idMode mode); + + int sendToDetector(int fnum, void* args, size_t args_size, void* retval, size_t retval_size); int64_t getReceiverSoftwareVersion() const; diff --git a/slsDetectorSoftware/src/slsDetector.cpp b/slsDetectorSoftware/src/slsDetector.cpp index 3db2fa0d8..472900858 100755 --- a/slsDetectorSoftware/src/slsDetector.cpp +++ b/slsDetectorSoftware/src/slsDetector.cpp @@ -1826,16 +1826,13 @@ int slsDetector::getDataBytesInclGapPixels() { int slsDetector::setDAC(int val, dacIndex index, int mV) { int fnum = F_SET_DAC; int ret = FAIL; - int args[3]{static_cast(index), mV, val}; + int args[]{static_cast(index), mV, val}; int retval = -1; FILE_LOG(logDEBUG1) << "Setting DAC " << index << " to " << val << (mV != 0 ? "mV" : "dac units"); if (detector_shm()->onlineFlag == ONLINE_FLAG) { - auto client = DetectorSocket(detector_shm()->hostname, - detector_shm()->controlPort); - ret = client.sendCommandThenRead(fnum, args, sizeof(args), &retval, - sizeof(retval)); + ret = sendToDetector(fnum, args, sizeof(args), &retval, sizeof(retval)); FILE_LOG(logDEBUG1) << "Dac index " << index << ": " << retval << (mV != 0 ? "mV" : "dac units"); } @@ -1845,6 +1842,15 @@ int slsDetector::setDAC(int val, dacIndex index, int mV) { return retval; } + +int slsDetector::sendToDetector(int fnum, void* args, size_t args_size, void* retval, size_t retval_size) +{ + auto client = DetectorSocket(detector_shm()->hostname, + detector_shm()->controlPort); + + return client.sendCommandThenRead(fnum, args, args_size, retval, retval_size); +} + int slsDetector::getADC(dacIndex index) { int fnum = F_GET_ADC; int arg = static_cast(index); @@ -1870,10 +1876,10 @@ slsDetector::setExternalCommunicationMode(externalCommunicationMode pol) { FILE_LOG(logDEBUG1) << "Setting communication to mode " << pol; 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)); + ret = sendToDetector(fnum, &arg, sizeof(arg), &retval,sizeof(retval)); + // auto client = DetectorSocket(detector_shm()->hostname, + // detector_shm()->controlPort); + // ret = client.sendCommandThenRead(fnum, &arg, sizeof(arg), &retval,sizeof(retval)); FILE_LOG(logDEBUG1) << "Timing Mode: " << retval; } if (ret == FORCE_UPDATE) { diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 61415ddc3..b8366739e 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,6 @@ include_directories( ${PROJECT_SOURCE_DIR}/catch + include ) set(SLS_TEST_SOURCES diff --git a/integrationTests/config.h b/tests/include/tests/config.h similarity index 90% rename from integrationTests/config.h rename to tests/include/tests/config.h index cb8357b40..c62ddd3f9 100644 --- a/integrationTests/config.h +++ b/tests/include/tests/config.h @@ -1,5 +1,8 @@ #pragma once #include +#include "sls_detector_defs.h" + + struct SingleDetectorConfig { slsDetectorDefs::detectorType type_enum = slsDetectorDefs::detectorType::CHIPTESTBOARD; diff --git a/tests/include/tests/globals.h b/tests/include/tests/globals.h new file mode 100644 index 000000000..61e90302e --- /dev/null +++ b/tests/include/tests/globals.h @@ -0,0 +1,6 @@ +#include "sls_detector_defs.h" +using dt = slsDetectorDefs::detectorType; +using di = slsDetectorDefs::dacIndex; +extern std::string hostname; +extern std::string detector_type; +extern dt type; \ No newline at end of file diff --git a/tests/test.cpp b/tests/test.cpp index 8daed99c4..857f447b6 100755 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -1,3 +1,38 @@ // tests-main.cpp -#define CATCH_CONFIG_MAIN -#include "catch.hpp" \ No newline at end of file +// #define CATCH_CONFIG_MAIN +// #include "catch.hpp" + +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" +#include "sls_detector_defs.h" +#include "tests/config.h" +#include + +// using namespace Catch::clara; +using Opt = Catch::clara::Opt; +using dt = slsDetectorDefs::detectorType; + +std::string hostname; +std::string detector_type; +dt type; + +int main(int argc, char *argv[]) { + Catch::Session session; + + auto cli = session.cli() | + Opt(hostname, "hostname")["-hn"]["--hostname"]( + "Detector hostname for integration tests") | + Opt(detector_type, "detector_type")["-dt"]["--detector_type"]( + "Detector type for integration tests"); + + session.cli(cli); + + auto ret = session.applyCommandLine(argc, argv); + if (ret) { + return ret; + } + + type = slsDetectorDefs::detectorTypeToEnum(detector_type); + + return session.run(); +} \ No newline at end of file