From 4585dba6ff75377ef52bdf8c1609568e4d4ccfe0 Mon Sep 17 00:00:00 2001 From: Mikhail Baranov Date: Tue, 7 Nov 2023 23:21:48 +0100 Subject: [PATCH] Refactor: * rename sender_sink_reciever_source tests so as to be able to run it separately * additional check in sender_sink for abs(cts-unix_base) < 1 ms * revert signature of PacketReader::read_nonzero_packet --- .../roc_pipeline/test_helpers/packet_reader.h | 14 +++++----- ...ce.cpp => test_loopback_sink_2_source.cpp} | 26 +++++++++---------- src/tests/roc_pipeline/test_sender_sink.cpp | 3 ++- 3 files changed, 21 insertions(+), 22 deletions(-) rename src/tests/roc_pipeline/{test_sender_sink_receiver_source.cpp => test_loopback_sink_2_source.cpp} (95%) diff --git a/src/tests/roc_pipeline/test_helpers/packet_reader.h b/src/tests/roc_pipeline/test_helpers/packet_reader.h index 10b50a61fa..a28e82851b 100644 --- a/src/tests/roc_pipeline/test_helpers/packet_reader.h +++ b/src/tests/roc_pipeline/test_helpers/packet_reader.h @@ -51,7 +51,7 @@ class PacketReader : public core::NonCopyable<> { void read_packet(size_t samples_per_packet, const audio::SampleSpec& sample_spec, - core::nanoseconds_t base_capture_ts = 0) { + core::nanoseconds_t base_capture_ts = -1) { packet::PacketPtr pp = read_packet_(); audio::sample_t samples[MaxSamples] = {}; @@ -69,9 +69,9 @@ class PacketReader : public core::NonCopyable<> { abs_offset_ += samples_per_packet; } - packet::PacketPtr read_nonzero_packet(size_t samples_per_packet, - const audio::SampleSpec& sample_spec, - core::nanoseconds_t base_capture_ts = 0) { + void read_nonzero_packet(size_t samples_per_packet, + const audio::SampleSpec& sample_spec, + core::nanoseconds_t base_capture_ts = -1) { packet::PacketPtr pp = read_packet_(); audio::sample_t samples[MaxSamples] = {}; @@ -86,13 +86,11 @@ class PacketReader : public core::NonCopyable<> { } CHECK(non_zero > 0); abs_offset_ += samples_per_packet; - - return pp; } void read_zero_packet(size_t samples_per_packet, const audio::SampleSpec& sample_spec, - core::nanoseconds_t base_capture_ts = 0) { + core::nanoseconds_t base_capture_ts = -1) { packet::PacketPtr pp = read_packet_(); audio::sample_t samples[MaxSamples] = {}; @@ -179,7 +177,7 @@ class PacketReader : public core::NonCopyable<> { core::nanoseconds_t base_ts) { CHECK(pkt.rtp()); - if (base_ts == 0) { + if (base_ts < 0) { LONGS_EQUAL(0, pkt.rtp()->capture_timestamp); } else { const core::nanoseconds_t capture_ts = diff --git a/src/tests/roc_pipeline/test_sender_sink_receiver_source.cpp b/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp similarity index 95% rename from src/tests/roc_pipeline/test_sender_sink_receiver_source.cpp rename to src/tests/roc_pipeline/test_loopback_sink_2_source.cpp index f0cf7991e9..9de6a3d564 100644 --- a/src/tests/roc_pipeline/test_sender_sink_receiver_source.cpp +++ b/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp @@ -374,21 +374,21 @@ void send_receive(int flags, } // namespace -TEST_GROUP(sender_sink_receiver_source) {}; +TEST_GROUP(loopback_sink_2_source) {}; -TEST(sender_sink_receiver_source, bare_rtp) { +TEST(loopback_sink_2_source, bare_rtp) { enum { Chans = Chans_Stereo, NumSess = 1 }; send_receive(FlagNone, NumSess, Chans, Chans); } -TEST(sender_sink_receiver_source, interleaving) { +TEST(loopback_sink_2_source, interleaving) { enum { Chans = Chans_Stereo, NumSess = 1 }; send_receive(FlagInterleaving, NumSess, Chans, Chans); } -TEST(sender_sink_receiver_source, fec_rs) { +TEST(loopback_sink_2_source, fec_rs) { enum { Chans = Chans_Stereo, NumSess = 1 }; if (is_fec_supported(FlagReedSolomon)) { @@ -396,7 +396,7 @@ TEST(sender_sink_receiver_source, fec_rs) { } } -TEST(sender_sink_receiver_source, fec_ldpc) { +TEST(loopback_sink_2_source, fec_ldpc) { enum { Chans = Chans_Stereo, NumSess = 1 }; if (is_fec_supported(FlagLDPC)) { @@ -404,7 +404,7 @@ TEST(sender_sink_receiver_source, fec_ldpc) { } } -TEST(sender_sink_receiver_source, fec_interleaving) { +TEST(loopback_sink_2_source, fec_interleaving) { enum { Chans = Chans_Stereo, NumSess = 1 }; if (is_fec_supported(FlagReedSolomon)) { @@ -412,7 +412,7 @@ TEST(sender_sink_receiver_source, fec_interleaving) { } } -TEST(sender_sink_receiver_source, fec_loss) { +TEST(loopback_sink_2_source, fec_loss) { enum { Chans = Chans_Stereo, NumSess = 1 }; if (is_fec_supported(FlagReedSolomon)) { @@ -420,7 +420,7 @@ TEST(sender_sink_receiver_source, fec_loss) { } } -TEST(sender_sink_receiver_source, fec_drop_source) { +TEST(loopback_sink_2_source, fec_drop_source) { enum { Chans = Chans_Stereo, NumSess = 0 }; if (is_fec_supported(FlagReedSolomon)) { @@ -428,7 +428,7 @@ TEST(sender_sink_receiver_source, fec_drop_source) { } } -TEST(sender_sink_receiver_source, fec_drop_repair) { +TEST(loopback_sink_2_source, fec_drop_repair) { enum { Chans = Chans_Stereo, NumSess = 1 }; if (is_fec_supported(FlagReedSolomon)) { @@ -436,25 +436,25 @@ TEST(sender_sink_receiver_source, fec_drop_repair) { } } -TEST(sender_sink_receiver_source, channel_mapping_stereo_to_mono) { +TEST(loopback_sink_2_source, channel_mapping_stereo_to_mono) { enum { FrameChans = Chans_Stereo, PacketChans = Chans_Mono, NumSess = 1 }; send_receive(FlagNone, NumSess, FrameChans, PacketChans); } -TEST(sender_sink_receiver_source, channel_mapping_mono_to_stereo) { +TEST(loopback_sink_2_source, channel_mapping_mono_to_stereo) { enum { FrameChans = Chans_Mono, PacketChans = Chans_Stereo, NumSess = 1 }; send_receive(FlagNone, NumSess, FrameChans, PacketChans); } -TEST(sender_sink_receiver_source, timestamp_mapping) { +TEST(loopback_sink_2_source, timestamp_mapping) { enum { Chans = Chans_Stereo, NumSess = 1 }; send_receive(FlagRTCP | FlagCTS, NumSess, Chans, Chans); } -TEST(sender_sink_receiver_source, timestamp_mapping_remixing) { +TEST(loopback_sink_2_source, timestamp_mapping_remixing) { enum { FrameChans = Chans_Mono, PacketChans = Chans_Stereo, NumSess = 1 }; send_receive(FlagRTCP | FlagCTS, NumSess, FrameChans, PacketChans); diff --git a/src/tests/roc_pipeline/test_sender_sink.cpp b/src/tests/roc_pipeline/test_sender_sink.cpp index a41fb337f3..7eb415f586 100644 --- a/src/tests/roc_pipeline/test_sender_sink.cpp +++ b/src/tests/roc_pipeline/test_sender_sink.cpp @@ -377,7 +377,7 @@ TEST(sender_sink, timestamp_mapping) { packet_reader.read_eof(); } -TEST(sender_sink, timestamp_mapping_remixing_packet_reader) { +TEST(sender_sink, timestamp_mapping_remixing) { enum { InputRate = 48000, PacketRate = 44100, @@ -424,6 +424,7 @@ TEST(sender_sink, timestamp_mapping_remixing_packet_reader) { if (np == 0) { cts = pp->rtp()->capture_timestamp; CHECK(cts >= unix_base); + CHECK(cts < unix_base + core::Millisecond); } else { test::expect_capture_timestamp(cts, pp->rtp()->capture_timestamp, packet_sample_spec,