xref: /openbmc/qemu/tests/docker/test-fuzz (revision ed75658a)
1#!/bin/bash -e
2#
3# Compile and check with oss-fuzz.
4#
5# Copyright (c) 2023 Linaro Ltd.
6#
7# Authors:
8#  Alex Bennée <alex.bennee@linaro.org>
9#
10# SPDX-License-Identifier: GPL-2.0-or-later
11
12. common.rc
13
14requires_binary clang
15
16# the build script runs out of $src so we need to copy across
17cd "$BUILD_DIR"
18cp -a $QEMU_SRC .
19cd src
20mkdir build-oss-fuzz
21export LSAN_OPTIONS=suppressions=scripts/oss-fuzz/lsan_suppressions.txt
22env CC="clang" CXX="clang++" CFLAGS="-fsanitize=address" ./scripts/oss-fuzz/build.sh
23export ASAN_OPTIONS="fast_unwind_on_malloc=0"
24for fuzzer in $(find ./build-oss-fuzz/DEST_DIR/ -executable -type f | grep -v slirp); do
25        grep "LLVMFuzzerTestOneInput" ${fuzzer} > /dev/null 2>&1 || continue ;
26        echo Testing ${fuzzer} ... ;
27        "${fuzzer}" -runs=1 -seed=1 || exit 1 ;
28done
29