xref: /aosp_15_r20/external/libmpeg2/fuzzer/ossfuzz.sh (revision a97c2a1f0a796dc32bed80d3353c69c5fc07c750)
1#!/bin/bash -eu
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15################################################################################
16# Ensure SRC and WORK are set
17test "${SRC}" != "" || exit 1
18test "${WORK}" != "" || exit 1
19test "${OUT}" != "" || exit 1
20
21#Opt out of shift sanitizers in undefined sanitizer
22if [[ $SANITIZER = *undefined* ]]; then
23  CFLAGS="$CFLAGS -fno-sanitize=shift"
24  CXXFLAGS="$CXXFLAGS -fno-sanitize=shift"
25fi
26
27# Build libmpeg2
28build_dir=$WORK/build
29rm -rf ${build_dir}
30mkdir -p ${build_dir}
31pushd ${build_dir}
32
33cmake $SRC/libmpeg2
34make -j$(nproc) mpeg2_dec_fuzzer
35cp ${build_dir}/mpeg2_dec_fuzzer $OUT/
36popd
37
38cp $SRC/mpeg2_dec_fuzzer_seed_corpus.zip $OUT/mpeg2_dec_fuzzer_seed_corpus.zip
39cp $SRC/libmpeg2/fuzzer/mpeg2_dec_fuzzer.dict $OUT/mpeg2_dec_fuzzer.dict
40