1# 2# Copyright (c) 2021 Nordic Semiconductor ASA 3# 4# SPDX-License-Identifier: Apache-2.0 5# 6 7echo "Usage: $0 <seconds to run> <bit width> <test case>" 8 9# For convenience (use for extra checks): 10# export AFL_USE_ASAN=1 11# For convenience (use if afl fails and recommends this): 12export AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES=1 13 14if [ -d "build-afl" ]; then rm -r build-afl; fi 15mkdir build-afl 16pushd build-afl 17cmake .. -DCMAKE_C_COMPILER=afl-clang-fast -DCMAKE_C_FLAGS="-m$2" -DTEST_CASE=$3 18[[ $? -ne 0 ]] && exit 1 19make fuzz_target 20[[ $? -ne 0 ]] && exit 1 21popd 22afl-fuzz -i build-afl/fuzz_input -o build-afl/output -V $1 -- ./build-afl/fuzz_target 23exit $(find build-afl/output/default/crashes/ -type f -printf x | wc -c) 24