run_coverage.sh 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash
  2. set -e # 遇到错误立即退出
  3. # ================================
  4. # 1. 运行 fuzzer
  5. # ================================
  6. ./build/linux/x86/release/RyanJson \
  7. ./test/fuzzer/corpus \
  8. -dict=./test/fuzzer/RyanJsonFuzzer.dict \
  9. -timeout=4 \
  10. -runs=99999999 \
  11. -verbosity=0 \
  12. -max_len=8192 \
  13. -workers=5 \
  14. -jobs=10
  15. # ================================
  16. # 2. 合并 profile 数据
  17. # ================================
  18. llvm-profdata merge -sparse default.profraw -o default.profdata
  19. # ================================
  20. # 3. 生成覆盖率报告(文本汇总)
  21. # ================================
  22. # 注意:llvm-cov report 只支持汇总统计,不支持行级参数
  23. # --show-functions 显示函数级覆盖率
  24. # --show-region-summary 显示区域覆盖率
  25. llvm-cov report ./build/linux/x86/release/RyanJson \
  26. -instr-profile=default.profdata \
  27. -show-mcdc-summary \
  28. -show-functions \
  29. -show-region-summary \
  30. -sources ./test/fuzzer ./RyanJson
  31. # ================================
  32. # 4. 生成覆盖率报告(HTML详细)
  33. # ================================
  34. llvm-cov show ./build/linux/x86/release/RyanJson \
  35. -instr-profile=default.profdata \
  36. -format=html \
  37. -output-dir=coverage/docs \
  38. -show-mcdc-summary \
  39. -show-expansions \
  40. -show-regions \
  41. -show-line-counts-or-regions \
  42. -sources ./RyanJson
  43. # -sources ./test/fuzzer ./RyanJson