#!/usr/bin/env bash

. ../common.sh

init "an entire .c file is never executed"

compile_c foo.c
compile_c bar.c
compile_c quux.c
link foo foo.o quux.o
link bar bar.o quux.o

run foo 1
run foo 2
run foo 23 423
# Note we never run bar
[ -f foo.da -o -f foo.gcda ] || fail "no counts file foo.gcda produced"
[ -f quux.da -o -f quux.gcda ] || fail "no counts file quux.gcda produced"
[ -f bar.da -o -f bar.gcda ] && fail "counts file quux.gcda produced unexpectedly"

run_gcov foo.c
run_tggcov foo.c
compare_counts foo.c

run_gcov quux.c
run_tggcov quux.c
compare_counts quux.c

# gcc 4.7 won't write a c.gcov file if the .gcda doesn't exist
# so we can only check for zero line counts directly.  But we
# need to work out whether to use the -N flag
run_tggcov $(_tggcov_Nflag quux.c) bar.c
compare_counts bar.c
