Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tests/docker: add test-fuzz
Running the fuzzer requires some hoop jumping and some problems only
show up in containers. This basically replicates the build-oss-fuzz
job from our CI so we can run in the same containers we use in CI.

Reviewed-by: Alexander Bulekov <alxndr@bu.edu>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Message-Id: <20230630180423.558337-10-alex.bennee@linaro.org>
  • Loading branch information
stsquad committed Jul 3, 2023
1 parent 3176990 commit 4ab20b5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Expand Up @@ -3106,6 +3106,7 @@ R: Qiuhao Li <Qiuhao.Li@outlook.com>
S: Maintained
F: tests/qtest/fuzz/
F: tests/qtest/fuzz-*test.c
F: tests/docker/test-fuzz
F: scripts/oss-fuzz/
F: hw/mem/sparse-mem.c
F: docs/devel/fuzzing.rst
Expand Down
28 changes: 28 additions & 0 deletions tests/docker/test-fuzz
@@ -0,0 +1,28 @@
#!/bin/bash -e
#
# Compile and check with oss-fuzz.
#
# Copyright (c) 2023 Linaro Ltd.
#
# Authors:
# Alex Bennée <alex.bennee@linaro.org>
#
# SPDX-License-Identifier: GPL-2.0-or-later

. common.rc

requires_binary clang

# the build script runs out of $src so we need to copy across
cd "$BUILD_DIR"
cp -a $QEMU_SRC .
cd src
mkdir build-oss-fuzz
export LSAN_OPTIONS=suppressions=scripts/oss-fuzz/lsan_suppressions.txt
env CC="clang" CXX="clang++" CFLAGS="-fsanitize=address" ./scripts/oss-fuzz/build.sh
export ASAN_OPTIONS="fast_unwind_on_malloc=0"
for fuzzer in $(find ./build-oss-fuzz/DEST_DIR/ -executable -type f | grep -v slirp); do
grep "LLVMFuzzerTestOneInput" ${fuzzer} > /dev/null 2>&1 || continue ;
echo Testing ${fuzzer} ... ;
"${fuzzer}" -runs=1 -seed=1 || exit 1 ;
done

0 comments on commit 4ab20b5

Please sign in to comment.