gconv覆盖率统计工具

 1) gcc -fprofile-arcs -ftest-coverage -o test test.c

 2)./test 运行生成test.gcda

 3)gcov test.c

       File 'test.c'
       Lines executed:87.50% of 8
       test.c:creating 'test.c.gcov'


 4)通过lcov生成html可视化结果

 #!/bin/sh

OUTPUT_DIR=/some/path

if (! test -d $OUTPUT_DIR )

then

  echo "Missing path: $OUTPUT_DIR"

  exit 1

fi

make clean || exit 1

export LDFLAGS="-lgcov"

export CPPFLAGS="-fprofile-arcs -ftest-coverage"

make || exit 1

lcov -c -i -d . -o .coverage.base

lcov -c -d . -o .coverage.run

lcov -d . -a .coverage.base -a .coverage.run -o .coverage.total

genhtml --no-branch-coverage -o $OUTPUT_DIR .coverage.total

          rm -f .coverage.base .coverage.run .coverage.total


你可能感兴趣的:(gconv覆盖率统计工具)