run_coverage.sh 1.5 KB

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