Bug 1533092 - Add in-tree fuzzing support for dav1d r=decoder
authorTyson Smith <twsmith@mozilla.com>
Mon, 11 Mar 2019 20:00:31 +0000
changeset 524477 8f0821b17fd680a419dd6ce7f8b839c0318f3d69
parent 524476 ede970649f873246c6f23b83924345827fb6d5c3
child 524478 7e5fa7b1f7bc9872a319c2eae52aaa612992560c
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdecoder
bugs1533092
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1533092 - Add in-tree fuzzing support for dav1d r=decoder Differential Revision: https://phabricator.services.mozilla.com/D22383
media/libdav1d/moz.build
media/libdav1d/test/fuzztest/dav1d_fuzz_adapter.cpp
media/libdav1d/test/fuzztest/moz.build
--- a/media/libdav1d/moz.build
+++ b/media/libdav1d/moz.build
@@ -38,16 +38,24 @@ if CONFIG['MOZ_DAV1D_ASM']:
              CFLAGS += ['-mstack-alignment=32']
              for ep in entrypoint_source_files:
                  SOURCES[ep].flags += ['-mstackrealign']
          elif CONFIG['CC_TYPE'] == 'gcc':
              CFLAGS += ['-mpreferred-stack-boundary=5']
              for ep in entrypoint_source_files:
                  SOURCES[ep].flags += ['-mincoming-stack-boundary=4']
 
+if CONFIG['OS_TARGET'] == 'Linux':
+    # For fuzzing, We only support building on Linux currently.
+    include('/tools/fuzzing/libfuzzer-config.mozbuild')
+    if CONFIG['FUZZING_INTERFACES']:
+        TEST_DIRS += [
+            'test/fuzztest'
+        ]
+
 # common sources
 SOURCES += [
     '../../third_party/dav1d/src/cdf.c',
     '../../third_party/dav1d/src/cpu.c',
     '../../third_party/dav1d/src/data.c',
     '../../third_party/dav1d/src/decode.c',
     '../../third_party/dav1d/src/dequant_tables.c',
     '../../third_party/dav1d/src/getbits.c',
new file mode 100644
--- /dev/null
+++ b/media/libdav1d/test/fuzztest/dav1d_fuzz_adapter.cpp
@@ -0,0 +1,9 @@
+
+#include "FuzzingInterface.h"
+
+namespace dav1dfuzz {
+#include "tests/libfuzzer/dav1d_fuzzer.c"
+}
+
+MOZ_FUZZING_INTERFACE_RAW(nullptr, dav1dfuzz::LLVMFuzzerTestOneInput,
+                          Dav1dDecode);
new file mode 100644
--- /dev/null
+++ b/media/libdav1d/test/fuzztest/moz.build
@@ -0,0 +1,33 @@
+# -*- 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('FuzzingDav1d')
+
+LOCAL_INCLUDES += [
+    '/media/libdav1d',
+    '/third_party/dav1d',
+    '/third_party/dav1d/tests/libfuzzer/',
+]
+
+# We currently only support building on Linux for fuzzing here, as guarded
+# in media/libaom/moz.build. More support can be added later if necessary.
+if CONFIG['CPU_ARCH'] == 'x86_64':
+    LOCAL_INCLUDES += [
+        '/media/libdav1d/asm/x86_64/',
+    ]
+elif CONFIG['CPU_ARCH'] == 'x86':
+    LOCAL_INCLUDES += [
+        '/media/libdav1d/asm/x86_32/',
+    ]
+
+SOURCES += [
+    '/third_party/dav1d/tests/libfuzzer/dav1d_fuzzer.c',
+    'dav1d_fuzz_adapter.cpp',
+]
+
+include('/tools/fuzzing/libfuzzer-config.mozbuild')
+
+FINAL_LIBRARY = 'xul-gtest'