xref: /aosp_15_r20/external/libavc/fuzzer/ossfuzz.sh (revision 495ae853bb871d1e5a258cb02c2cc13cde8ddb9a)
1*495ae853SAndroid Build Coastguard Worker#!/bin/bash -eu
2*495ae853SAndroid Build Coastguard Worker#
3*495ae853SAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*495ae853SAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*495ae853SAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*495ae853SAndroid Build Coastguard Worker#
7*495ae853SAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
8*495ae853SAndroid Build Coastguard Worker#
9*495ae853SAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*495ae853SAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*495ae853SAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*495ae853SAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*495ae853SAndroid Build Coastguard Worker# limitations under the License.
14*495ae853SAndroid Build Coastguard Worker#
15*495ae853SAndroid Build Coastguard Worker################################################################################
16*495ae853SAndroid Build Coastguard Worker# Ensure SRC and WORK are set
17*495ae853SAndroid Build Coastguard Workertest "${SRC}" != "" || exit 1
18*495ae853SAndroid Build Coastguard Workertest "${WORK}" != "" || exit 1
19*495ae853SAndroid Build Coastguard Workertest "${OUT}" != "" || exit 1
20*495ae853SAndroid Build Coastguard Worker
21*495ae853SAndroid Build Coastguard Worker#Opt out of shift sanitizer in undefined sanitizer
22*495ae853SAndroid Build Coastguard Workerif [[ $SANITIZER = *undefined* ]]; then
23*495ae853SAndroid Build Coastguard Worker  CFLAGS="$CFLAGS -fno-sanitize=shift"
24*495ae853SAndroid Build Coastguard Worker  CXXFLAGS="$CXXFLAGS -fno-sanitize=shift"
25*495ae853SAndroid Build Coastguard Workerfi
26*495ae853SAndroid Build Coastguard Worker
27*495ae853SAndroid Build Coastguard Worker# Build libavc
28*495ae853SAndroid Build Coastguard Workerbuild_dir=$WORK/build
29*495ae853SAndroid Build Coastguard Workerrm -rf ${build_dir}
30*495ae853SAndroid Build Coastguard Workermkdir -p ${build_dir}
31*495ae853SAndroid Build Coastguard Worker
32*495ae853SAndroid Build Coastguard Workerpushd ${build_dir}
33*495ae853SAndroid Build Coastguard Workercmake ${SRC}/libavc -DENABLE_SVC=1 -DENABLE_MVC=1
34*495ae853SAndroid Build Coastguard Workermake -j$(nproc) avc_dec_fuzzer avc_enc_fuzzer mvc_dec_fuzzer svc_dec_fuzzer svc_enc_fuzzer
35*495ae853SAndroid Build Coastguard Workercp ${build_dir}/avc_dec_fuzzer $OUT/
36*495ae853SAndroid Build Coastguard Workercp ${build_dir}/avc_enc_fuzzer $OUT/
37*495ae853SAndroid Build Coastguard Workercp ${build_dir}/mvc_dec_fuzzer $OUT/
38*495ae853SAndroid Build Coastguard Workercp ${build_dir}/svc_dec_fuzzer $OUT/
39*495ae853SAndroid Build Coastguard Workercp ${build_dir}/svc_enc_fuzzer $OUT/
40*495ae853SAndroid Build Coastguard Workerpopd
41*495ae853SAndroid Build Coastguard Worker
42*495ae853SAndroid Build Coastguard Workercp $SRC/avc_dec_fuzzer_seed_corpus.zip $OUT/avc_dec_fuzzer_seed_corpus.zip
43*495ae853SAndroid Build Coastguard Workercp $SRC/libavc/fuzzer/avc_dec_fuzzer.dict $OUT/avcdec_fuzzer.dict
44