Chromium Code Reviews| Index: webrtc/test/fuzzers/congestion_controller_fuzzer.cc |
| diff --git a/webrtc/test/fuzzers/congestion_controller_fuzzer.cc b/webrtc/test/fuzzers/congestion_controller_fuzzer.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..32b5baa9a4845a6968ce31bea50a3abccba0116f |
| --- /dev/null |
| +++ b/webrtc/test/fuzzers/congestion_controller_fuzzer.cc |
| @@ -0,0 +1,50 @@ |
| +/* |
| + * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "webrtc/call/mock/mock_rtc_event_log.h" |
| +#include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| +#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_controller.h" |
| +#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_estimator.h" |
| +#include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| + |
| +namespace webrtc { |
| + |
| +void FuzzOneInput(const uint8_t* data, size_t size) { |
| + size_t i = 0; |
| + const size_t kMinSize = sizeof(size_t) + sizeof(uint16_t) + sizeof(uint8_t); |
|
pbos-webrtc
2016/07/18 08:02:52
Something like kMinPacketSize?
stefan-webrtc
2016/07/18 15:46:56
Roughly, it also includes the size of the packet.
|
| + if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t) + kMinSize) |
|
pbos-webrtc
2016/07/18 08:02:52
You can permit this to run with 0 packets as well,
stefan-webrtc
2016/07/18 15:46:56
Good suggestion, fixing.
|
| + return; |
| + SimulatedClock clock(data[i++]); |
| + testing::NiceMock<test::MockCongestionObserver> observer; |
| + testing::NiceMock<MockRemoteBitrateObserver> rbe_observer; |
| + testing::NiceMock<MockRtcEventLog> event_log; |
| + CongestionController cc(&clock, &observer, &rbe_observer, &event_log); |
| + RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true); |
| + RTPHeader header; |
| + header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]); |
| + i += sizeof(uint32_t); |
| + header.extension.hasTransportSequenceNumber = true; |
| + int64_t arrival_time_ms = |
| + std::max<int64_t>(ByteReader<int64_t>::ReadBigEndian(&data[i]), 0); |
| + i += sizeof(int64_t); |
| + while (i + kMinSize < size) { |
| + size_t payload_size = ByteReader<size_t>::ReadBigEndian(&data[i]) % 1500; |
| + i += sizeof(size_t); |
| + header.extension.transportSequenceNumber = |
| + ByteReader<uint16_t>::ReadBigEndian(&data[i]); |
| + i += sizeof(uint16_t); |
| + rbe->IncomingPacket(arrival_time_ms, payload_size, header); |
| + clock.AdvanceTimeMilliseconds(5); |
| + arrival_time_ms += ByteReader<uint8_t>::ReadBigEndian(&data[i]); |
| + arrival_time_ms += sizeof(uint8_t); |
| + } |
| + rbe->Process(); |
| +} |
| +} // namespace webrtc |