Tests: FPGAIntegrationTest removed, its host-side checks on the mock
FPGAIntegrationTest.cpp ran the HLS simulation of the card for 59 cases, most of them checking the card's arithmetic (conversion, gain modes, storage cells, summation, thresholds, square root, spot finder, integration, ROI, pixel counts, EIGER unpacking, generator memory). The firmware does not change, so these go; whether the mock gives the host what the card gives is checked in MockAcquisitionDeviceTest.cpp. What those cases checked of the host side - FPGAAcquisitionDevice and AcquisitionCounters - stays, on the mock, in FPGAAcquisitionDeviceTest.cpp (8 cases): bytes received and module headers from the internal packet generator, also for one data stream of four; missing modules and the slowest frame; delays; a lost frame and which outputs exist; buffer alignment and counters for one frame; the end of the collection on a frame far past the last; the XFEL pulse ID. In DetectLastFrame the packet now comes after the start, so the not-yet-finished check does not race the mock. Cancel, wrong-length and Ethernet-error packets are covered by the equivalence cases. The card-to-preprocessor pixel sum parity is covered by ImagePreprocessorPixelSumTest.cpp, written against the card's definition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HVeDQsU5a8AJUdJPgWevAK
This commit is contained in:
1 parent
ce89180627
commit
710edd61e7
4 files changed
+177
-2831
No files matched your search
@@ -14,7 +14,7 @@ class HLSSimulatedDevice : public FPGAAcquisitionDevice {
|
||||
// Owns the simulated frame buffers. Plain heap (this path is not performance-critical, so no
|
||||
// NUMA placement and no mmap), but page-aligned (4 KiB) to match the real device's kernel DMA
|
||||
// buffers - more than enough for the data path's alignment needs (AXI datamover 64 B,
|
||||
// FPGAIntegrationTest 128 B). Declared before `device` so the buffers outlive the HLSDevice
|
||||
// FPGAAcquisitionDeviceTest 128 B). Declared before `device` so the buffers outlive the HLSDevice
|
||||
// action thread that writes into them; buffer_device points into these.
|
||||
struct alignas(4096) FrameBuffer { uint8_t data[FPGA_BUFFER_LOCATION_SIZE]; };
|
||||
std::vector<std::unique_ptr<FrameBuffer>> buffers;
|
||||
|
||||
@@ -63,8 +63,9 @@ ADD_EXECUTABLE(jfjoch_test
|
||||
../common/RawToConvertedGeometry.h
|
||||
../common/DiffractionExperiment.h
|
||||
CheckImageOutput.h
|
||||
FPGAIntegrationTest.cpp
|
||||
MockCardOutput.h
|
||||
MockAcquisitionDeviceTest.cpp
|
||||
FPGAAcquisitionDeviceTest.cpp
|
||||
StrongPixelSetTest.cpp
|
||||
AdaptiveThresholdTest.cpp
|
||||
AdaptiveSpotFinderCPUTest.cpp
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// The host side of the card - FPGAAcquisitionDevice and its AcquisitionCounters - on the mock of the card: what
|
||||
// arrived, where it went, delays, the end of the data collection. The card itself is compared with the mock in
|
||||
// MockAcquisitionDeviceTest.cpp.
|
||||
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
||||
#include "../acquisition_device/MockAcquisitionDevice.h"
|
||||
|
||||
TEST_CASE("FPGAAcquisitionDevice_InternalPacketGenerator", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.Raw();
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0);
|
||||
|
||||
MockAcquisitionDevice test(0, 64);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 128 * nmodules * 4 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
for (int image = 0; image < 4; image++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
const auto &stats = test.GetDeviceOutput(image, m)->module_statistics;
|
||||
CHECK(stats.frame_number == image);
|
||||
CHECK(stats.module_number == m);
|
||||
CHECK(stats.timestamp == INT_PKT_GEN_EXPTTIME * image);
|
||||
CHECK(stats.pulse_id == INT_PKT_GEN_BUNCHID + image);
|
||||
CHECK(stats.exptime == INT_PKT_GEN_EXPTTIME);
|
||||
CHECK(stats.detector_type == SLS_DETECTOR_TYPE_JUNGFRAU);
|
||||
}
|
||||
}
|
||||
REQUIRE(test.GetExpectedDescriptorsPerModule() == DMA_DESCRIPTORS_PER_MODULE);
|
||||
}
|
||||
|
||||
// Of four data streams, the card of the last one generates only its own module
|
||||
TEST_CASE("FPGAAcquisitionDevice_InternalPacketGenerator_DataStream", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.DataStreams(4);
|
||||
x.Raw();
|
||||
x.UseInternalPacketGenerator(true).ImagesPerTrigger(4).PedestalG0Frames(0);
|
||||
|
||||
MockAcquisitionDevice test(3, 64);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 128 * 4 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
for (int image = 0; image < 4; image++)
|
||||
REQUIRE(test.Counters().IsFullModuleCollected(image, 0));
|
||||
}
|
||||
|
||||
// Module 0 runs on, module 1 stops after 3 frames, modules 2 and 3 never come: the slowest frame moves on once the
|
||||
// fastest module is far enough ahead
|
||||
TEST_CASE("FPGAAcquisitionDevice_MissingModules", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
const uint64_t nframes = AcquisitionCounters::ThresholdFramesLost + 5;
|
||||
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.Raw();
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(nframes).NumTriggers(1);
|
||||
|
||||
MockAcquisitionDevice test(0, nframes + 2);
|
||||
test.CreateJFPackets(x, 1, nframes, 0, nullptr);
|
||||
test.CreateJFPackets(x, 1, 3, 1, nullptr);
|
||||
test.CreateFinalPacket(x);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.Counters().GetSlowestFrameNumber() == 5 - 1);
|
||||
REQUIRE(test.Counters().GetBufferHandle(0, 0) != AcquisitionCounters::HandleNotFound);
|
||||
REQUIRE(test.Counters().GetBufferHandle(0, 1) == AcquisitionCounters::HandleNotFound);
|
||||
REQUIRE(test.Counters().GetBufferHandle(0, 2) == AcquisitionCounters::HandleNotFound);
|
||||
REQUIRE(test.GetBytesReceived() == nframes * 128 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
}
|
||||
|
||||
TEST_CASE("FPGAAcquisitionDevice_Delay", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.Raw();
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1);
|
||||
|
||||
MockAcquisitionDevice test(0, 64);
|
||||
for (int f = 1; f <= 3; f++)
|
||||
for (int m = 0; m < nmodules; m++)
|
||||
test.CreateJFPacket(x, f, 0, m, nullptr);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.Counters().CalculateDelay(0) == 2);
|
||||
REQUIRE(test.Counters().CalculateDelay(0, 0) == 2);
|
||||
REQUIRE(test.Counters().CalculateDelay(1) == 1);
|
||||
REQUIRE(test.Counters().CalculateDelay(1, 0) == 1);
|
||||
REQUIRE(test.Counters().CalculateDelay(2) == 0);
|
||||
REQUIRE(test.Counters().CalculateDelay(2, 0) == 0);
|
||||
}
|
||||
|
||||
// A single packet of one module: that module of that frame is there, nothing else is
|
||||
TEST_CASE("FPGAAcquisitionDevice_LostFrame", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.Raw();
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1);
|
||||
|
||||
MockAcquisitionDevice test(0, 64);
|
||||
test.CreateJFPacket(x, 1, 0, 0, nullptr);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
REQUIRE_NOTHROW(test.GetDeviceOutput(0, 0));
|
||||
REQUIRE(!test.Counters().IsFullModuleCollected(0, 0));
|
||||
REQUIRE_THROWS(test.GetDeviceOutput(0, 1));
|
||||
REQUIRE_THROWS(test.GetDeviceOutput(1, 0));
|
||||
REQUIRE_THROWS(test.GetDeviceOutput(2, 1));
|
||||
}
|
||||
|
||||
TEST_CASE("FPGAAcquisitionDevice_OneFrame", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.PedestalG0Frames(0).NumTriggers(1).ImagesPerTrigger(1);
|
||||
|
||||
MockAcquisitionDevice test(0, 64);
|
||||
test.CreateJFPackets(x, 1, 1, 0, nullptr);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
test.WaitForActionComplete();
|
||||
REQUIRE(test.Counters().IsAcquisitionFinished());
|
||||
|
||||
// address properly aligned
|
||||
REQUIRE((uint64_t) test.GetDeviceOutput(0, 0)->pixels % 128 == 0);
|
||||
|
||||
REQUIRE(test.Counters().GetSlowestFrameNumber() == 0);
|
||||
REQUIRE(test.Counters().GetCurrFrameNumber(0) == 0);
|
||||
REQUIRE(test.GetBytesReceived() == 128 * JUNGFRAU_PACKET_SIZE_BYTES);
|
||||
}
|
||||
|
||||
// A frame far past the last one ends the data collection
|
||||
TEST_CASE("FPGAAcquisitionDevice_DetectLastFrame", "[FPGAAcquisitionDevice]") {
|
||||
const uint16_t nmodules = 4;
|
||||
DiffractionExperiment x(DetJF(nmodules));
|
||||
x.PedestalG0Frames(0).NumTriggers(2).ImagesPerTrigger(5);
|
||||
|
||||
MockAcquisitionDevice test(0, 64);
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE(!test.Counters().IsAcquisitionFinished());
|
||||
|
||||
test.CreateJFPacket(x, 15, 0, 0, nullptr);
|
||||
test.WaitForActionComplete();
|
||||
REQUIRE(test.Counters().IsAcquisitionFinished());
|
||||
}
|
||||
|
||||
TEST_CASE("FPGAAcquisitionDevice_BunchID", "[FPGAAcquisitionDevice]") {
|
||||
const uint64_t bunchid = 0xAAAAAAAA87345600;
|
||||
DiffractionExperiment x(DetJF(4));
|
||||
x.Raw();
|
||||
x.PedestalG0Frames(0).ImagesPerTrigger(3).NumTriggers(1);
|
||||
|
||||
MockAcquisitionDevice test(0, 64);
|
||||
test.CreateXfelBunchIDPacket(bunchid, 0);
|
||||
test.CreateFinalPacket(x);
|
||||
|
||||
REQUIRE_NOTHROW(test.StartAction(x));
|
||||
REQUIRE_NOTHROW(test.WaitForActionComplete());
|
||||
|
||||
REQUIRE(test.GetBytesReceived() == 0);
|
||||
REQUIRE(test.GetDataCollectionStatus().current_pulseid == bunchid);
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user