diff --git a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp index 8e2912ce7..35313c02e 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller-chiptestboard.cpp @@ -1025,128 +1025,6 @@ TEST_CASE("dbitclk", "[.detectorintegration]") { } } -TEST_CASE("v_abcd", "[.detectorintegration]") { - Detector det; - Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - - std::vector cmds{"v_a", "v_b", "v_c", "v_d"}; - std::vector indices{defs::V_POWER_A, defs::V_POWER_B, - defs::V_POWER_C, defs::V_POWER_D}; - - if (det.isVirtualDetectorServer().tsquash("Inconsistent virtual servers")) { - cmds.push_back("v_io"); - indices.push_back(defs::V_POWER_IO); - } - - for (size_t i = 0; i < cmds.size(); ++i) { - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPower(indices[i]); - // this is the first command touching power dacs, should not be - // -100 - if (det_type == defs::XILINX_CHIPTESTBOARD) { - REQUIRE(prev_val.any(-100) == false); - REQUIRE(prev_val.any(-1) == false); - } - { - std::ostringstream oss; - caller.call(cmds[i], {"0"}, -1, PUT, oss); - REQUIRE(oss.str() == cmds[i] + " 0\n"); - } - { - std::ostringstream oss1, oss2; - caller.call(cmds[i], {"1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == cmds[i] + " 1200\n"); - caller.call(cmds[i], {}, -1, GET, oss2); - REQUIRE(oss2.str() == cmds[i] + " 1200\n"); - } - for (int imod = 0; imod != det.size(); ++imod) { - if (det_type == defs::XILINX_CHIPTESTBOARD && - prev_val[imod] == -100) { - prev_val[imod] = 0; - } - det.setPower(indices[i], prev_val[imod], {imod}); - } - - } else { - REQUIRE_THROWS(caller.call(cmds[i], {}, -1, GET)); - } - for (int i = 0; i != det.size(); ++i) { - det.setPower(defs::V_POWER_A, prev_val[i], {i}); - } - } - else { - REQUIRE_THROWS(caller.call("v_a", {}, -1, GET)); - } -} - -TEST_CASE("v_b", "[.cmdcall]") { - Detector det; - Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPower(defs::V_POWER_B); - { - std::ostringstream oss1, oss2; - caller.call("v_b", {"1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "v_b 1200\n"); - caller.call("v_b", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "v_b 1200\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPower(defs::V_POWER_B, prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("v_b", {}, -1, GET)); - } -} - -TEST_CASE("v_c", "[.cmdcall]") { - Detector det; - Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPower(defs::V_POWER_C); - { - std::ostringstream oss1, oss2; - caller.call("v_c", {"1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "v_c 1200\n"); - caller.call("v_c", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "v_c 1200\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPower(defs::V_POWER_C, prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("v_c", {}, -1, GET)); - } -} - -TEST_CASE("v_d", "[.cmdcall]") { - Detector det; - Caller caller(&det); - auto det_type = det.getDetectorType().squash(); - if (det_type == defs::CHIPTESTBOARD || - det_type == defs::XILINX_CHIPTESTBOARD) { - auto prev_val = det.getPower(defs::V_POWER_D); - { - std::ostringstream oss1, oss2; - caller.call("v_d", {"1200"}, -1, PUT, oss1); - REQUIRE(oss1.str() == "v_d 1200\n"); - caller.call("v_d", {}, -1, GET, oss2); - REQUIRE(oss2.str() == "v_d 1200\n"); - } - for (int i = 0; i != det.size(); ++i) { - det.setPower(defs::V_POWER_D, prev_val[i], {i}); - } - } else { - REQUIRE_THROWS(caller.call("v_d", {}, -1, GET)); - } -} - TEST_CASE("v_io", "[.detectorintegration]") { Detector det; Caller caller(&det); diff --git a/slsDetectorSoftware/tests/Caller/test-Caller.cpp b/slsDetectorSoftware/tests/Caller/test-Caller.cpp index 24aa40ef3..c96cf1026 100644 --- a/slsDetectorSoftware/tests/Caller/test-Caller.cpp +++ b/slsDetectorSoftware/tests/Caller/test-Caller.cpp @@ -46,9 +46,10 @@ TEST_CASE("config", "[.detectorintegration]") { // free: not testing -TEST_CASE("parameters", "[.cmdcall]") { +void test_include_file(const std::string &cmd) { Detector det; Caller caller(&det); + // put only REQUIRE_THROWS(caller.call(cmd, {}, -1, GET)); diff --git a/slsSupportLib/src/ClientSocket.cpp b/slsSupportLib/src/ClientSocket.cpp index 6dc6aac42..dcdfa31f3 100644 --- a/slsSupportLib/src/ClientSocket.cpp +++ b/slsSupportLib/src/ClientSocket.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -27,9 +26,12 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host, if (getaddrinfo(host.c_str(), nullptr, &hints, &result) != 0) { + std::ostringstream msg; - auto msg = fmt::format("Cannot resolve {} hostname: '{}'", to_lower(socketType), host); - throwError(msg); + msg << "Cannot resolve " << to_lower(socketType) << " hostname: '" + << host << "'"; + + throwError(msg.str()); } // TODO! Erik, results could have multiple entries do we need to loop @@ -43,11 +45,13 @@ ClientSocket::ClientSocket(std::string stype, const std::string &host, if (::connect(getSocketId(), (struct sockaddr *)&serverAddr, sizeof(serverAddr)) != 0) { freeaddrinfo(result); - auto msg = fmt::format( - "Cannot connect to {} on {}:{}\n", - to_lower(socketType), host, port); - throwError(msg); + std::ostringstream msg; + + msg << "Cannot connect to " << to_lower(socketType) << " on " << host + << ":" << port; + + throwError(msg.str()); } freeaddrinfo(result); } @@ -58,8 +62,11 @@ ClientSocket::ClientSocket(std::string sType, struct sockaddr_in addr) if (::connect(getSocketId(), (struct sockaddr *)&addr, sizeof(addr)) != 0) { char address[INET_ADDRSTRLEN]; inet_ntop(AF_INET, &addr.sin_addr, address, INET_ADDRSTRLEN); - auto msg = fmt::format("Cannot connect to {} on {}:{}", to_lower(socketType), address, addr.sin_port); - throwError(msg); + std::ostringstream msg; + + msg << "Cannot connect to " << to_lower(socketType) << " on " << address + << ":" << addr.sin_port; + throwError(msg.str()); } } @@ -99,8 +106,10 @@ void ClientSocket::readReply(int &ret, void *retval, size_t retval_size) { } // debugging catch (SocketError &e) { - auto msg = fmt::format("While reading reply from {} {}", to_lower(socketType), e.what()); - throwError(msg); + std::ostringstream msg; + msg << "While reading reply from " << to_lower(socketType) << " " + << e.what(); + throwError(msg.str()); } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 48e2991a7..a7ca6eba7 100755 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,9 +59,4 @@ catch_discover_tests(tests) configure_file(scripts/test_simulators.py ${CMAKE_BINARY_DIR}/bin/test_simulators.py COPYONLY) configure_file(scripts/test_frame_synchronizer.py ${CMAKE_BINARY_DIR}/bin/test_frame_synchronizer.py COPYONLY) -configure_file(scripts/utils_for_test.py ${CMAKE_BINARY_DIR}/bin/utils_for_test.py COPYONLY) -<<<<<<< HEAD -configure_file(scripts/test_roi.py ${CMAKE_BINARY_DIR}/bin/test_roi.py COPYONLY) -configure_file(scripts/test_free.py ${CMAKE_BINARY_DIR}/bin/test_free.py COPYONLY) -======= ->>>>>>> 28b2aa967 (Dev/add simulator tests in GitHub workflows (#1337)) +configure_file(scripts/utils_for_test.py ${CMAKE_BINARY_DIR}/bin/utils_for_test.py COPYONLY) \ No newline at end of file