1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-23 00:15:59 +01:00

4 Commits

Author SHA1 Message Date
James Fraser
de617dedc7 Renamed script... coverage.sh 2019-02-18 23:39:34 +11:00
James Fraser
88d194cc1d Fixed matching commands. 2019-02-18 23:38:54 +11:00
James Fraser
9d36a91ace Merge branch 'master' of github.com:meekrosoft/fff into coverage 2019-02-18 23:28:51 +11:00
James Fraser
c066468236 Init coverage script 2019-02-18 23:26:56 +11:00

25
coverage.sh Executable file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
fff_len=`cat fff.h | wc -l`
# test/fff_test_c.c
gcc -E test/fff_test_c.c > out
comm -13 <(sort < fff.h | uniq) <(sort < out | uniq) > unique_to_out # strip out fff.h include
awk 'FNR==NR{a[$1];next}($1 in a){print}' fff.h unique_to_out > matched # find unique matches
awk 'FNR==NR{a[$1];next}($1 in a){print}' matched fff.h > coverage # find coverage of matches in fff.h
cov_len=`cat coverage | wc -l`
echo "test/fff_test_c.c coverage:"
echo "$cov_len / $fff_len" | bc -l
# test/fff_test_cpp.cpp
gcc -E test/fff_test_cpp.cpp -I . > out
comm -13 <(sort < fff.h | uniq) <(sort < out | uniq) > unique_to_out
awk 'FNR==NR{a[$1];next}($1 in a){print}' fff.h unique_to_out > matched
awk 'FNR==NR{a[$1];next}($1 in a){print}' matched fff.h > coverage
cov_len_2=`cat coverage | wc -l`
echo "test/fff_test_cpp.cpp coverage:"
echo "$cov_len_2 / $fff_len" | bc -l
# total coverage
echo "TOTAL COVERAGE:"
echo "($cov_len + $cov_len_2) / ($fff_len * 2)" | bc -l