Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Unified Diff: net/quic/congestion_control/rtt_stats_test.cc

Issue 687883002: Protect UpdateRTT from negative send deltas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Protect_against_divide_by_zero_78578198
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/congestion_control/rtt_stats.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/congestion_control/rtt_stats_test.cc
diff --git a/net/quic/congestion_control/rtt_stats_test.cc b/net/quic/congestion_control/rtt_stats_test.cc
index c377ebd4b5e77b8949d7b78032ccad0de88fee98..d993c9e3764db28722d3ec3bc7f19fce26eba750 100644
--- a/net/quic/congestion_control/rtt_stats_test.cc
+++ b/net/quic/congestion_control/rtt_stats_test.cc
@@ -4,9 +4,18 @@
#include "net/quic/congestion_control/rtt_stats.h"
+#include <vector>
+
#include "base/logging.h"
+#include "net/test/scoped_mock_log.h"
#include "testing/gtest/include/gtest/gtest.h"
+using logging::LOG_WARNING;
+using std::vector;
+using testing::HasSubstr;
+using testing::Message;
+using testing::_;
+
namespace net {
namespace test {
@@ -217,5 +226,34 @@ TEST_F(RttStatsTest, ExpireSmoothedMetrics) {
EXPECT_LT(initial_rtt, rtt_stats_.mean_deviation());
}
+TEST_F(RttStatsTest, UpdateRttWithBadSendDeltas) {
+ // Make sure we ignore bad RTTs.
+ ScopedMockLog log;
+
+ QuicTime::Delta initial_rtt = QuicTime::Delta::FromMilliseconds(10);
+ rtt_stats_.UpdateRtt(initial_rtt, QuicTime::Delta::Zero(), QuicTime::Zero());
+ EXPECT_EQ(initial_rtt, rtt_stats_.MinRtt());
+ EXPECT_EQ(initial_rtt, rtt_stats_.recent_min_rtt());
+ EXPECT_EQ(initial_rtt, rtt_stats_.SmoothedRtt());
+
+ vector<QuicTime::Delta> bad_send_deltas{
+ QuicTime::Delta::Zero(),
+ QuicTime::Delta::Infinite(),
+ QuicTime::Delta::FromMicroseconds(-1000)};
+ log.StartCapturingLogs();
+
+ for (QuicTime::Delta bad_send_delta : bad_send_deltas) {
+ SCOPED_TRACE(Message() << "bad_send_delta = "
+ << bad_send_delta.ToMicroseconds());
+ EXPECT_CALL(log, Log(LOG_WARNING, _, _, _, HasSubstr("Ignoring")));
+ rtt_stats_.UpdateRtt(bad_send_delta,
+ QuicTime::Delta::Zero(),
+ QuicTime::Zero());
+ EXPECT_EQ(initial_rtt, rtt_stats_.MinRtt());
+ EXPECT_EQ(initial_rtt, rtt_stats_.recent_min_rtt());
+ EXPECT_EQ(initial_rtt, rtt_stats_.SmoothedRtt());
+ }
+}
+
} // namespace test
} // namespace net
« no previous file with comments | « net/quic/congestion_control/rtt_stats.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698