3 if [[ $# -lt 2 ]]; then
4 echo "Usage: ./generate-gcov-report.sh <rel-target-dir> <srcdir> [<srcdir> ... ]"
12 if [[ "${target_dir:0:1}" != '/' ]]; then
13 target_dir="$PWD/$target_dir"
15 summary_file="$target_dir/summary.txt"
17 mkdir -p "$target_dir"
18 rm -f "$target_dir"/*.gcov
20 for dir in $source_dirs; do
21 pushd "$dir" > /dev/null
23 find ./ -name "*${file/\.c/.gcda}" -exec gcov {} \; > /dev/null
25 find ./ -name "*.gcov" \! -path "*/`basename "$target_dir"`/*" -exec mv {} "$target_dir" \;
29 echo "========== coverage report ========" > "$summary_file"
30 for file in "$target_dir"/*.gcov; do
31 total=`grep -v " -:" "$file" | wc -l`
32 missing=`grep "#####" "$file" | wc -l`
33 hit=$((total - missing));
34 percent=$((($hit * 100)/$total))
35 fname=`basename "$file"`
36 printf "%-32s total lines: %4s not tested: %4s (%3s%%)\n" "$fname" "$total" "$missing" "$percent">> "$summary_file"
38 echo "========== =============== ========" >> "$summary_file"