Commit bd69a737 authored by Thanassis Tsiodras's avatar Thanassis Tsiodras
Browse files
parent 5a84ccc5
all:
gcc -g -O0 -fprofile-arcs -ftest-coverage coverage_demo.c
coverage_demo:
gcc -g -O0 -fprofile-arcs -ftest-coverage -o $@ coverage_demo.c
report:
report: coverage_demo
$(MAKE)
gcov -pcb coverage_demo.c
cat coverage_demo.c.gcov
decision: coverage_demo
$(MAKE) clean
$(MAKE)
./coverage_demo 3 0 2
./coverage_demo 1 0 1
$(MAKE) report
condition: coverage_demo
$(MAKE) clean
$(MAKE)
./coverage_demo 1 0 2
./coverage_demo 2 1 1
$(MAKE) report
mcdc: coverage_demo
$(MAKE) clean
$(MAKE)
./coverage_demo 2 0 1
./coverage_demo 3 1 2
./coverage_demo 1 0 1
$(MAKE) report
clean:
rm -f coverage_demo.c.gcov coverage_demo.gcda coverage_demo.gcno a.out
rm -f coverage_demo.c.gcov coverage_demo.gcda coverage_demo.gcno coverage_demo
......@@ -4,11 +4,18 @@
int main(int argc, char *argv[])
{
uint32_t t1 = atoi(argv[1]);
uint32_t t2 = t1 < 8 && t1 > 2;
if (t1 < 7 && t1 > 3)
printf("3<%d<7 was true\n", t1);
else
printf("3<%d<7 was false\n", t1);
uint32_t a = atoi(argv[1]);
uint32_t b = atoi(argv[2]);
uint32_t x = atoi(argv[3]);
if (a > 1 && b == 0) {
puts("Decision 1 was true");
} else {
puts("Decision 1 was false");
}
if (a == 2 || x > 1) {
puts("Decision 2 was true");
} else {
puts("Decision 2 was false");
}
return 0;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment