Add JFJochReceiverTest_Cancel

This commit is contained in:
2023-05-08 21:22:28 +02:00
parent 0f4eccf733
commit 96cd6fe552
2 changed files with 36 additions and 1 deletions

View File

@@ -38,7 +38,7 @@ JFJochProtoBuf::ReceiverOutput RunJFJochReceiverTest(std::vector<AcquisitionDevi
if (x.GetImageNum() > 0) {
// Initial communication
if (abort) {
std::this_thread::sleep_for(std::chrono::seconds(180));
std::this_thread::sleep_for(std::chrono::seconds(60));
service.Cancel(&grpc_context, nullptr, nullptr);
}
}

View File

@@ -501,3 +501,38 @@ TEST_CASE("JFJochReceiverTest_PacketLost_Raw", "[JFJochReceiver]") {
REQUIRE(receiver_out.efficiency() < 1.0);
REQUIRE(receiver_out.images_sent() == x.GetImageNum());
}
TEST_CASE("JFJochReceiverTest_Cancel", "[JFJochReceiver]") {
DiffractionExperiment x(DetectorGeometry(2));
const uint16_t nthreads = 4;
std::vector<uint16_t> frame_in(RAW_MODULE_SIZE);
for (auto &i: frame_in) i = 776;
x.Mode(DetectorMode::Raw);
x.PedestalG0Frames(0).NumTriggers(1)
.UseInternalPacketGenerator(false).ImagesPerTrigger(4).PhotonEnergy_keV(12.4);
std::vector<std::unique_ptr<AcquisitionDevice>> aq_devices;
for (int i = 0; i < x.GetDataStreamsNum(); i++) {
auto test = new HLSSimulatedDevice(i, 64);
test->CreatePackets(x, 1, 1, 0, frame_in.data(), false);
test->CreatePackets(x, 1, 1, 1, frame_in.data(), false);
test->CreatePackets(x, 2, 1, 0, frame_in.data(), false);
test->CreatePackets(x, 2, 1, 1, frame_in.data(), false);
test->CreatePackets(x, 3, 1, 0, frame_in.data(), false);
test->CreatePackets(x, 3, 1, 1, frame_in.data(), false);
aq_devices.emplace_back(test);
}
Logger logger("JFJochReceiverTest_Cancelw");
JFCalibration calib(x);
std::vector<AcquisitionDevice *> tmp_devices;
for (const auto &i: aq_devices)
tmp_devices.emplace_back(i.get());
TestImagePusher pusher(x.GetImageNum() - 1);
auto receiver_out = RunJFJochReceiverTest(tmp_devices, pusher, x, logger, calib, nthreads, true);
REQUIRE(receiver_out.cancelled());
}