mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-04-22 03:04:35 +02:00
Fix all tests for udp recv
This commit is contained in:
@@ -185,7 +185,7 @@ TEST(BufferUdpReceiver, missing_first_packet)
|
||||
TEST(BufferUdpReceiver, missing_last_packet)
|
||||
{
|
||||
auto n_packets = 128;
|
||||
int source_id = 1234;
|
||||
int module_id = 1234;
|
||||
int n_frames = 3;
|
||||
|
||||
uint16_t udp_port = MOCK_UDP_PORT;
|
||||
@@ -193,7 +193,7 @@ TEST(BufferUdpReceiver, missing_last_packet)
|
||||
auto send_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
ASSERT_TRUE(send_socket_fd >= 0);
|
||||
|
||||
FrameUdpReceiver udp_receiver(udp_port, source_id);
|
||||
FrameUdpReceiver udp_receiver(udp_port, n_packets);
|
||||
|
||||
auto handle = async(launch::async, [&](){
|
||||
for (int i_frame=0; i_frame < n_frames; i_frame++){
|
||||
@@ -222,20 +222,20 @@ TEST(BufferUdpReceiver, missing_last_packet)
|
||||
|
||||
handle.wait();
|
||||
|
||||
ModuleFrame metadata;
|
||||
ModuleFrame meta;
|
||||
meta.module_id = module_id;
|
||||
auto frame_buffer = make_unique<char[]>(DATA_BYTES_PER_FRAME);
|
||||
|
||||
// n_frames -1 because the last frame is not complete.
|
||||
for (int i_frame=0; i_frame < n_frames - 1; i_frame++) {
|
||||
auto pulse_id = udp_receiver.get_frame_from_udp(
|
||||
metadata, frame_buffer.get());
|
||||
udp_receiver.get_frame_from_udp(meta, 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);
|
||||
ASSERT_EQ(i_frame + 1, meta.pulse_id);
|
||||
ASSERT_EQ(meta.frame_index, i_frame + 1000);
|
||||
ASSERT_EQ(meta.daq_rec, i_frame + 10000);
|
||||
// -1 because we skipped a packet.
|
||||
ASSERT_EQ(metadata.n_recv_packets, n_packets - 1);
|
||||
ASSERT_EQ(metadata.module_id, source_id);
|
||||
ASSERT_EQ(meta.n_recv_packets, n_packets - 1);
|
||||
ASSERT_EQ(meta.module_id, module_id);
|
||||
}
|
||||
|
||||
::close(send_socket_fd);
|
||||
|
||||
Reference in New Issue
Block a user