Skip to content
Snippets Groups Projects
Commit 8cfda79e authored by Christian Holler's avatar Christian Holler
Browse files

Bug 1465407 - Add media fuzzing targets. r=jya

Depends on D35776

Differential Revision: https://phabricator.services.mozilla.com/D35777

--HG--
extra : moz-landing-system : lando
parent af96b9bf
No related branches found
No related tags found
No related merge requests found
Showing
with 147 additions and 0 deletions
......@@ -22,3 +22,6 @@ FINAL_LIBRARY = 'xul'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ADTSDemuxer.h"
#include "Benchmark.h"
#include "BufferMediaResource.h"
#include "FlacDemuxer.h"
#include "FuzzingInterface.h"
#include "mozilla/AbstractThread.h"
#include "MP3Demuxer.h"
#include "MP4Demuxer.h"
#include "OggDemuxer.h"
#include "systemservices/MediaUtils.h"
#include "WaveDemuxer.h"
#include "WebMDemuxer.h"
using namespace mozilla;
class FuzzRunner {
public:
explicit FuzzRunner(Benchmark* aBenchmark) : mBenchmark(aBenchmark) {}
void Run() {
mBenchmark->Init();
media::Await(
GetMediaThreadPool(MediaThreadType::PLAYBACK), mBenchmark->Run(),
[&](uint32_t aDecodeFps) {}, [&](const MediaResult& aError) {});
return;
}
private:
RefPtr<Benchmark> mBenchmark;
};
static int FuzzingInitMedia(int* argc, char*** argv) {
/* Generic no-op initialization used for all targets */
return 0;
}
#define MOZ_MEDIA_FUZZER(_name) \
static int FuzzingRunMedia##_name(const uint8_t* data, size_t size) { \
if (!size) { \
return 0; \
} \
RefPtr<BufferMediaResource> resource = \
new BufferMediaResource(data, size); \
FuzzRunner runner(new Benchmark(new _name##Demuxer(resource))); \
runner.Run(); \
return 0; \
} \
MOZ_FUZZING_INTERFACE_RAW(FuzzingInitMedia, FuzzingRunMedia##_name, \
Media##_name);
MOZ_MEDIA_FUZZER(ADTS);
MOZ_MEDIA_FUZZER(Flac);
MOZ_MEDIA_FUZZER(MP3);
MOZ_MEDIA_FUZZER(MP4);
MOZ_MEDIA_FUZZER(Ogg);
MOZ_MEDIA_FUZZER(WAV);
MOZ_MEDIA_FUZZER(WebM);
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Library('FuzzingMedia')
SOURCES += [
'FuzzMedia.cpp',
]
include('/ipc/chromium/chromium-config.mozbuild')
LOCAL_INCLUDES += [
'/dom/media',
'/dom/media/encoder',
'/dom/media/gmp',
'/dom/media/hls',
'/dom/media/mp4',
'/dom/media/ogg',
'/dom/media/platforms',
'/dom/media/platforms/agnostic',
]
FINAL_LIBRARY = 'xul-gtest'
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -22,3 +22,6 @@ FINAL_LIBRARY = 'xul'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -69,6 +69,14 @@ TEST_DIRS += [
'gtest',
]
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
if CONFIG['FUZZING_INTERFACES']:
TEST_DIRS += [
'fuzz'
]
MOCHITEST_MANIFESTS += [
'test/mochitest.ini',
'tests/mochitest/identity/mochitest.ini',
......
......@@ -17,3 +17,6 @@ UNIFIED_SOURCES += [
]
FINAL_LIBRARY = 'xul'
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -40,3 +40,6 @@ FINAL_LIBRARY = 'xul'
CXXFLAGS += [
'-Wno-sign-compare',
]
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -23,3 +23,6 @@ UNIFIED_SOURCES += [
]
FINAL_LIBRARY = 'xul'
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -127,3 +127,6 @@ FINAL_LIBRARY = 'xul'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -34,3 +34,6 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
# Avoid warnings from third-party code that we can not modify.
if CONFIG['CC_TYPE'] == 'clang-cl':
CXXFLAGS += ['-Wno-invalid-source-encoding']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -32,3 +32,6 @@ include('/ipc/chromium/chromium-config.mozbuild')
FINAL_LIBRARY = 'xul'
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -18,3 +18,6 @@ FINAL_LIBRARY = 'xul'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -29,3 +29,6 @@ FINAL_LIBRARY = 'xul'
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CXXFLAGS += ['-Wno-error=shadow']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -75,3 +75,6 @@ if CONFIG['MOZ_DEBUG']:
elif not CONFIG['RELEASE_OR_BETA']:
# Enable fast assertions in opt builds of Nightly and Aurora.
DEFINES['ASSERT_LEVEL'] = 1
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -28,3 +28,6 @@ FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -12,3 +12,6 @@ FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -20,3 +20,6 @@ UNIFIED_SOURCES += [
]
FINAL_LIBRARY = 'gkmedias'
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -138,3 +138,6 @@ if CONFIG['CPU_ARCH'] == 'aarch64' and CONFIG['CC_TYPE'] in ('clang', 'gcc'):
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
if CONFIG['CC_TYPE'] == 'clang':
CFLAGS += ['-Wno-#pragma-messages']
# Add libFuzzer configuration directives
include('/tools/fuzzing/libfuzzer-config.mozbuild')
......@@ -56,3 +56,6 @@ FINAL_LIBRARY = 'gkmedias'
# Suppress warnings in third-party code.
if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
CFLAGS += ['-Wno-uninitialized']
# Add libFuzzer configuration directives
#include('/tools/fuzzing/libfuzzer-config.mozbuild')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment