blob: a52dd231bebfa218685f1f1d1a4916d606b0bf83 [file] [log] [blame]
Peter Boström62e9bda2015-11-23 15:12:06 +01001/*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
Peter Boström62e9bda2015-11-23 15:12:06 +010010
pbos3514cbe2015-12-16 18:36:14 -080011// This file is intended to provide a common interface for fuzzing functions.
12// It's intended to set sane defaults, such as removing logging for further
13// fuzzing efficiency.
Peter Boström62e9bda2015-11-23 15:12:06 +010014
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "rtc_base/logging.h"
Peter Boström89d658f2015-11-25 21:58:36 +010016
17namespace {
18bool g_initialized = false;
19void InitializeWebRtcFuzzDefaults() {
20 if (g_initialized)
21 return;
22
Yves Gerey665174f2018-06-19 15:03:05 +020023// Remove default logging to prevent huge slowdowns.
24// TODO(pbos): Disable in Chromium: http://crbug.com/561667
Peter Boström89d658f2015-11-25 21:58:36 +010025#if !defined(WEBRTC_CHROMIUM_BUILD)
26 rtc::LogMessage::LogToDebug(rtc::LS_NONE);
27#endif // !defined(WEBRTC_CHROMIUM_BUILD)
28
29 g_initialized = true;
30}
Yves Gerey665174f2018-06-19 15:03:05 +020031} // namespace
Peter Boström89d658f2015-11-25 21:58:36 +010032
Peter Boström62e9bda2015-11-23 15:12:06 +010033namespace webrtc {
34extern void FuzzOneInput(const uint8_t* data, size_t size);
35} // namespace webrtc
36
Yves Gerey665174f2018-06-19 15:03:05 +020037extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
Peter Boström89d658f2015-11-25 21:58:36 +010038 InitializeWebRtcFuzzDefaults();
Peter Boström62e9bda2015-11-23 15:12:06 +010039 webrtc::FuzzOneInput(data, size);
40 return 0;
41}