xref: /aosp_15_r20/external/libxaac/fuzzer/ossfuzz.sh (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
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
19
20#Opt out of shift sanitizer in undefined sanitizer
21if [[ $SANITIZER = *undefined* ]]; then
22  CFLAGS="$CFLAGS -fno-sanitize=shift"
23  CXXFLAGS="$CXXFLAGS -fno-sanitize=shift"
24fi
25
26# Build libxaac
27build_dir=$WORK/build
28rm -rf ${build_dir}
29mkdir -p ${build_dir}
30pushd ${build_dir}
31
32cmake $SRC/libxaac
33make -j$(nproc) xaac_dec_fuzzer xaac_enc_fuzzer
34cp ${build_dir}/xaac_dec_fuzzer $OUT/
35cp ${build_dir}/xaac_enc_fuzzer $OUT/
36popd
37
38cp $SRC/libxaac/fuzzer/xaac_dec_fuzzer.dict $OUT/
39cp $SRC/libxaac/fuzzer/xaac_enc_fuzzer.dict $OUT/
40