brotli/c/fuzz/test_fuzzer.sh
Adrian Perez 641bec0e30
CMake: Allow using BUILD_SHARED_LIBS to choose static/shared libs (#655)
By convention projects using CMake which can build either static or
shared libraries use a BUILD_SHARED_LIBS flag to allow selecting between
both: the add_library() command automatically switches between both using
this variable when the library kind is not passed to add_library(). It
is also usual to expose the BUILD_SHARED_LIBS as an user-facing setting
with the option() command.

This way, the following will both work as expected:

   % cmake -DBUILD_SHARED_LIBS=OFF ...
   % cmake -DBUILS_SHARED_LIBS=ON ...

This is helpful for distributions which need (or want) to build only
static libraries.
2022-12-16 11:42:42 +01:00

34 lines
703 B
Bash
Executable File

#!/usr/bin/env bash
set -e
export CC=${CC:-cc}
BROTLI="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
SRC=$BROTLI/c
cd $BROTLI
rm -rf bin
mkdir bin
cd bin
cmake $BROTLI -DCMAKE_C_COMPILER="$CC" \
-DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=OFF -DENABLE_SANITIZER=address
make -j$(nproc) brotlidec
${CC} -o run_decode_fuzzer -std=c99 -fsanitize=address -I$SRC/include \
$SRC/fuzz/decode_fuzzer.c $SRC/fuzz/run_decode_fuzzer.c \
./libbrotlidec.a ./libbrotlicommon.a
mkdir decode_corpora
unzip $BROTLI/java/org/brotli/integration/fuzz_data.zip -d decode_corpora
for f in `ls decode_corpora`
do
echo "Testing $f"
./run_decode_fuzzer decode_corpora/$f
done
cd $BROTLI
rm -rf bin