dcsctp: Add packet capture support in unit tests
This is needed to be able to debug test cases when they fail. Bug: webrtc:12961 Change-Id: I39bfe532709d02acb328ff5fdd005d33be4dc31c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225544 Commit-Queue: Victor Boivie <boivie@webrtc.org> Reviewed-by: Florent Castelli <orphis@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34452}
This commit is contained in:
parent
5e726da14b
commit
813a087e84
@ -211,6 +211,7 @@ if (rtc_include_tests) {
|
||||
"../packet:tlv_trait",
|
||||
"../public:socket",
|
||||
"../public:types",
|
||||
"../public:utils",
|
||||
"../rx:data_tracker",
|
||||
"../rx:reassembly_queue",
|
||||
"../testing:data_generator",
|
||||
@ -220,6 +221,7 @@ if (rtc_include_tests) {
|
||||
"../tx:retransmission_queue",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/flags:flag",
|
||||
"//third_party/abseil-cpp/absl/memory",
|
||||
"//third_party/abseil-cpp/absl/strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/memory/memory.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/types/optional.h"
|
||||
@ -40,6 +41,7 @@
|
||||
#include "net/dcsctp/public/dcsctp_message.h"
|
||||
#include "net/dcsctp/public/dcsctp_options.h"
|
||||
#include "net/dcsctp/public/dcsctp_socket.h"
|
||||
#include "net/dcsctp/public/text_pcap_packet_observer.h"
|
||||
#include "net/dcsctp/public/types.h"
|
||||
#include "net/dcsctp/rx/reassembly_queue.h"
|
||||
#include "net/dcsctp/socket/mock_dcsctp_socket_callbacks.h"
|
||||
@ -47,6 +49,8 @@
|
||||
#include "rtc_base/gunit.h"
|
||||
#include "test/gmock.h"
|
||||
|
||||
ABSL_FLAG(bool, dcsctp_capture_packets, false, "Print packet capture.");
|
||||
|
||||
namespace dcsctp {
|
||||
namespace {
|
||||
using ::testing::_;
|
||||
@ -207,14 +211,21 @@ DcSctpOptions MakeOptionsForTest(bool enable_message_interleaving) {
|
||||
return options;
|
||||
}
|
||||
|
||||
std::unique_ptr<PacketObserver> GetPacketObserver(absl::string_view name) {
|
||||
if (absl::GetFlag(FLAGS_dcsctp_capture_packets)) {
|
||||
return std::make_unique<TextPcapPacketObserver>(name);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
class DcSctpSocketTest : public testing::Test {
|
||||
protected:
|
||||
explicit DcSctpSocketTest(bool enable_message_interleaving = false)
|
||||
: options_(MakeOptionsForTest(enable_message_interleaving)),
|
||||
cb_a_("A"),
|
||||
cb_z_("Z"),
|
||||
sock_a_("A", cb_a_, nullptr, options_),
|
||||
sock_z_("Z", cb_z_, nullptr, options_) {}
|
||||
sock_a_("A", cb_a_, GetPacketObserver("A"), options_),
|
||||
sock_z_("Z", cb_z_, GetPacketObserver("Z"), options_) {}
|
||||
|
||||
void AdvanceTime(DurationMs duration) {
|
||||
cb_a_.AdvanceTime(duration);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user