Formatted package
This commit is contained in:
Dhanya Thattil
2022-08-05 15:39:34 +02:00
committed by GitHub
parent 7173785b29
commit 6bf9dbf6d3
89 changed files with 1366 additions and 1210 deletions

View File

@ -10,5 +10,4 @@ void test_dac(slsDetectorDefs::dacIndex index, const std::string &dacname,
void test_onchip_dac(slsDetectorDefs::dacIndex index,
const std::string &dacname, int dacvalue);
} // namespace sls

View File

@ -511,18 +511,23 @@ TEST_CASE("interpolation", "[.cmd]") {
std::ostringstream oss;
proxy.Call("interpolation", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "interpolation 1\n");
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
7);
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == disabledDacValue);
REQUIRE(det.getCounterMask().tsquash(
"inconsistent counter mask") == 7);
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
.tsquash("inconsistent vth3 dac value") ==
disabledDacValue);
}
{
std::ostringstream oss;
proxy.Call("interpolation", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "interpolation 0\n");
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") ==
fixedMask[i]);
uint32_t expectedVth3DacVal = (fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == expectedVth3DacVal);
REQUIRE(det.getCounterMask().tsquash(
"inconsistent counter mask") == fixedMask[i]);
uint32_t expectedVth3DacVal =
(fixedMask[i] & 0x4 ? fixedVth3DacVal : disabledDacValue);
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
.tsquash("inconsistent vth3 dac value") ==
expectedVth3DacVal);
}
}
@ -535,7 +540,6 @@ TEST_CASE("interpolation", "[.cmd]") {
det.setCounterMask(prev_mask[i], {i});
det.setInterpolation(prev_interpolation[i], {i});
det.setDAC(defs::VTH3, prev_vth3DacVal[i], 0, {i});
}
} else {
REQUIRE_THROWS(proxy.Call("interpolation", {}, -1, GET));
@ -567,23 +571,38 @@ TEST_CASE("pumpprobe", "[.cmd]") {
std::ostringstream oss;
proxy.Call("pumpprobe", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "pumpprobe 1\n");
REQUIRE(det.getDAC(defs::VTH1, 0, {0}).tsquash("inconsistent vth2 dac value") == disabledDacValue);
REQUIRE(det.getDAC(defs::VTH2, 0, {0}).tsquash("inconsistent vth2 dac value") == fixedVthDacVal);
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth2 dac value") == disabledDacValue);
}
// interpolation and pump probe
REQUIRE(det.getDAC(defs::VTH1, 0, {0})
.tsquash("inconsistent vth2 dac value") ==
disabledDacValue);
REQUIRE(det.getDAC(defs::VTH2, 0, {0})
.tsquash("inconsistent vth2 dac value") ==
fixedVthDacVal);
REQUIRE(det.getDAC(defs::VTH3, 0, {0})
.tsquash("inconsistent vth2 dac value") ==
disabledDacValue);
}
// interpolation and pump probe
REQUIRE_THROWS(proxy.Call("interpolation", {"1"}, -1, PUT));
{
// none
std::ostringstream oss;
proxy.Call("pumpprobe", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "pumpprobe 0\n");
REQUIRE(det.getCounterMask().tsquash("inconsistent counter mask") == 7);
REQUIRE(det.getDAC(defs::VTH1, 0, {0}).tsquash("inconsistent vth1 dac value") == (fixedMask[i] & 0x1 ? fixedVthDacVal : disabledDacValue));
REQUIRE(det.getDAC(defs::VTH2, 0, {0}).tsquash("inconsistent vth2 dac value") == (fixedMask[i] & 0x2 ? fixedVthDacVal : disabledDacValue));
REQUIRE(det.getDAC(defs::VTH3, 0, {0}).tsquash("inconsistent vth3 dac value") == (fixedMask[i] & 0x4 ? fixedVthDacVal : disabledDacValue));
}
REQUIRE(det.getCounterMask().tsquash(
"inconsistent counter mask") == 7);
REQUIRE(
det.getDAC(defs::VTH1, 0, {0})
.tsquash("inconsistent vth1 dac value") ==
(fixedMask[i] & 0x1 ? fixedVthDacVal : disabledDacValue));
REQUIRE(
det.getDAC(defs::VTH2, 0, {0})
.tsquash("inconsistent vth2 dac value") ==
(fixedMask[i] & 0x2 ? fixedVthDacVal : disabledDacValue));
REQUIRE(
det.getDAC(defs::VTH3, 0, {0})
.tsquash("inconsistent vth3 dac value") ==
(fixedMask[i] & 0x4 ? fixedVthDacVal : disabledDacValue));
}
}
{
std::ostringstream oss;

View File

@ -170,12 +170,12 @@ TEST_CASE("patloop", "[.cmd]") {
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patloop" + sLoop;
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"0x20", "0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n");
}
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " [0x0020, 0x005c]\n");
@ -190,9 +190,10 @@ TEST_CASE("patloop", "[.cmd]") {
std::ostringstream oss;
proxy.Call("patloop", {sLoop}, -1, GET, oss);
REQUIRE(oss.str() == "patloop [0x0020, 0x005c]\n");
}
}
for (int iDet = 0; iDet != det.size(); ++iDet) {
det.setPatternLoopAddresses(iLoop, prev_val[iDet][0], prev_val[iDet][1], {iDet});
det.setPatternLoopAddresses(iLoop, prev_val[iDet][0],
prev_val[iDet][1], {iDet});
}
}
} else {
@ -216,12 +217,12 @@ TEST_CASE("patnloop", "[.cmd]") {
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patnloop" + sLoop;
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"5"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 5\n");
}
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 5\n");
@ -262,12 +263,12 @@ TEST_CASE("patwait", "[.cmd]") {
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patwait" + sLoop;
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"0x5c"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n");
}
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 0x005c\n");
@ -308,12 +309,12 @@ TEST_CASE("patwaittime", "[.cmd]") {
std::string sLoop = ToString(iLoop);
if (iLoop < 3) {
std::string deprecatedCmd = "patwaittime" + sLoop;
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {"8589936640"}, -1, PUT, oss);
REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n");
}
{// depreciated
{ // depreciated
std::ostringstream oss;
proxy.Call(deprecatedCmd, {}, -1, GET, oss);
REQUIRE(oss.str() == deprecatedCmd + " 8589936640\n");

View File

@ -465,7 +465,8 @@ TEST_CASE("rx_roi", "[.cmd]") {
REQUIRE(oss.str() == "rx_roi [10, 15]\n");
}
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("rx_roi", {"10", "15", "25", "30"}, -1, PUT));
REQUIRE_THROWS(
proxy.Call("rx_roi", {"10", "15", "25", "30"}, -1, PUT));
}
// 2d
else {
@ -481,10 +482,18 @@ TEST_CASE("rx_roi", "[.cmd]") {
}
{
std::ostringstream oss;
proxy.Call("rx_roi", {"1", std::to_string(detsize.x - 5), "1", std::to_string(detsize.y - 5)}, -1, PUT, oss);
REQUIRE(oss.str() == std::string("rx_roi [1, ") + std::to_string(detsize.x - 5) + std::string(", ") + std::to_string(detsize.y - 5) + std::string(", 1]\n"));
}
REQUIRE_THROWS(proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
proxy.Call("rx_roi",
{"1", std::to_string(detsize.x - 5), "1",
std::to_string(detsize.y - 5)},
-1, PUT, oss);
REQUIRE(oss.str() == std::string("rx_roi [1, ") +
std::to_string(detsize.x - 5) +
std::string(", ") +
std::to_string(detsize.y - 5) +
std::string(", 1]\n"));
}
REQUIRE_THROWS(
proxy.Call("rx_roi", {"-1", "-1", "-1", "-1"}, -1, PUT));
}
for (int i = 0; i != det.size(); ++i) {
@ -574,7 +583,7 @@ TEST_CASE("fname", "[.cmd]") {
}
REQUIRE_THROWS(proxy.Call("fname", {"fdf/dfd"}, -1, PUT));
REQUIRE_THROWS(proxy.Call("fname", {"fdf dfd"}, -1, PUT));
for (int i = 0; i != det.size(); ++i) {
det.setFileNamePrefix(prev_val[i], {i});
}

View File

@ -16,15 +16,14 @@ namespace sls {
using test::GET;
using test::PUT;
TEST_CASE("Calling help doesn't throw or cause segfault"){
//Dont add [.cmd] tag this should run with normal tests
TEST_CASE("Calling help doesn't throw or cause segfault") {
// Dont add [.cmd] tag this should run with normal tests
CmdProxy proxy(nullptr);
auto commands = proxy.GetProxyCommands();
std::ostringstream os;
for (const auto &cmd : commands)
REQUIRE_NOTHROW(proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
REQUIRE_NOTHROW(
proxy.Call(cmd, {}, -1, slsDetectorDefs::HELP_ACTION, os));
}
TEST_CASE("Unknown command", "[.cmd]") {
@ -338,9 +337,8 @@ TEST_CASE("threshold", "[.cmd]") {
det.setTrimEnergies(prev_energies);
for (int i = 0; i != det.size(); ++i) {
if (prev_threshold[i][0] >= 0) {
std::cout
<< "prev cvalues:" << ToString(prev_threshold[i])
<< std::endl;
std::cout << "prev cvalues:" << ToString(prev_threshold[i])
<< std::endl;
det.setThresholdEnergy(prev_threshold[i], prev_settings,
true, {i});
}
@ -585,7 +583,8 @@ TEST_CASE("master", "[.cmd]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 || det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
if (det_type == defs::EIGER || det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD || det_type == defs::GOTTHARD2) {
REQUIRE_NOTHROW(proxy.Call("master", {}, -1, GET));
if (det_type == defs::EIGER) {
// get previous master
@ -2265,10 +2264,8 @@ TEST_CASE("scan", "[.cmd]") {
{
std::ostringstream oss;
proxy.Call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT,
oss);
CHECK(oss.str() ==
"scan [" + ToString(ind) + ", 500, 1500, 500]\n");
proxy.Call("scan", {ToString(ind), "500", "1500", "500"}, -1, PUT, oss);
CHECK(oss.str() == "scan [" + ToString(ind) + ", 500, 1500, 500]\n");
}
{
std::ostringstream oss;
@ -2279,8 +2276,8 @@ TEST_CASE("scan", "[.cmd]") {
}
{
std::ostringstream oss;
proxy.Call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1,
PUT, oss);
proxy.Call("scan", {ToString(ind), "500", "1500", "500", "2s"}, -1, PUT,
oss);
CHECK(oss.str() ==
"scan [" + ToString(ind) + ", 500, 1500, 500, 2s]\n");
}
@ -2305,16 +2302,14 @@ TEST_CASE("scan", "[.cmd]") {
std::ostringstream oss;
proxy.Call("scan", {ToString(ind), "1500", "500", "-500"}, -1, PUT,
oss);
CHECK(oss.str() ==
"scan [" + ToString(ind) + ", 1500, 500, -500]\n");
CHECK(oss.str() == "scan [" + ToString(ind) + ", 1500, 500, -500]\n");
}
CHECK_THROWS(proxy.Call(
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1,
PUT));
CHECK_THROWS(proxy.Call("scan", {ToString(ind), "500", "1500", "-500"},
-1, PUT));
CHECK_THROWS(proxy.Call("scan", {ToString(ind), "1500", "500", "500"},
-1, PUT));
"scan", {ToString(notImplementedInd), "500", "1500", "500"}, -1, PUT));
CHECK_THROWS(
proxy.Call("scan", {ToString(ind), "500", "1500", "-500"}, -1, PUT));
CHECK_THROWS(
proxy.Call("scan", {ToString(ind), "1500", "500", "500"}, -1, PUT));
if (det_type == defs::MYTHEN3 || defs::EIGER) {
{

View File

@ -3,14 +3,14 @@
#include <stdlib.h>
#include "SharedMemory.h"
#include "CtbConfig.h"
#include "SharedMemory.h"
#include <fstream>
namespace sls {
TEST_CASE("Default construction"){
static_assert(sizeof(CtbConfig) == 360); // 18*20
TEST_CASE("Default construction") {
static_assert(sizeof(CtbConfig) == 360); // 18*20
CtbConfig c;
auto names = c.getDacNames();
@ -21,7 +21,7 @@ TEST_CASE("Default construction"){
REQUIRE(names[3] == "dac3");
}
TEST_CASE("Set and get a single dac name"){
TEST_CASE("Set and get a single dac name") {
CtbConfig c;
c.setDacName(3, "vrf");
auto names = c.getDacNames();
@ -30,28 +30,28 @@ TEST_CASE("Set and get a single dac name"){
REQUIRE(names[3] == "vrf");
}
TEST_CASE("Set a name that is too large throws"){
TEST_CASE("Set a name that is too large throws") {
CtbConfig c;
REQUIRE_THROWS(c.setDacName(3, "somestringthatisreallytolongforadatac"));
}
TEST_CASE("Length of dac name cannot be 0"){
TEST_CASE("Length of dac name cannot be 0") {
CtbConfig c;
REQUIRE_THROWS(c.setDacName(1, ""));
}
TEST_CASE("Copy a CTB config"){
TEST_CASE("Copy a CTB config") {
CtbConfig c1;
c1.setDacName(5, "somename");
auto c2 = c1;
//change the name on the first object
//to detecto shallow copy
// change the name on the first object
// to detecto shallow copy
c1.setDacName(5, "someothername");
REQUIRE(c2.getDacName(5) == "somename");
}
TEST_CASE("Move CtbConfig "){
TEST_CASE("Move CtbConfig ") {
CtbConfig c1;
c1.setDacName(3, "yetanothername");
CtbConfig c2(std::move(c1));

View File

@ -97,7 +97,6 @@ TEST_CASE("Move SharedMemory", "[detector]") {
shm.createSharedMemory();
shm()->x = 9;
SharedMemory<Data> shm2(shm_id + 1, -1);
shm2 = std::move(shm); // shm is now a moved from object!
@ -132,13 +131,12 @@ TEST_CASE("Create several shared memories", "[detector]") {
}
}
TEST_CASE("Create create a shared memory with a tag"){
TEST_CASE("Create create a shared memory with a tag") {
SharedMemory<int> shm(0, -1, "ctbdacs");
REQUIRE(shm.getName() == "/slsDetectorPackage_detector_0_ctbdacs");
}
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set") {
// if SLSDETNAME is already set we unset it but
// save the value
@ -156,10 +154,9 @@ TEST_CASE("Create create a shared memory with a tag when SLSDETNAME is set"){
unsetenv(SHM_ENV_NAME);
else
setenv(SHM_ENV_NAME, old_slsdetname.c_str(), 1);
}
TEST_CASE("map int64 to int32 throws"){
TEST_CASE("map int64 to int32 throws") {
SharedMemory<int32_t> shm(shm_id, -1);
shm.createSharedMemory();
*shm() = 7;