Skip to content

Instantly share code, notes, and snippets.

@latk
Last active May 27, 2022 04:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save latk/102b125dff160484f93d8997204fc201 to your computer and use it in GitHub Desktop.
Save latk/102b125dff160484f93d8997204fc201 to your computer and use it in GitHub Desktop.
#include<stdio.h>
void fun1(){
printf("fun1\n");
}
void fun2(){
printf("fun2\n");
}
.PHONY: help question answer answer-gcovr clean
help:
@echo "Available targets:"
@echo " make question"
@echo " make answer"
@echo " make answer-gcovr"
clean:
rm -rf ut1 ut2 *.gcda *.gcno *.o *.json coverage.*
question: clean
gcc -Wall -fprofile-arcs -ftest-coverage ut1.c common.c -o ut1
gcc -Wall -fprofile-arcs -ftest-coverage ut2.c common.c -o ut2
./ut1
./ut2
gcov common.c
cat common.c.gcov
answer: clean
gcc -Wall --coverage -c common.c -o common.o
gcc -Wall --coverage ut1.c common.o -o ut1
gcc -Wall --coverage ut2.c common.o -o ut2
./ut1
./ut2
gcov common.c
cat common.c.gcov
answer-gcovr: clean
gcc -Wall --coverage ut1.c common.c -o ut1
./ut1
gcovr --json ut1.json
rm *.gcda *.gcno
gcc -Wall --coverage ut2.c common.c -o ut2
./ut2
gcovr --json ut2.json
gcovr -a ut1.json -a ut2.json --html-details coverage.html
#include<stdio.h>
void fun1();
int main(){
fun1();
}
#include<stdio.h>
void fun2();
int main(){
fun2();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment