Improve text logs in the network stack.
1) Network info is appended with its network ID assigned by the network
manager so that we can cross-reference networks by IDs in the log.
2) The local network info is added to the candidate pair string
representation so that we do not need the cross reference to the
logs of candidate gathering to find out the network where the local
candidate is from.
3) A flag is added to the candidate pair string representation to
indicate if this pair is the selected one.
4) Sorting of candidate pairs is logged with the reason of sorting
request.
5) Network filtering that takes place in the port allocator is
explicitly logged.
Bug: None
Change-Id: Iaa337394cad803515e26e254814aa04ed2213eab
Reviewed-on: https://webrtc-review.googlesource.com/72522
Commit-Queue: Qingsi Wang <qingsi@google.com>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23266}
diff --git a/rtc_base/network_unittest.cc b/rtc_base/network_unittest.cc
index 8aaa81b..630e733 100644
--- a/rtc_base/network_unittest.cc
+++ b/rtc_base/network_unittest.cc
@@ -61,6 +61,18 @@
}
};
+bool SameNameAndPrefix(const rtc::Network& a, const rtc::Network& b) {
+ if (a.name() != b.name()) {
+ RTC_LOG(INFO) << "Different interface names.";
+ return false;
+ }
+ if (a.prefix_length() != b.prefix_length() || a.prefix() != b.prefix()) {
+ RTC_LOG(INFO) << "Different IP prefixes.";
+ return false;
+ }
+ return true;
+}
+
} // namespace
class NetworkTest : public testing::Test, public sigslot::has_slots<> {
@@ -320,7 +332,7 @@
manager.GetNetworks(&list);
EXPECT_EQ(1U, list.size());
- EXPECT_EQ(ipv4_network1.ToString(), list[0]->ToString());
+ EXPECT_TRUE(SameNameAndPrefix(ipv4_network1, *list[0]));
Network* net1 = list[0];
uint16_t net_id1 = net1->id();
EXPECT_EQ(1, net_id1);
@@ -336,7 +348,7 @@
manager.GetNetworks(&list);
EXPECT_EQ(1U, list.size());
- EXPECT_EQ(ipv4_network2.ToString(), list[0]->ToString());
+ EXPECT_TRUE(SameNameAndPrefix(ipv4_network2, *list[0]));
Network* net2 = list[0];
uint16_t net_id2 = net2->id();
// Network id will increase.
@@ -544,7 +556,7 @@
int matchcount = 0;
for (NetworkManager::NetworkList::iterator it = list.begin();
it != list.end(); ++it) {
- if ((*it)->ToString() == original_list[2]->ToString()) {
+ if (SameNameAndPrefix(**it, *original_list[2])) {
++matchcount;
EXPECT_EQ(1, matchcount);
// This should be the same network object as before.