2017-08-08 17:54:53 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
|
|
|
|
# Testcase 1. Valid fuzzer build.
|
|
|
|
################################################################################
|
|
|
|
./configure
|
|
|
|
make -j$(nproc) clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
|
|
|
|
$CXX $CXXFLAGS -std=c++11 -I. \
|
|
|
|
$SRC/bad_example_fuzzer.cc -o $OUT/bad_example_valid_build \
|
2019-05-01 15:09:55 +00:00
|
|
|
$LIB_FUZZING_ENGINE ./libz.a
|
2017-08-08 17:54:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Testcase 2. Silent startup crash.
|
|
|
|
################################################################################
|
|
|
|
./configure
|
|
|
|
make -j$(nproc) clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
|
|
|
|
$CXX $CXXFLAGS -std=c++11 -I. -DINTENTIONAL_STARTUP_CRASH \
|
|
|
|
$SRC/bad_example_fuzzer.cc -o $OUT/bad_example_startup_crash \
|
2019-05-01 15:09:55 +00:00
|
|
|
$LIB_FUZZING_ENGINE ./libz.a
|
2017-08-08 17:54:53 +00:00
|
|
|
|
|
|
|
|
2021-02-11 23:26:07 +00:00
|
|
|
# The latest two examples won't work for coverage build, bail out.
|
2018-10-01 13:43:21 +00:00
|
|
|
if [[ $SANITIZER = *coverage* ]]; then
|
2017-08-09 16:55:48 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2018-04-17 16:31:53 +00:00
|
|
|
# Testcase 3. Partially ignore the flags provided by OSS-Fuzz.
|
2017-08-08 17:54:53 +00:00
|
|
|
################################################################################
|
2018-04-17 16:31:53 +00:00
|
|
|
export CFLAGS_ORIG="$CFLAGS"
|
2017-08-08 17:54:53 +00:00
|
|
|
export CFLAGS="-O1"
|
2018-04-17 16:31:53 +00:00
|
|
|
export CXXFLAGS_ORIG="$CXXFLAGS"
|
2017-08-08 17:54:53 +00:00
|
|
|
export CXXFLAGS="-O1 -stdlib=libc++"
|
|
|
|
|
|
|
|
./configure
|
|
|
|
make -j$(nproc) clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
|
2018-04-17 16:31:53 +00:00
|
|
|
$CXX -fsanitize=$SANITIZER $CXXFLAGS_ORIG -std=c++11 -I. \
|
|
|
|
$SRC/bad_example_fuzzer.cc -o $OUT/bad_example_partial_instrumentation \
|
2019-05-01 15:09:55 +00:00
|
|
|
$LIB_FUZZING_ENGINE ./libz.a
|
2018-04-17 16:31:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Testcase 4. Completely ignore the flags provided by OSS-Fuzz.
|
|
|
|
################################################################################
|
|
|
|
./configure
|
|
|
|
make -j$(nproc) clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
|
2017-08-08 17:54:53 +00:00
|
|
|
$CXX -fsanitize=$SANITIZER $CXXFLAGS -std=c++11 -I. \
|
|
|
|
$SRC/bad_example_fuzzer.cc -o $OUT/bad_example_no_instrumentation \
|
2019-05-01 15:09:55 +00:00
|
|
|
$LIB_FUZZING_ENGINE ./libz.a
|
2017-08-08 17:54:53 +00:00
|
|
|
|
|
|
|
|
2018-04-17 16:31:53 +00:00
|
|
|
# Testcase 5. Enable multiple sanitizers.
|
2017-08-08 17:54:53 +00:00
|
|
|
################################################################################
|
|
|
|
# Add UBSan to ASan or MSan build. Add ASan to UBSan build.
|
|
|
|
EXTRA_SANITIZER="undefined"
|
2017-08-09 16:55:48 +00:00
|
|
|
if [[ $SANITIZER = *undefined* ]]; then
|
2017-08-08 17:54:53 +00:00
|
|
|
EXTRA_SANITIZER="address"
|
|
|
|
fi
|
|
|
|
|
2018-04-17 16:31:53 +00:00
|
|
|
export CFLAGS="$CFLAGS_ORIG -fsanitize=$EXTRA_SANITIZER"
|
|
|
|
export CXXFLAGS="$CXXFLAGS_ORIG -fsanitize=$EXTRA_SANITIZER"
|
2017-08-08 17:54:53 +00:00
|
|
|
|
|
|
|
./configure
|
|
|
|
make -j$(nproc) clean
|
|
|
|
make -j$(nproc) all
|
|
|
|
|
|
|
|
$CXX $CXXFLAGS -std=c++11 -I. \
|
|
|
|
$SRC/bad_example_fuzzer.cc -o $OUT/bad_example_mixed_sanitizers \
|
2019-05-01 15:09:55 +00:00
|
|
|
$LIB_FUZZING_ENGINE ./libz.a
|