fuzz.sh 843 B

1234567891011121314151617181920212223242526
  1. #!/bin/bash -eux
  2. ROOT_DIR=$(dirname $0)/../../
  3. INCLUDE_DIR=${ROOT_DIR}/src/
  4. FUZZING_DIR=${ROOT_DIR}/extras/fuzzing/
  5. CXXFLAGS="-g -fprofile-instr-generate -fcoverage-mapping -fsanitize=address,undefined,fuzzer -fno-sanitize-recover=all"
  6. fuzz() {
  7. NAME="$1"
  8. FUZZER="${NAME}_fuzzer"
  9. FUZZER_CPP="${FUZZING_DIR}/${NAME}_fuzzer.cpp"
  10. CORPUS_DIR="${FUZZING_DIR}/${NAME}_corpus"
  11. SEED_CORPUS_DIR="${FUZZING_DIR}/${NAME}_seed_corpus"
  12. clang++-${CLANG} ${CXXFLAGS} -o ${FUZZER} -I$INCLUDE_DIR ${FUZZER_CPP}
  13. export ASAN_OPTIONS="detect_leaks=0"
  14. export LLVM_PROFILE_FILE="${FUZZER}.profraw"
  15. ./${FUZZER} "$CORPUS_DIR" "$SEED_CORPUS_DIR" -max_total_time=30 -timeout=1
  16. llvm-profdata-${CLANG} merge -sparse ${LLVM_PROFILE_FILE} -o ${FUZZER}.profdata
  17. llvm-cov-${CLANG} report ./${FUZZER} -instr-profile=${FUZZER}.profdata
  18. }
  19. fuzz json
  20. fuzz msgpack