1#!/bin/bash 2# Copyright 2017 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16############################################################################## 17set -eu 18 19FUZZERS="opus_decode_fuzzer opus_multi_fuzzer" 20BUILDS=(floating fixed) 21 22tar xvf $SRC/opus_testvectors.tar.gz 23 24if [[ $CFLAGS = *sanitize=memory* ]]; then 25 CFLAGS+=" -D_FORTIFY_SOURCE=0" 26fi 27 28./autogen.sh 29 30for build in "${BUILDS[@]}"; do 31 case "$build" in 32 floating) 33 extra_args="" 34 ;; 35 fixed) 36 extra_args=" --enable-fixed-point --enable-check-asm" 37 ;; 38 esac 39 40 ./configure $extra_args --enable-static --disable-shared --disable-doc \ 41 --enable-assertions 42 make -j$(nproc) 43 44 # Build all fuzzers 45 for fuzzer in $FUZZERS; do 46 $CC $CFLAGS -c -Iinclude \ 47 tests/$fuzzer.c \ 48 -o $fuzzer.o 49 50 $CXX $CXXFLAGS \ 51 $fuzzer.o \ 52 -o $OUT/${fuzzer}_${build} \ 53 $LIB_FUZZING_ENGINE .libs/libopus.a 54 55 # Setup the .options and test corpus zip files using the corresponding 56 # fuzzer's name 57 [ -f tests/$fuzzer.options ] \ 58 && cp tests/$fuzzer.options $OUT/${fuzzer}_${build}.options 59 zip -r $OUT/${fuzzer}_${build}_seed_corpus.zip opus_testvectors/ 60 done 61done 62