more tests

This commit is contained in:
maliakal_d 2020-03-31 18:19:32 +02:00
parent 83010de9f4
commit 262b4b0b16
6 changed files with 77 additions and 43 deletions

View File

@ -1331,6 +1331,9 @@ int* getDetectorPosition() {
// Detector Specific
int checkDetectorType() {
#ifdef VIRTUAL
return OK;
#endif
LOG(logINFO, ("Checking type of module\n"));
FILE* fd = fopen(TYPE_FILE_NAME, "r");
if (fd == NULL) {

View File

@ -1098,11 +1098,6 @@ int getADC(enum ADCINDEX ind){
}
int setHighVoltage(int val){
#ifdef VIRTUAL
if (val >= 0)
highvoltage = val;
return highvoltage;
#endif
u_int32_t addr = HV_REG;
u_int32_t sel = 0x0;

View File

@ -1284,7 +1284,9 @@ int powerChip (int on){
bus_w(CHIP_POWER_REG, bus_r(CHIP_POWER_REG) & ~CHIP_POWER_ENABLE_MSK);
}
}
#ifdef VIRTUAL
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_ENABLE_MSK) >> CHIP_POWER_ENABLE_OFST);
#endif
return ((bus_r(CHIP_POWER_REG) & CHIP_POWER_STATUS_MSK) >> CHIP_POWER_STATUS_OFST);
}

View File

@ -1112,6 +1112,9 @@ uint64_t getPatternBitMask() {
}
int checkDetectorType() {
#ifdef VIRTUAL
return OK;
#endif
LOG(logINFO, ("Checking type of module\n"));
FILE* fd = fopen(TYPE_FILE_NAME, "r");
if (fd == NULL) {

View File

@ -13,37 +13,7 @@ using sls::Detector;
using test::GET;
using test::PUT;
TEST_CASE("powerchip", "[.cmd][!mayfail]") {
// TODO! this test currently fails with the
// virtual detecto server
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU) {
auto pc = det.getPowerChip();
{
std::ostringstream oss;
proxy.Call("powerchip", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "powerchip 1\n");
}
{
std::ostringstream oss;
proxy.Call("powerchip", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "powerchip 0\n");
}
{
std::ostringstream oss;
proxy.Call("powerchip", {}, -1, GET, oss);
REQUIRE(oss.str() == "powerchip 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPowerChip(pc[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("powerchip", {}, -1, GET));
}
}
TEST_CASE("nframes", "[.cmd]") {
Detector det;

View File

@ -702,26 +702,26 @@ TEST_CASE("vhighvoltage", "[.cmd][.new]") {
else if (det_type == defs::EIGER) {
{
std::ostringstream oss1, oss2;
proxy.Call("vhighvoltage", {"50"}, -1, PUT, oss1);
proxy.Call("vhighvoltage", {"50"}, 0, PUT, oss1);
REQUIRE(oss1.str() == "vhighvoltage 50\n");
std::this_thread::sleep_for(std::chrono::seconds(2));
proxy.Call("vhighvoltage", {}, -1, GET, oss2);
proxy.Call("vhighvoltage", {}, 0, GET, oss2);
REQUIRE(oss2.str() == "vhighvoltage 50\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("vhighvoltage", {"120"}, -1, PUT, oss1);
proxy.Call("vhighvoltage", {"120"}, 0, PUT, oss1);
REQUIRE(oss1.str() == "vhighvoltage 120\n");
std::this_thread::sleep_for(std::chrono::seconds(2));
proxy.Call("vhighvoltage", {}, -1, GET, oss2);
proxy.Call("vhighvoltage", {}, 0, GET, oss2);
REQUIRE(oss2.str() == "vhighvoltage 120\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("vhighvoltage", {"0"}, -1, PUT, oss1);
proxy.Call("vhighvoltage", {"0"}, 0, PUT, oss1);
REQUIRE(oss1.str() == "vhighvoltage 0\n");
std::this_thread::sleep_for(std::chrono::seconds(2));
proxy.Call("vhighvoltage", {}, -1, GET, oss2);
proxy.Call("vhighvoltage", {}, 0, GET, oss2);
REQUIRE(oss2.str() == "vhighvoltage 0\n");
}
}
@ -754,9 +754,70 @@ TEST_CASE("vhighvoltage", "[.cmd][.new]") {
}
}
TEST_CASE("powerchip", "[.cmd][.new]") {
// TODO! this test currently fails with the
// virtual detecto server
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::JUNGFRAU ||
det_type == defs::MYTHEN3 ||
det_type == defs::GOTTHARD2 ||
det_type == defs::MOENCH) {
auto prev_val = det.getPowerChip();
{
std::ostringstream oss;
proxy.Call("powerchip", {"1"}, -1, PUT, oss);
REQUIRE(oss.str() == "powerchip 1\n");
}
{
std::ostringstream oss;
proxy.Call("powerchip", {"0"}, -1, PUT, oss);
REQUIRE(oss.str() == "powerchip 0\n");
}
{
std::ostringstream oss;
proxy.Call("powerchip", {}, -1, GET, oss);
REQUIRE(oss.str() == "powerchip 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setPowerChip(prev_val[i], {i});
}
} else {
REQUIRE_THROWS(proxy.Call("powerchip", {}, -1, GET));
}
}
TEST_CASE("imagetest", "[.cmd][.new]") {
Detector det;
CmdProxy proxy(&det);
auto det_type = det.getDetectorType().squash();
if (det_type == defs::GOTTHARD) {
auto prev_val = det.getImageTestMode();
{
std::ostringstream oss1, oss2;
proxy.Call("imagetest", {"1"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "imagetest 1\n");
proxy.Call("imagetest", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "imagetest 1\n");
}
{
std::ostringstream oss1, oss2;
proxy.Call("imagetest", {"0"}, -1, PUT, oss1);
REQUIRE(oss1.str() == "imagetest 0\n");
proxy.Call("imagetest", {}, -1, GET, oss2);
REQUIRE(oss2.str() == "imagetest 0\n");
}
for (int i = 0; i != det.size(); ++i) {
det.setImageTestMode(prev_val[i], {i});
}
} else if (det_type != defs::JUNGFRAU &&
det_type != defs::EIGER) {
// wont fail for eiger and jungfrau virtual servers
REQUIRE_THROWS(proxy.Call("imagetest", {}, -1, GET));
}
}