mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-30 23:52:22 +02:00
Fix unit tests
This commit is contained in:
@@ -14,6 +14,7 @@ TEST(BufferUdpReceiver, simple_recv)
|
||||
{
|
||||
auto n_packets = JUNGFRAU_N_PACKETS_PER_FRAME;
|
||||
int source_id = 1234;
|
||||
int n_frames = 5;
|
||||
|
||||
uint16_t udp_port = MOCK_UDP_PORT;
|
||||
auto server_address = get_server_address(udp_port);
|
||||
@@ -23,9 +24,8 @@ TEST(BufferUdpReceiver, simple_recv)
|
||||
BufferUdpReceiver udp_receiver(udp_port, source_id);
|
||||
|
||||
auto handle = async(launch::async, [&](){
|
||||
for (int i_frame=0; i_frame < BUFFER_UDP_RCVBUF_N_SLOTS; i_frame++){
|
||||
for (int i_frame=0; i_frame < n_frames; i_frame++){
|
||||
for (size_t i_packet=0; i_packet<n_packets; i_packet++) {
|
||||
|
||||
jungfrau_packet send_udp_buffer;
|
||||
send_udp_buffer.packetnum = i_packet;
|
||||
send_udp_buffer.bunchid = i_frame + 1;
|
||||
@@ -48,12 +48,14 @@ TEST(BufferUdpReceiver, simple_recv)
|
||||
ModuleFrame metadata;
|
||||
auto frame_buffer = make_unique<char[]>(JUNGFRAU_DATA_BYTES_PER_FRAME);
|
||||
|
||||
for (int i_frame=0; i_frame < BUFFER_UDP_RCVBUF_N_SLOTS; i_frame++) {
|
||||
for (int i_frame=0; i_frame < n_frames; i_frame++) {
|
||||
auto pulse_id = udp_receiver.get_frame_from_udp(
|
||||
metadata, frame_buffer.get());
|
||||
|
||||
ASSERT_EQ(i_frame + 1, pulse_id);
|
||||
ASSERT_EQ(metadata.frame_index, i_frame + 1000);
|
||||
ASSERT_EQ(metadata.daq_rec, i_frame + 10000);
|
||||
// -1 because we skipped a packet.
|
||||
ASSERT_EQ(metadata.n_received_packets, n_packets);
|
||||
ASSERT_EQ(metadata.module_id, source_id);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user