mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 02:20:42 +02:00
more tests
This commit is contained in:
parent
1bbd77536c
commit
e996068328
@ -106,10 +106,10 @@ endif()
|
|||||||
|
|
||||||
|
|
||||||
if(SLS_USE_SANITIZER)
|
if(SLS_USE_SANITIZER)
|
||||||
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
target_compile_options(slsProjectOptions INTERFACE -fsanitize=address,undefined -fno-omit-frame-pointer)
|
||||||
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
|
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=address,undefined)
|
||||||
target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
|
# target_compile_options(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||||
target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
# target_link_libraries(slsProjectOptions INTERFACE -fsanitize=thread)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#rapidjson
|
#rapidjson
|
||||||
|
@ -60,13 +60,8 @@ int main(int argc, char *argv[]) {
|
|||||||
//How big should this try block be?
|
//How big should this try block be?
|
||||||
sls::Detector det(parser.multi_id());
|
sls::Detector det(parser.multi_id());
|
||||||
sls::CmdProxy proxy(&det);
|
sls::CmdProxy proxy(&det);
|
||||||
auto cmd = proxy.Call(parser.command(), parser.arguments(),
|
proxy.Call(parser.command(), parser.arguments(),
|
||||||
parser.detector_id(), action);
|
parser.detector_id(), action);
|
||||||
// TODO! move this check into CmdProxy
|
|
||||||
if (!cmd.empty()) {
|
|
||||||
std::cout << cmd
|
|
||||||
<< " Unknown command, use list to list all commands\n";
|
|
||||||
}
|
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const sls::RuntimeError &e) {
|
||||||
// OK to catch and do nothing since this will print the error message
|
// OK to catch and do nothing since this will print the error message
|
||||||
// and command line app will anyway exit
|
// and command line app will anyway exit
|
||||||
|
@ -25,7 +25,7 @@ std::ostream &operator<<(std::ostream &os,
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CmdProxy::Call(const std::string &command,
|
void CmdProxy::Call(const std::string &command,
|
||||||
const std::vector<std::string> &arguments,
|
const std::vector<std::string> &arguments,
|
||||||
int detector_id, int action, std::ostream &os) {
|
int detector_id, int action, std::ostream &os) {
|
||||||
cmd = command;
|
cmd = command;
|
||||||
@ -37,9 +37,8 @@ std::string CmdProxy::Call(const std::string &command,
|
|||||||
auto it = functions.find(cmd);
|
auto it = functions.find(cmd);
|
||||||
if (it != functions.end()) {
|
if (it != functions.end()) {
|
||||||
os << ((*this).*(it->second))(action);
|
os << ((*this).*(it->second))(action);
|
||||||
return {};
|
|
||||||
} else {
|
} else {
|
||||||
return cmd;
|
throw sls::RuntimeError(cmd + " Unknown command, use list to list all commands");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ class CmdProxy {
|
|||||||
public:
|
public:
|
||||||
explicit CmdProxy(Detector *ptr) : det(ptr) {}
|
explicit CmdProxy(Detector *ptr) : det(ptr) {}
|
||||||
|
|
||||||
std::string Call(const std::string &command,
|
void Call(const std::string &command,
|
||||||
const std::vector<std::string> &arguments, int detector_id = -1,
|
const std::vector<std::string> &arguments, int detector_id = -1,
|
||||||
int action = -1, std::ostream &os = std::cout);
|
int action = -1, std::ostream &os = std::cout);
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "Detector.h"
|
#include "Detector.h"
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include "sls_detector_defs.h"
|
#include "sls_detector_defs.h"
|
||||||
|
#include <array>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
#include "tests/globals.h"
|
#include "tests/globals.h"
|
||||||
@ -12,26 +13,84 @@ using sls::Detector;
|
|||||||
using test::GET;
|
using test::GET;
|
||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
// TEST_CASE("tengiga", "[.cmd][.eiger][.ctb]") {
|
TEST_CASE("dr", "[.cmd][.eiger]") {
|
||||||
// if (test::type == slsDetectorDefs::EIGER || test::type ==
|
Detector det;
|
||||||
// slsDetectorDefs::CHIPTESTBOARD) {
|
CmdProxy proxy(&det);
|
||||||
// {
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("tengiga 1", PUT));
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
if (det_type == defs::EIGER) {
|
||||||
|
// The only detector currently supporting setting dr
|
||||||
|
// is EIGER?
|
||||||
|
auto dr = det.getDynamicRange().squash();
|
||||||
|
std::array<int, 4> vals{4, 8, 16, 32};
|
||||||
|
for (const auto val : vals) {
|
||||||
|
std::ostringstream oss1, oss2;
|
||||||
|
proxy.Call("dr", {std::to_string(val)}, -1, PUT, oss1);
|
||||||
|
REQUIRE(oss1.str() == "dr " + std::to_string(val) + '\n');
|
||||||
|
proxy.Call("dr", {}, -1, GET, oss2);
|
||||||
|
REQUIRE(oss2.str() == "dr " + std::to_string(val) + '\n');
|
||||||
|
}
|
||||||
|
det.setDynamicRange(dr);
|
||||||
|
} else {
|
||||||
|
// For the other detectors we should get an error message
|
||||||
|
// except for dr 16
|
||||||
|
REQUIRE_THROWS(proxy.Call("dr", {"4"}, -1, PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call("dr", {"8"}, -1, PUT));
|
||||||
|
REQUIRE_THROWS(proxy.Call("dr", {"32"}, -1, PUT));
|
||||||
|
|
||||||
|
std::ostringstream oss1, oss2;
|
||||||
|
proxy.Call("dr", {"16"}, -1, PUT, oss1);
|
||||||
|
REQUIRE(oss1.str() == "dr 16\n");
|
||||||
|
proxy.Call("dr", {"16"}, -1, PUT, oss2);
|
||||||
|
REQUIRE(oss2.str() == "dr 16\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEST_CASE("subexptime", "[.cmd][.eiger]") {
|
||||||
|
// if (test::type == slsDetectorDefs::EIGER) {
|
||||||
|
// std::string s;
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:tengiga", GET, nullptr,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("subexptime", GET, nullptr,
|
||||||
// oss)); REQUIRE(oss.str() == "tengiga 1\n");
|
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
||||||
// }
|
// PUT));
|
||||||
// {
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("tengiga 0", PUT));
|
|
||||||
// std::ostringstream oss;
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:tengiga", GET, nullptr,
|
|
||||||
// oss)); REQUIRE(oss.str() == "tengiga 0\n");
|
|
||||||
// }
|
|
||||||
// } else {
|
// } else {
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("tengiga", GET));
|
// REQUIRE_THROWS(multiSlsDetectorClient("subexptime", GET));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// TEST_CASE("subdeadtime", "[.cmd][.eiger]") {
|
||||||
|
// if (test::type == slsDetectorDefs::EIGER) {
|
||||||
|
// std::string s;
|
||||||
|
// std::ostringstream oss;
|
||||||
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("subdeadtime", GET, nullptr,
|
||||||
|
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
||||||
|
// PUT));
|
||||||
|
// } else {
|
||||||
|
// REQUIRE_THROWS(multiSlsDetectorClient("subdeadtime", GET));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
TEST_CASE("tengiga", "[.cmd][.eiger][.ctb]") {
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
|
||||||
|
auto det_type = det.getDetectorType().squash();
|
||||||
|
if (det_type == defs::EIGER || det_type == defs::CHIPTESTBOARD){
|
||||||
|
auto tengiga = det.getTenGiga();
|
||||||
|
det.setTenGiga(false);
|
||||||
|
|
||||||
|
std::ostringstream oss1, oss2;
|
||||||
|
proxy.Call("tengiga", {"1"}, -1, PUT, oss1);
|
||||||
|
REQUIRE(oss1.str() == "tengiga 1\n");
|
||||||
|
proxy.Call("tengiga", {}, -1, GET, oss2);
|
||||||
|
REQUIRE(oss2.str() == "tengiga 1\n");
|
||||||
|
|
||||||
|
for (int i = 0; i!=det.size(); ++i){
|
||||||
|
det.setTenGiga(tengiga[i], {i});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE("quad", "[.cmd]") {
|
TEST_CASE("quad", "[.cmd]") {
|
||||||
// TODO! set and get once available in virtual detector
|
// TODO! set and get once available in virtual detector
|
||||||
Detector det;
|
Detector det;
|
||||||
@ -142,7 +201,6 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") {
|
|||||||
// REQUIRE(oss.str() == "trigger successful\n");
|
// REQUIRE(oss.str() == "trigger successful\n");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// auto currentfnum = det.getStartingFrameNumber().tsquash(
|
// auto currentfnum = det.getStartingFrameNumber().tsquash(
|
||||||
// "inconsistent frame nr in test");
|
// "inconsistent frame nr in test");
|
||||||
|
|
||||||
@ -154,49 +212,49 @@ TEST_CASE("Setting and reading back EIGER dacs", "[.cmd]") {
|
|||||||
// REQUIRE(oss.str() == "timing auto\n");
|
// REQUIRE(oss.str() == "timing auto\n");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// if(test::type != slsDetectorDefs::EIGER) {
|
// if(test::type != slsDetectorDefs::EIGER) {
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT));
|
// REQUIRE_THROWS(multiSlsDetectorClient("trigger", PUT));
|
||||||
// } else {
|
// } else {
|
||||||
// // trigger
|
// // trigger
|
||||||
// {
|
// {
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing trigger", PUT,
|
||||||
// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n");
|
// nullptr, oss)); REQUIRE(oss.str() == "timing trigger\n");
|
||||||
// }
|
// }
|
||||||
// int startingfnum = 0;
|
// int startingfnum = 0;
|
||||||
// {
|
// {
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
||||||
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
||||||
// strlen("startingfnum ")); startingfnum = std::stoi(s);
|
// strlen("startingfnum ")); startingfnum = std::stoi(s);
|
||||||
// }
|
// }
|
||||||
// {
|
// {
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("start", PUT, nullptr,
|
||||||
// oss)); REQUIRE(oss.str() == "start successful\n");
|
// oss)); REQUIRE(oss.str() == "start successful\n");
|
||||||
// }
|
// }
|
||||||
// {
|
// {
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("status", GET,
|
||||||
// nullptr, oss)); REQUIRE(oss.str() != "status idle\n");
|
// nullptr, oss)); REQUIRE(oss.str() != "status idle\n");
|
||||||
// REQUIRE(oss.str()
|
// REQUIRE(oss.str()
|
||||||
// != "status stopped\n");
|
// != "status stopped\n");
|
||||||
// }
|
// }
|
||||||
// {
|
// {
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("trigger", PUT,
|
||||||
// nullptr, oss)); REQUIRE(oss.str() == "trigger successful\n");
|
// nullptr, oss)); REQUIRE(oss.str() == "trigger successful\n");
|
||||||
// }
|
// }
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT));
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("stop", PUT));
|
||||||
// int currentfnum = 0;
|
// int currentfnum = 0;
|
||||||
// {
|
// {
|
||||||
// std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("startingfnum", GET,
|
||||||
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
// nullptr, oss)); std::string s = (oss.str()).erase (0,
|
||||||
// strlen("startingfnum ")); currentfnum = std::stoi(s);
|
// strlen("startingfnum ")); currentfnum = std::stoi(s);
|
||||||
// }
|
// }
|
||||||
// REQUIRE((startingfnum + 1) == currentfnum);
|
// REQUIRE((startingfnum + 1) == currentfnum);
|
||||||
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT));
|
// REQUIRE_NOTHROW(multiSlsDetectorClient("timing auto", PUT));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
@ -61,14 +61,15 @@ TEST_CASE("rx_framescaught", "[.cmd]") {
|
|||||||
REQUIRE(oss.str() == "rx_framescaught 0\n");
|
REQUIRE(oss.str() == "rx_framescaught 0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Currently disabled may activate if we have a stable env
|
||||||
// Now take one frame and see that we caught it
|
// Now take one frame and see that we caught it
|
||||||
det.setNumberOfFrames(1);
|
// det.setNumberOfFrames(1);
|
||||||
det.acquire();
|
// det.acquire();
|
||||||
{
|
// {
|
||||||
std::ostringstream oss;
|
// std::ostringstream oss;
|
||||||
proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
// proxy.Call("rx_framescaught", {}, -1, GET, oss);
|
||||||
REQUIRE(oss.str() == "rx_framescaught 1\n");
|
// REQUIRE(oss.str() == "rx_framescaught 1\n");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("rx_status", "[.cmd]") {
|
TEST_CASE("rx_status", "[.cmd]") {
|
||||||
|
@ -14,6 +14,12 @@ using sls::Detector;
|
|||||||
using test::GET;
|
using test::GET;
|
||||||
using test::PUT;
|
using test::PUT;
|
||||||
|
|
||||||
|
TEST_CASE("Unknown command", "[.cmd]"){
|
||||||
|
Detector det;
|
||||||
|
CmdProxy proxy(&det);
|
||||||
|
REQUIRE_THROWS(proxy.Call("vsaevrreavv", {}, -1, PUT));
|
||||||
|
}
|
||||||
|
|
||||||
// TEST_CASE("vchip", "[.cmd]") {
|
// TEST_CASE("vchip", "[.cmd]") {
|
||||||
// int prev_val = 0;
|
// int prev_val = 0;
|
||||||
|
|
||||||
@ -3100,66 +3106,27 @@ TEST_CASE("stopport", "[.cmd]") {
|
|||||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT));
|
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// TEST_CASE("subdeadtime", "[.cmd][.eiger]") {
|
|
||||||
// if (test::type == slsDetectorDefs::EIGER) {
|
|
||||||
// std::string s;
|
|
||||||
// std::ostringstream oss;
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("subdeadtime", GET, nullptr,
|
|
||||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
|
||||||
// PUT));
|
|
||||||
// } else {
|
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("subdeadtime", GET));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TEST_CASE("subexptime", "[.cmd][.eiger]") {
|
|
||||||
// if (test::type == slsDetectorDefs::EIGER) {
|
|
||||||
// std::string s;
|
|
||||||
// std::ostringstream oss;
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("subexptime", GET, nullptr,
|
|
||||||
// oss)); s = oss.str(); REQUIRE_NOTHROW(multiSlsDetectorClient(s,
|
|
||||||
// PUT));
|
|
||||||
// } else {
|
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("subexptime", GET));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TEST_CASE("dr", "[.cmd][.eiger]") {
|
|
||||||
// if (test::type == slsDetectorDefs::EIGER) {
|
|
||||||
// int vals[4] = {4, 8, 16, 32};
|
|
||||||
// for (int i = 0; i < 4; ++i) {
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr " +
|
|
||||||
// std::to_string(vals[i]), PUT)); std::ostringstream oss;
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr", GET, nullptr, oss));
|
|
||||||
// REQUIRE(oss.str() == "dr " + std::to_string(vals[i]) + '\n');
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("dr 4", PUT));
|
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("dr 8", PUT));
|
|
||||||
// REQUIRE_THROWS(multiSlsDetectorClient("dr 32", PUT));
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr 16", PUT));
|
|
||||||
// {
|
|
||||||
// std::ostringstream oss;
|
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("dr", GET, nullptr, oss));
|
|
||||||
// REQUIRE(oss.str() == "dr " + std::to_string(16) + '\n');
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// TEST_CASE("zmqip", "[.cmd]") {
|
|
||||||
// std::string s;
|
|
||||||
// {
|
|
||||||
// std::ostringstream oss;
|
TEST_CASE("zmqip", "[.cmd]") {
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:zmqip", GET, nullptr,
|
Detector det;
|
||||||
// oss)); s = oss.str();
|
CmdProxy proxy(&det);
|
||||||
// }
|
std::ostringstream oss1, oss2;
|
||||||
// {
|
auto zmqip = det.getClientZmqIp();
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient(s, PUT));
|
proxy.Call("zmqip", {}, 0, GET, oss1);
|
||||||
// std::ostringstream oss;
|
REQUIRE(oss1.str() == "zmqip " + zmqip[0].str() + '\n');
|
||||||
// REQUIRE_NOTHROW(multiSlsDetectorClient("0:zmqip", GET, nullptr,
|
|
||||||
// oss)); REQUIRE(oss.str() == s);
|
proxy.Call("zmqip", {zmqip[0].str()}, 0, PUT, oss2);
|
||||||
// }
|
REQUIRE(oss2.str() == "zmqip " + zmqip[0].str() + '\n');
|
||||||
// }
|
|
||||||
|
for (int i = 0; i!=det.size(); ++i){
|
||||||
|
det.setRxZmqIP(zmqip[i], {i});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TEST_CASE("zmqport", "[.cmd]") {
|
// TEST_CASE("zmqport", "[.cmd]") {
|
||||||
// multiSlsDetector d;
|
// multiSlsDetector d;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user