mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
Fix fuzz tests to work on oss-fuzz
- the tests now build/run/check_build with libfuzzer on oss-fuzz - centipede is removed as it builds/runs but do not check_build (timeout due to arguments not parsed correctly) Bug: oss-fuzz:69508 Change-Id: Id063565fc4cce02fc5e36c7d8499d6de9ff54345
This commit is contained in:
parent
3ba8af1a33
commit
9ce982fdf2
@ -35,7 +35,7 @@ set(fuzztest_SOURCE_DIR ${CMAKE_BINARY_DIR}/_deps/fuzztest-src)
|
||||
FetchContent_Declare(
|
||||
fuzztest
|
||||
GIT_REPOSITORY https://github.com/google/fuzztest.git
|
||||
GIT_TAG a40caf40aaf621dd0e04f9d8b47d1153fd2682d2
|
||||
GIT_TAG ce454aced15f7dc2cc96aeae969a6204b563b4c9
|
||||
GIT_PROGRESS TRUE
|
||||
PATCH_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/patch.sh)
|
||||
|
||||
|
@ -39,21 +39,27 @@
|
||||
set -eu
|
||||
|
||||
# Avoid fuzz engines that do not compile.
|
||||
if [[ "$FUZZING_ENGINE" != "libfuzzer" && "$FUZZING_ENGINE" != "centipede" ]]; then
|
||||
if [[ "$FUZZING_ENGINE" != "libfuzzer" ]]; then
|
||||
exit
|
||||
fi
|
||||
|
||||
EXTRA_CMAKE_FLAGS=""
|
||||
if [ "$FUZZING_ENGINE" == "libfuzzer" ]
|
||||
then
|
||||
export CXXFLAGS="${CXXFLAGS} -DFUZZTEST_COMPATIBILITY_MODE"
|
||||
EXTRA_CMAKE_FLAGS="-DFUZZTEST_COMPATIBILITY_MODE=libfuzzer"
|
||||
fi
|
||||
|
||||
# limit allocation size to reduce spurious OOMs
|
||||
WEBP_CFLAGS="$CFLAGS -DWEBP_MAX_IMAGE_SIZE=838860800" # 800MiB
|
||||
|
||||
export CFLAGS="$WEBP_CFLAGS"
|
||||
cmake -S . -B build -DWEBP_BUILD_FUZZTEST=ON
|
||||
cmake -S . -B build -DWEBP_BUILD_FUZZTEST=ON ${EXTRA_CMAKE_FLAGS}
|
||||
cd build && make -j$(nproc) && cd ..
|
||||
|
||||
find $SRC/libwebp-test-data -type f -size -32k -iname "*.webp" \
|
||||
-exec zip -qju fuzz_seed_corpus.zip "{}" \;
|
||||
|
||||
# build fuzztests
|
||||
# The following is taken from https://github.com/google/oss-fuzz/blob/31ac7244748ea7390015455fb034b1f4eda039d9/infra/base-images/base-builder/compile_fuzztests.sh#L59
|
||||
# Iterate the fuzz binaries and list each fuzz entrypoint in the binary. For
|
||||
# each entrypoint create a wrapper script that calls into the binaries the
|
||||
|
@ -8,3 +8,5 @@ after="if (data.size() == 0) return;"
|
||||
sed -i "s/${before}/${after}/" ./fuzztest/internal/compatibility_mode.cc
|
||||
sed -i "s/set(GTEST_HAS_ABSL ON)/set(GTEST_HAS_ABSL OFF)/" \
|
||||
./cmake/BuildDependencies.cmake
|
||||
# Fixes https://github.com/google/fuzztest/issues/1192
|
||||
git revert --no-commit ed6f817771702bf7823b73498d0e1914475f2313
|
||||
|
Loading…
Reference in New Issue
Block a user