From 7f3d5e8a7e59521d81f964436a5df02d24152916 Mon Sep 17 00:00:00 2001 From: Erik Frojdh Date: Tue, 26 Nov 2019 20:34:17 +0100 Subject: [PATCH] WIP --- slsDetectorSoftware/tests/CMakeLists.txt | 1 + .../tests/test-CmdProxy-rx.cpp | 31 +-- slsDetectorSoftware/tests/test-CmdProxy.cpp | 240 ++++++------------ 3 files changed, 75 insertions(+), 197 deletions(-) diff --git a/slsDetectorSoftware/tests/CMakeLists.txt b/slsDetectorSoftware/tests/CMakeLists.txt index 9dca92d0f..25ad51248 100755 --- a/slsDetectorSoftware/tests/CMakeLists.txt +++ b/slsDetectorSoftware/tests/CMakeLists.txt @@ -3,6 +3,7 @@ target_sources(tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test-slsDetector.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-rx.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdProxy-eiger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-Result.cpp ${CMAKE_CURRENT_SOURCE_DIR}/test-CmdLineParser.cpp ) diff --git a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp index ce17d576d..32c346032 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp @@ -13,35 +13,8 @@ using test::GET; using test::PUT; /* -This file should contain receiver specific tests -25/11/2019 we have: -rx_datastream -rx_dbitlist -rx_dbitoffset -rx_discardpolicy -rx_fifodepth -rx_frameindex -rx_framescaught -rx_framesperfile -rx_hostname -rx_jsonaddheader -rx_jsonpara -rx_lastclient -rx_lock -rx_missingpackets -rx_padding -rx_printconfig -rx_readfreq -rx_realudpsocksize -rx_silent -rx_start -rx_status -rx_stop -rx_tcpport -rx_udpsocksize -rx_version -rx_zmqip -rx_zmqport +This file should contain receiver specific tests use python/scripts/list_tested_cmd.py +to check if all commands are covered */ diff --git a/slsDetectorSoftware/tests/test-CmdProxy.cpp b/slsDetectorSoftware/tests/test-CmdProxy.cpp index 89223b0d2..188075f91 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy.cpp @@ -1377,8 +1377,6 @@ using test::PUT; // } - - TEST_CASE("user", "[.cmd]") { Detector det; CmdProxy proxy(&det); @@ -1453,7 +1451,6 @@ TEST_CASE("stopport", "[.cmd]") { REQUIRE(port == 1953); } - // TEST_CASE("adcreg", "[.cmd]") { // if (test::type == slsDetectorDefs::JUNGFRAU || test::type == // slsDetectorDefs::CHIPTESTBOARD || test::type == @@ -1755,7 +1752,6 @@ TEST_CASE("stopport", "[.cmd]") { // REQUIRE_NOTHROW(multiSlsDetectorClient("rx_jsonaddheader \"\"", PUT)); // } - // TEST_CASE("patsetbit", "[.cmd][.ctb]") { // if (test::type == slsDetectorDefs::CHIPTESTBOARD) { // uint64_t val = 0; @@ -2845,19 +2841,6 @@ TEST_CASE("stopport", "[.cmd]") { // } // } -// TEST_CASE("quad", "[.cmd][.eiger]") { -// if (test::type == slsDetectorDefs::EIGER) { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("quad", GET, nullptr, -// oss)); REQUIRE(oss.str() == "quad 0\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("quad 0", PUT)); -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("quad", GET)); -// } -// } - // TEST_CASE("pulse", "[.cmd][.eiger]") { // REQUIRE_THROWS(multiSlsDetectorClient("pulse", GET)); // REQUIRE_THROWS(multiSlsDetectorClient("pulsenmove", GET)); @@ -3267,8 +3250,6 @@ TEST_CASE("stopport", "[.cmd]") { // } // } - - // TEST_CASE("zmqport", "[.cmd]") { // multiSlsDetector d; // int socketsperdetector = 1; @@ -3299,8 +3280,6 @@ TEST_CASE("stopport", "[.cmd]") { // } // } - - // TEST_CASE("fpath", "[.cmd]") { // std::string s; // { @@ -3325,34 +3304,6 @@ TEST_CASE("stopport", "[.cmd]") { // } // } -// TEST_CASE("rx_hostname", "[.cmd]") { -// std::string s; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:rx_hostname", GET, nullptr, -// oss)); s = oss.str(); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:rx_hostname", GET, nullptr, -// oss)); REQUIRE(oss.str() == s); -// } -// // save rx_hostame's ip somewhere (getent hosts [rx_hostname]) -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_hostname none", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:rx_hostname", GET, nullptr, -// oss)); REQUIRE(oss.str() == "rx_hostname none\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_hostname 129.129.205.80", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("0:rx_hostname", GET, nullptr, -// oss)); REQUIRE(oss.str() == "rx_hostname 129.129.205.80\n"); -// } -// } - // TEST_CASE("txndelay", "[.cmd][.eiger][.jungfrau]") { // if (test::type == slsDetectorDefs::EIGER) { // { @@ -3454,8 +3405,6 @@ TEST_CASE("stopport", "[.cmd]") { // } // } - - // TEST_CASE("network", "[.cmd]") { // /* {TODO custom srcip in globals // REQUIRE_NOTHROW(multiSlsDetectorClient("0:udp_srcip 129.129.205.203", @@ -3617,38 +3566,46 @@ TEST_CASE("stopport", "[.cmd]") { // REQUIRE_THROWS(multiSlsDetectorClient("numinterfaces 0", PUT)); // } -// TEST_CASE("timing", "[.cmd]") { -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing", GET, nullptr, oss)); -// REQUIRE(oss.str() == "timing auto\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing", GET, nullptr, oss)); -// REQUIRE(oss.str() == "timing trigger\n"); -// } -// if (test::type == slsDetectorDefs::EIGER) { -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing gating", PUT)); -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing", GET, nullptr, -// oss)); REQUIRE(oss.str() == "timing gating\n"); -// } -// { -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing burst_trigger", -// PUT)); std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing", GET, nullptr, -// oss)); REQUIRE(oss.str() == "timing burst_trigger\n"); -// } -// } else { -// REQUIRE_THROWS(multiSlsDetectorClient("timing gating", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("timing burst_trigger", PUT)); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT)); -// } +TEST_CASE("timing", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + det.setTimingMode(defs::AUTO_TIMING); // start in auto + { + std::ostringstream oss1, oss2; + proxy.Call("timing", {"auto"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing auto\n"); + proxy.Call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing auto\n"); + } + { + std::ostringstream oss1, oss2; + proxy.Call("timing", {"trigger"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing trigger\n"); + proxy.Call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing trigger\n"); + } + auto det_type = det.getDetectorType().squash(); + if (det_type == slsDetectorDefs::EIGER) { + { + std::ostringstream oss1, oss2; + proxy.Call("timing", {"gating"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing gating\n"); + proxy.Call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing gating\n"); + } + { + std::ostringstream oss1, oss2; + proxy.Call("timing", {"burst_trigger"}, -1, PUT, oss1); + REQUIRE(oss1.str() == "timing burst_trigger\n"); + proxy.Call("timing", {}, -1, GET, oss2); + REQUIRE(oss2.str() == "timing burst_trigger\n"); + } + } else { + REQUIRE_THROWS(proxy.Call("timing", {"gating"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("timing", {"burst_trigger"}, -1, PUT)); + } + det.setTimingMode(defs::AUTO_TIMING); // reset to auto +} // TEST_CASE("adc", "[.cmd][.ctb]") { // if (test::type != slsDetectorDefs::CHIPTESTBOARD) { @@ -4064,13 +4021,13 @@ TEST_CASE("stopport", "[.cmd]") { // CHECK_NOTHROW(multiSlsDetectorClient("type", GET)); // } -// TEST_CASE("firmwareversion", "[.cmd]") { -// { -// std::ostringstream oss; -// CHECK_NOTHROW(multiSlsDetectorClient("firmwareversion", GET, nullptr, -// oss)); -// } -// } +TEST_CASE("firmwareversion", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + std::ostringstream oss; + proxy.Call("firmwareversion", {}, -1, GET, oss); + REQUIRE_THROWS(proxy.Call("firmwareversion", {"4"}, -1, PUT, oss)); +} // TEST_CASE("status", "[.cmd]") { // Detector det; // CmdProxy proxy(&det); @@ -4105,53 +4062,6 @@ TEST_CASE("stopport", "[.cmd]") { // proxy.Call("frames", {"1"}, -1, PUT); // } -// TEST_CASE("trigger", "[.cmd][.eiger]") { -// if(test::type != slsDetectorDefs::EIGER) { -// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT)); -// } else { -// // trigger -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n"); -// } -// int startingfnum = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("startingfnum ")); startingfnum = std::stoi(s); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "start successful\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET, nullptr, -// oss)); REQUIRE(oss.str() != "status idle\n"); REQUIRE(oss.str() -// != "status stopped\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "trigger successful\n"); -// } -// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT)); -// int currentfnum = 0; -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET, -// nullptr, oss)); std::string s = (oss.str()).erase (0, -// strlen("startingfnum ")); currentfnum = std::stoi(s); -// } -// REQUIRE((startingfnum + 1) == currentfnum); - -// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT)); -// } -// } - // TEST_CASE("framesl", "[.cmd][.jungfrau][gotthard][ctb]") { // if(test::type == slsDetectorDefs::EIGER) { // REQUIRE_THROWS(multiSlsDetectorClient("framesl", GET)); @@ -4274,8 +4184,6 @@ TEST_CASE("stopport", "[.cmd]") { // } // } - - TEST_CASE("frames", "[.cmd]") { Detector det; CmdProxy proxy(&det); @@ -4297,8 +4205,6 @@ TEST_CASE("frames", "[.cmd]") { } } - - TEST_CASE("fwrite", "[.cmd]") { Detector det; CmdProxy proxy(&det); @@ -4380,8 +4286,6 @@ TEST_CASE("findex", "[.cmd]") { } } - - TEST_CASE("fname", "[.cmd]") { Detector det; CmdProxy proxy(&det); @@ -4402,7 +4306,6 @@ TEST_CASE("fname", "[.cmd]") { } } - TEST_CASE("lock", "[.cmd]") { Detector det; CmdProxy proxy(&det); @@ -4427,8 +4330,6 @@ TEST_CASE("lock", "[.cmd]") { // REQUIRE_NOTHROW(multiSlsDetectorClient("lastclient", GET)); // } - - TEST_CASE("exptime", "[.cmd]") { Detector det; CmdProxy proxy(&det); @@ -4469,25 +4370,28 @@ TEST_CASE("period", "[.cmd]") { } } -// TEST_CASE("delay", "[.cmd][.eiger]") { -// if(test::type == slsDetectorDefs::EIGER) { -// REQUIRE_THROWS(multiSlsDetectorClient("delay 1", PUT)); -// REQUIRE_THROWS(multiSlsDetectorClient("delay", GET)); -// } else { -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("delay 1.25s", PUT, -// nullptr, oss)); REQUIRE(oss.str() == "delay 1.25s\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("delay", GET, nullptr, -// oss)); REQUIRE(oss.str() == "delay 1.25s\n"); -// } -// { -// std::ostringstream oss; -// REQUIRE_NOTHROW(multiSlsDetectorClient("delay 0", PUT, nullptr, -// oss)); REQUIRE(oss.str() == "delay 0\n"); -// } -// } -// } \ No newline at end of file +TEST_CASE("delay", "[.cmd]") { + Detector det; + CmdProxy proxy(&det); + auto det_type = det.getDetectorType().squash(); + if (det_type == defs::EIGER) { + REQUIRE_THROWS(proxy.Call("delay", {"1"}, -1, PUT)); + REQUIRE_THROWS(proxy.Call("delay", {}, -1, GET)); + } else { + { + std::ostringstream oss; + proxy.Call("delay", {"1.25s"}, -1, PUT, oss); + REQUIRE(oss.str() == "delay 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("delay", {}, -1, GET, oss); + REQUIRE(oss.str() == "delay 1.25s\n"); + } + { + std::ostringstream oss; + proxy.Call("delay", {"0s"}, -1, PUT, oss); + REQUIRE(oss.str() == "delay 0s\n"); + } + } +} \ No newline at end of file