diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 15e5a031f..9b678d7db 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -64,6 +64,7 @@ ADD_EXECUTABLE(jfjoch_test ../common/DiffractionExperiment.h CheckImageOutput.h FPGAIntegrationTest.cpp + MockAcquisitionDeviceTest.cpp StrongPixelSetTest.cpp AdaptiveThresholdTest.cpp AdaptiveSpotFinderCPUTest.cpp diff --git a/tests/MockAcquisitionDeviceTest.cpp b/tests/MockAcquisitionDeviceTest.cpp new file mode 100644 index 000000000..14fe585be --- /dev/null +++ b/tests/MockAcquisitionDeviceTest.cpp @@ -0,0 +1,514 @@ +// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute +// SPDX-License-Identifier: GPL-3.0-only + +// MockAcquisitionDevice against HLSSimulatedDevice: the same scenario runs on the HLS simulation, what the card +// wrote is recorded and given to the mock, and the host must see the same on both - the buffers, which module +// went to which buffer (i.e. the order of completions), counters and, for the receiver, its results. +// Then receiver tests of JFJochReceiverIntegrationTest.cpp, run on the mock. + +#include +#include + +#include "../acquisition_device/HLSSimulatedDevice.h" +#include "../acquisition_device/MockAcquisitionDevice.h" +#include "../image_pusher/TestImagePusher.h" +#include "../jungfrau/JFPedestalCalc.h" +#include "../receiver/JFJochReceiverService.h" +#include "../receiver/JFJochReceiverTest.h" + +namespace { + // HLS simulation that can give away everything it wrote to the host - as long as no buffer was used twice + class RecordingHLSDevice : public HLSSimulatedDevice { + public: + using HLSSimulatedDevice::HLSSimulatedDevice; + + void CopyOutputs(MockAcquisitionDevice &mock) const { + for (size_t h = 0; h < buffer_device.size(); h++) { + const DeviceOutput *output = GetDeviceOutput(h); + if (output->module_statistics.packet_count > 0) + mock.SetOutput(output->module_statistics.frame_number, output->module_statistics.module_number, + *output); + } + } + }; + + std::unique_ptr OutputWithPixels(const uint16_t *pixels) { + auto ret = std::make_unique(); + memcpy(ret->pixels, pixels, RAW_MODULE_SIZE * sizeof(uint16_t)); + return ret; + } + + void CompareDevices(const AcquisitionDevice &hls, const AcquisitionDevice &mock, const DiffractionExperiment &x) { + CHECK(hls.GetBytesReceived() == mock.GetBytesReceived()); + CHECK(hls.Counters().GetSlowestFrameNumber() == mock.Counters().GetSlowestFrameNumber()); + CHECK(hls.Counters().GetFastestFrameNumber() == mock.Counters().GetFastestFrameNumber()); + + auto stats_hls = hls.GetStatistics(); + auto stats_mock = mock.GetStatistics(); + CHECK(stats_hls.good_packets == stats_mock.good_packets); + CHECK(stats_hls.packets_expected == stats_mock.packets_expected); + CHECK(stats_hls.packets_received_per_module == stats_mock.packets_received_per_module); + + int64_t frames = x.GetFrameNum() / x.GetFPGASummation(); + for (int64_t f = 0; f < frames; f++) { + for (int m = 0; m < x.GetModulesNum(); m++) { + INFO("frame " << f << " module " << m); + auto handle = hls.Counters().GetBufferHandle(f, m); + // The same buffer means the same order of completions + CHECK(handle == mock.Counters().GetBufferHandle(f, m)); + CHECK(hls.Counters().CalculateDelay(f, m) == mock.Counters().CalculateDelay(f, m)); + CHECK(hls.Counters().IsFullModuleCollected(f, m) == mock.Counters().IsFullModuleCollected(f, m)); + if (handle != AcquisitionCounters::HandleNotFound) + CHECK(memcmp(hls.GetDeviceOutput(f, m), mock.GetDeviceOutput(f, m), sizeof(DeviceOutput)) == 0); + } + } + } + + // Runs the same packets on both devices, the mock with what the HLS simulation wrote + template + void CompareOnPackets(const DiffractionExperiment &x, Packets packets) { + RecordingHLSDevice hls(0, 64); + packets(hls); + REQUIRE_NOTHROW(hls.StartAction(x)); + REQUIRE_NOTHROW(hls.WaitForActionComplete()); + REQUIRE(hls.GetBytesReceived() > 0); + + MockAcquisitionDevice mock(0, 64); + hls.CopyOutputs(mock); + packets(mock); + REQUIRE_NOTHROW(mock.StartAction(x)); + REQUIRE_NOTHROW(mock.WaitForActionComplete()); + + CompareDevices(hls, mock, x); + } +} + +TEST_CASE("MockAcquisitionDevice_SameAsHLS_Packets", "[MockAcquisitionDevice][HLS]") { + const uint16_t nmodules = 4; + DiffractionExperiment x(DetJF(nmodules)); + x.Raw(); + x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1); + + std::vector module(RAW_MODULE_SIZE); + for (int i = 0; i < RAW_MODULE_SIZE; i++) + module[i] = (7 * i + 534 + 5 * i * i) % UINT16_MAX; + + CompareOnPackets(x, [&](auto &d) { + // Frame 1: module 0 incomplete, both halves; module 1 missing; modules 2 and 3 complete + d.CreateJFPacket(x, 1, 0, 0, module.data()); + d.CreateJFPacket(x, 1, 64, 0, module.data()); + d.CreateJFPackets(x, 1, 1, 2, module.data()); + d.CreateJFPackets(x, 1, 1, 3, module.data()); + // Frame 3 before frame 2 for module 0; one packet with a wrong length, one with an Ethernet error + d.CreateJFPacket(x, 3, 5, 0, module.data()); + d.CreateJFPacket(x, 2, 6, 0, module.data()); + d.CreateJFPacket(x, 2, 7, 0, module.data(), -1); + d.CreateJFPacket(x, 2, 8, 0, module.data(), 0, 1); + d.CreateJFPackets(x, 2, 1, 1, module.data()); + d.CreateJFPackets(x, 3, 1, 3, module.data()); + // A frame after the last one + d.CreateJFPacket(x, 4, 1, 2, module.data()); + d.CreateFinalPacket(x); + }); +} + +TEST_CASE("MockAcquisitionDevice_SameAsHLS_Summation", "[MockAcquisitionDevice][HLS]") { + const uint16_t nmodules = 2; + DiffractionExperiment x(DetJF(nmodules)); + x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1).Summation(2) + .JungfrauConvPhotonCnt(false).PixelSigned(true).BitDepthImage(32); + REQUIRE(x.GetFPGASummation() == 2); + + std::vector module(RAW_MODULE_SIZE); + std::mt19937 g(1387); + std::uniform_int_distribution dist(0, UINT16_MAX); + for (auto &i: module) + i = dist(g); + + CompareOnPackets(x, [&](auto &d) { + for (int f = 1; f <= 6; f++) { + d.CreateJFPackets(x, f, 1, 0, module.data()); + // Second frame of the second image is missing for module 1, so the whole image is dropped + if (f != 4) + d.CreateJFPackets(x, f, 1, 1, module.data()); + } + d.CreateFinalPacket(x); + }); +} + +TEST_CASE("MockAcquisitionDevice_SameAsHLS_EIGER", "[MockAcquisitionDevice][HLS]") { + DiffractionExperiment x(DetEIGER(1)); + x.Raw(); + x.PedestalG0Frames(0).ImagesPerTrigger(1).NumTriggers(1); + + std::vector module(RAW_MODULE_SIZE); + for (int i = 0; i < RAW_MODULE_SIZE; i++) + module[i] = i % (UINT16_MAX - 11); + + CompareOnPackets(x, [&](auto &d) { + for (int row = 0; row < 2; row++) { + for (int col = 0; col < 2; col++) { + for (int i = 0; i < 64; i++) { + if ((i != 10) || (col != row)) + d.CreateEIGERPacket(x, 1, i, 0, col, row, module.data() + 2048 * (128 * row + col + 2 * i)); + } + } + } + d.CreateFinalPacket(x); + }); +} + +TEST_CASE("MockAcquisitionDevice_SameAsHLS_InternalGenerator", "[MockAcquisitionDevice][HLS]") { + const uint16_t nmodules = 2; + DiffractionExperiment x(DetJF(nmodules)); + x.Raw(); + x.UseInternalPacketGenerator(true).ImagesPerTrigger(3).PedestalG0Frames(0); + + CompareOnPackets(x, [&](auto &d) {}); +} + +TEST_CASE("MockAcquisitionDevice_SameAsHLS_Cancel", "[MockAcquisitionDevice][HLS]") { + DiffractionExperiment x(DetJF(4)); + x.Raw(); + x.PedestalG0Frames(0).ImagesPerTrigger(5).NumTriggers(1); + + HLSSimulatedDevice hls(0, 64); + MockAcquisitionDevice mock(0, 64); + for (AcquisitionDevice *d: {static_cast(&hls), static_cast(&mock)}) { + REQUIRE_NOTHROW(d->StartAction(x)); + d->Cancel(); + REQUIRE_NOTHROW(d->WaitForActionComplete()); + CHECK(d->Counters().GetSlowestFrameNumber() == 0); + CHECK(d->GetBytesReceived() == 0); + } +} + +// The receiver on the HLS simulation, and on the mock with what the HLS simulation wrote during that run +TEST_CASE("MockAcquisitionDevice_SameAsHLS_Receiver", "[MockAcquisitionDevice][HLS]") { + const uint16_t nmodules = 2; + DiffractionExperiment x(DetJF(nmodules)); + x.Conversion(); + x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true).ImagesPerTrigger(4) + .IncidentEnergy_keV(12.4).DetectorDistance_mm(75).BeamX_pxl(500).BeamY_pxl(600) + .Compression(CompressionAlgorithm::BSHUF_LZ4); + + JFCalibration calib(x); + std::vector pedestal(RAW_MODULE_SIZE); + for (int m = 0; m < nmodules; m++) { + for (int i = 0; i < RAW_MODULE_SIZE; i++) + pedestal[i] = 3000 + 10 * m + i % 50; + calib.Pedestal(m, 0).LoadPedestal(pedestal); + } + + // A few photons of background, some spots, one saturated and one bad pixel + std::vector raw(nmodules * RAW_MODULE_SIZE); + std::mt19937 g(1900); + std::uniform_int_distribution background(0, 300); + std::uniform_int_distribution where(20 * RAW_MODULE_COLS, (RAW_MODULE_LINES - 20) * RAW_MODULE_COLS); + for (int i = 0; i < raw.size(); i++) + raw[i] = 3000 + 10 * (i / RAW_MODULE_SIZE) + i % 50 + background(g); + for (int s = 0; s < 80; s++) { + int i0 = where(g) + (s % nmodules) * RAW_MODULE_SIZE; + for (int y = 0; y < 3; y++) + for (int i = 0; i < 3; i++) + raw[i0 + y * RAW_MODULE_COLS + i] = 12000; + } + raw[50 * RAW_MODULE_COLS + 500] = 0xC000; + raw[60 * RAW_MODULE_COLS + 600] = 0xFFFF; + + SpotFindingSettings settings = DiffractionExperiment::DefaultDataProcessingSettings(); + settings.signal_to_noise_threshold = 3; + settings.photon_count_threshold = 2; + settings.min_pix_per_spot = 1; + settings.indexing = false; + + auto run = [&](AcquisitionDeviceGroup &devices, std::vector &image, std::vector> &plots) { + Logger logger("MockAcquisitionDevice_SameAsHLS_Receiver"); + TestImagePusher pusher(x.GetImageNum() - 1); + JFJochReceiverService service(devices, logger, pusher); + service.NumThreads(4); + service.SetSpotFindingSettings(settings); + service.LoadInternalGeneratorImage(x, raw, 0); + PixelMask mask(x); + service.Start(x, mask, &calib); + auto output = service.Stop(); + image = pusher.GetImage(); + for (auto type: {PlotType::SpotCount, PlotType::StrongPixels, PlotType::ErrorPixels, + PlotType::SaturatedPixels, PlotType::PixelSum, PlotType::MaxValue, + PlotType::BkgEstimate, PlotType::PacketsReceived}) { + std::vector v; + service.GetPlotRaw(v, type, ""); + plots.push_back(v); + } + std::vector azint; + service.GetPlotRaw(azint, PlotType::AzInt, ""); + plots.push_back(azint); + return output; + }; + + AcquisitionDeviceGroup hls_devices; + hls_devices.Add(std::make_unique(0, 64)); + std::vector hls_image; + std::vector> hls_plots; + auto hls_output = run(hls_devices, hls_image, hls_plots); + + auto mock = std::make_unique(0, 64); + dynamic_cast(hls_devices[0]).CopyOutputs(*mock); + AcquisitionDeviceGroup mock_devices; + mock_devices.Add(std::move(mock)); + std::vector mock_image; + std::vector> mock_plots; + auto mock_output = run(mock_devices, mock_image, mock_plots); + + REQUIRE(hls_output.status.images_sent == x.GetImageNum()); + CHECK(mock_output.status.images_sent == hls_output.status.images_sent); + CHECK(mock_output.status.max_image_number_sent == hls_output.status.max_image_number_sent); + CHECK(mock_output.status.compressed_size == hls_output.status.compressed_size); + CHECK(mock_output.efficiency == hls_output.efficiency); + CHECK(mock_output.received_packets == hls_output.received_packets); + CHECK(mock_output.expected_packets == hls_output.expected_packets); + CHECK(mock_image == hls_image); + REQUIRE(mock_plots.size() == hls_plots.size()); + for (int i = 0; i < hls_plots.size(); i++) { + INFO("plot " << i); + REQUIRE(mock_plots[i].size() == hls_plots[i].size()); + CHECK(memcmp(mock_plots[i].data(), hls_plots[i].data(), hls_plots[i].size() * sizeof(float)) == 0); + } +} + +// Receiver tests of JFJochReceiverIntegrationTest.cpp on the mock; the card output is given by the test + +TEST_CASE("MockAcquisitionDevice_JFJochReceiverTest_Raw", "[MockAcquisitionDevice]") { + DiffractionExperiment x(DetJF(4)); + const uint16_t nthreads = 4; + + x.Raw(); + x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true) + .ImagesPerTrigger(100).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::NO_COMPRESSION); + + // In raw mode the card writes the detector frame, here the one JFJochReceiverTest() expects + std::vector raw(RAW_MODULE_SIZE * x.GetModulesNum()); + for (int i = 0; i < raw.size(); i++) + raw[i] = i % 65536; + + AcquisitionDeviceGroup aq_devices; + for (int i = 0; i < x.GetDataStreamsNum(); i++) { + auto test = std::make_unique(i, 64); + for (int m = 0; m < x.GetModulesNum(i); m++) + test->SetOutput(0, m, *OutputWithPixels(raw.data() + (x.GetFirstModuleOfDataStream(i) + m) * RAW_MODULE_SIZE)); + aq_devices.Add(std::move(test)); + } + + Logger logger("MockAcquisitionDevice_JFJochReceiverTest_Raw"); + PixelMask mask(x); + + JFJochReceiverOutput output; + bool ret; + REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, raw, nthreads)); + REQUIRE(ret); + REQUIRE(output.efficiency == 1.0); + REQUIRE(output.status.images_sent == x.GetImageNum()); + REQUIRE(output.status.compressed_ratio == 1.0); + REQUIRE(output.status.compressed_size == x.GetImageNum() * x.GetByteDepthImage() * x.GetPixelsNum()); + REQUIRE(output.status.max_image_number_sent == x.GetImageNum()); + REQUIRE(!output.status.cancelled); +} + +// Two cards running at the same time - not possible with the HLS simulation +TEST_CASE("MockAcquisitionDevice_JFJochReceiverTest_Raw_TwoDevices", "[MockAcquisitionDevice]") { + DiffractionExperiment x(DetJF(4)); + const uint16_t nthreads = 4; + + x.Raw(); + x.DataStreams(2); + x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true) + .ImagesPerTrigger(100).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::NO_COMPRESSION); + REQUIRE(x.GetDataStreamsNum() == 2); + + std::vector raw(RAW_MODULE_SIZE * x.GetModulesNum()); + for (int i = 0; i < raw.size(); i++) + raw[i] = i % 65536; + + AcquisitionDeviceGroup aq_devices; + for (int i = 0; i < x.GetDataStreamsNum(); i++) { + auto test = std::make_unique(i, 64); + for (int m = 0; m < x.GetModulesNum(i); m++) + test->SetOutput(0, m, *OutputWithPixels(raw.data() + (x.GetFirstModuleOfDataStream(i) + m) * RAW_MODULE_SIZE)); + aq_devices.Add(std::move(test)); + } + + Logger logger("MockAcquisitionDevice_JFJochReceiverTest_Raw_TwoDevices"); + PixelMask mask(x); + + JFJochReceiverOutput output; + bool ret; + REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, raw, nthreads)); + REQUIRE(ret); + REQUIRE(output.efficiency == 1.0); + REQUIRE(output.status.images_sent == x.GetImageNum()); + REQUIRE(!output.status.cancelled); +} + +TEST_CASE("MockAcquisitionDevice_JFJochReceiverTest_EIGER", "[MockAcquisitionDevice]") { + Logger logger("MockAcquisitionDevice_JFJochReceiverTest_EIGER"); + + DiffractionExperiment x(DetEIGER(2)); + const uint16_t nthreads = 4; + + x.Raw(); + x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(true) + .ImagesPerTrigger(32).ImagesPerFile(10).IncidentEnergy_keV(12.4).Compression(CompressionAlgorithm::BSHUF_ZSTD); + + std::vector raw(RAW_MODULE_SIZE * x.GetModulesNum()); + for (int i = 0; i < raw.size(); i++) + raw[i] = i % 65536; + + AcquisitionDeviceGroup aq_devices; + for (int i = 0; i < x.GetDataStreamsNum(); i++) { + auto test = std::make_unique(i, 64); + for (int m = 0; m < x.GetModulesNum(i); m++) + test->SetOutput(0, m, *OutputWithPixels(raw.data() + (x.GetFirstModuleOfDataStream(i) + m) * RAW_MODULE_SIZE)); + aq_devices.Add(std::move(test)); + } + + PixelMask mask(x); + + JFJochReceiverOutput output; + bool ret; + REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, raw, nthreads)); + REQUIRE(ret); + REQUIRE(output.efficiency == 1.0); + REQUIRE(output.status.images_sent == x.GetImageNum()); + REQUIRE(!output.status.cancelled); +} + +TEST_CASE("MockAcquisitionDevice_JFJochReceiverTest_PacketLost_Raw", "[MockAcquisitionDevice]") { + DiffractionExperiment x(DetJF(2)); + const uint16_t nthreads = 4; + + std::vector frame_in(RAW_MODULE_SIZE); + for (auto &i: frame_in) i = 776; + + x.Raw(); + x.PedestalG0Frames(0).NumTriggers(1) + .UseInternalPacketGenerator(false).ImagesPerTrigger(4).IncidentEnergy_keV(12.4) + .Compression(CompressionAlgorithm::NO_COMPRESSION); + + PixelMask pixel_mask(x); + + // The card writes the missing packet as UINT16_MAX + std::vector frame_lost = frame_in; + for (int i = 127 * 4096; i < RAW_MODULE_SIZE; i++) + frame_lost[i] = UINT16_MAX; + + AcquisitionDeviceGroup aq_devices; + for (int i = 0; i < x.GetDataStreamsNum(); i++) { + auto test = std::make_unique(i, 64); + for (int image = 0; image < 4; image++) { + test->SetOutput(image, 0, *OutputWithPixels((image == 3) ? frame_lost.data() : frame_in.data())); + test->SetOutput(image, 1, *OutputWithPixels(frame_in.data())); + } + + test->CreateJFPackets(x, 1, 1, 0, frame_in.data()); + test->CreateJFPackets(x, 1, 1, 1, frame_in.data()); + test->CreateJFPackets(x, 2, 1, 0, frame_in.data()); + test->CreateJFPackets(x, 2, 1, 1, frame_in.data()); + test->CreateJFPackets(x, 3, 1, 0, frame_in.data()); + test->CreateJFPackets(x, 3, 1, 1, frame_in.data()); + + for (int j = 0; j < 127; j++) + test->CreateJFPacket(x, 4, j, 0, nullptr); + test->CreateJFPackets(x, 4, 1, 1, frame_in.data()); + test->CreateFinalPacket(x); + + aq_devices.Add(std::move(test)); + } + Logger logger("MockAcquisitionDevice_JFJochReceiverTest_PacketLost_Raw"); + + JFCalibration calib(x); + + TestImagePusher pusher(x.GetImageNum() - 1); + + JFJochReceiverService service(aq_devices, logger, pusher); + service.NumThreads(nthreads); + + service.Start(x, pixel_mask, &calib); + auto receiver_out = service.Stop(); + + const auto image = pusher.GetImage(); + + REQUIRE(aq_devices[0].GetBytesReceived() == (8 * 128 - 1) * 8192UL); + REQUIRE(image.size() == 2 * RAW_MODULE_SIZE * sizeof(uint16_t)); + REQUIRE(pusher.GetCounter() == x.GetImageNum()); + + auto raw = (const uint16_t *) (image.data()); + CHECK(raw[0] == 776); + CHECK(raw[256 * 1024 + 315] == 776); + CHECK(raw[RAW_MODULE_SIZE - 4095] == UINT16_MAX); + CHECK(raw[RAW_MODULE_SIZE - 1] == UINT16_MAX); + + CHECK(raw[RAW_MODULE_SIZE + 0] == 776); + CHECK(raw[RAW_MODULE_SIZE + 256 * 1024 + 315] == 776); + CHECK(raw[2 * RAW_MODULE_SIZE - 1] == 776); + + REQUIRE(receiver_out.efficiency < 1.0); + REQUIRE(receiver_out.status.images_sent == x.GetImageNum()); +} + +TEST_CASE("MockAcquisitionDevice_JFJochReceiverTest_PedestalG0", "[MockAcquisitionDevice]") { + DiffractionExperiment x(DetJF(1)); + const uint16_t nthreads = 4; + size_t nframes = 500; + // The card output repeats every distinct_frames frames + size_t distinct_frames = 25; + + std::vector pedestal_in(RAW_MODULE_SIZE * distinct_frames); + + // Predictable random number generator + std::mt19937 g1(1900); + std::normal_distribution distribution(3000, 50); + + for (auto &i: pedestal_in) { + uint16_t number = distribution(g1); + if (number < 20) number = 20; + if (number > 16300) number = 16300; + i = number; + } + + x.Mode(DetectorMode::PedestalG0); + x.PedestalG0Frames(nframes) + .NumTriggers(1).UseInternalPacketGenerator(false) + .ImagesPerTrigger(0).IncidentEnergy_keV(12.4); + + AcquisitionDeviceGroup aq_devices; + for (int i = 0; i < x.GetDataStreamsNum(); i++) { + auto test = std::make_unique(i, 64); + for (int f = 0; f < distinct_frames; f++) + test->SetOutput(f, 0, *OutputWithPixels(pedestal_in.data() + f * RAW_MODULE_SIZE)); + for (int f = 0; f < nframes; f++) + test->CreateJFPackets(x, f + 1, 1, 0, pedestal_in.data() + (f % distinct_frames) * RAW_MODULE_SIZE); + test->CreateFinalPacket(x); + aq_devices.Add(std::move(test)); + } + + JFPedestalCalc pc(x); + for (int i = 0; i < nframes; i++) + pc.AnalyzeImage(pedestal_in.data() + (i % distinct_frames) * RAW_MODULE_SIZE); + + PixelMask mask(x); + + Logger logger("MockAcquisitionDevice_JFJochReceiverTest_PedestalG0"); + JFJochReceiverOutput output; + bool ret; + REQUIRE_NOTHROW(ret = JFJochReceiverTest(output, logger, aq_devices, x, mask, nthreads)); + REQUIRE(ret); + REQUIRE(output.status.images_sent == x.GetImageNum()); + REQUIRE(output.efficiency == 1.0); + + JFModulePedestal ref_pedestal; + pc.Export(ref_pedestal, 0); + JFModulePedestal out_pedestal = output.pedestal_result.at(0); + REQUIRE(abs(ref_pedestal.Mean() - out_pedestal.Mean()) < 0.65); + REQUIRE(out_pedestal.CountMaskedPixels() == 0); + REQUIRE(out_pedestal.GetFrameCount() == nframes); +}