blob: 10a768d610b4957b563e53e23727682da26b7e8e [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
11// This file is intended to provide a common interface for fuzzing functions, so
12// whether we're running fuzzing under libFuzzer or DrFuzz the webrtc functions
13// can remain the same.
14// TODO(pbos): Implement FuzzOneInput() for more than one platform (currently
15// libFuzzer).
16
Peter Boström89d658f2015-11-25 21:58:36 +010017#include "webrtc/base/logging.h"
18
19namespace {
20bool g_initialized = false;
21void InitializeWebRtcFuzzDefaults() {
22 if (g_initialized)
23 return;
24
25 // Remove default logging to prevent huge slowdowns.
26 // TODO(pbos): Disable in Chromium: http://crbug.com/561667
27#if !defined(WEBRTC_CHROMIUM_BUILD)
28 rtc::LogMessage::LogToDebug(rtc::LS_NONE);
29#endif // !defined(WEBRTC_CHROMIUM_BUILD)
30
31 g_initialized = true;
32}
33}
34
Peter Boström62e9bda2015-11-23 15:12:06 +010035namespace webrtc {
36extern void FuzzOneInput(const uint8_t* data, size_t size);
37} // namespace webrtc
38
39extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) {
Peter Boström89d658f2015-11-25 21:58:36 +010040 InitializeWebRtcFuzzDefaults();
Peter Boström62e9bda2015-11-23 15:12:06 +010041 webrtc::FuzzOneInput(data, size);
42 return 0;
43}