Update struct input_event
[platform/upstream/libevdev.git] / test / generate-gcov-report.sh
1 #!/bin/bash -e
2
3 if [[ $# -lt 2 ]]; then
4     echo "Usage: ./generate-gcov-report.sh <rel-target-dir> <srcdir> [<srcdir> ... ]"
5     exit 1
6 fi
7
8 target_dir=$1
9 shift
10 source_dirs=$*
11
12 if [[ "${target_dir:0:1}" != '/' ]]; then
13     target_dir="$PWD/$target_dir"
14 fi
15 summary_file="$target_dir/summary.txt"
16
17 mkdir -p "$target_dir"
18 rm -f "$target_dir"/*.gcov
19
20 for dir in $source_dirs; do
21         pushd "$dir" > /dev/null
22         for file in *.c; do
23                 find ./ -name "*${file/\.c/.gcda}" -exec gcov {} \; > /dev/null
24         done
25         find ./ -name "*.gcov" \! -path "*/`basename "$target_dir"`/*" -exec mv {} "$target_dir" \;
26         popd > /dev/null
27 done
28
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"
37 done
38 echo "========== =============== ========" >> "$summary_file"