Skip to content

Instantly share code, notes, and snippets.

@holyshared
Last active July 3, 2016 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save holyshared/bd90337a7573895fb1507c60e1ee683f to your computer and use it in GitHub Desktop.
Save holyshared/bd90337a7573895fb1507c60e1ee683f to your computer and use it in GitHub Desktop.

lcov-fixture

make
make test
#include "func1.h"
#include "func2.h"
int main(int argc, char* argv[])
{
func1(0, 2);
func1(1, 1);
func2(0, 2);
func2(1, 1);
}
#include <stdio.h>
#include <stdlib.h>
#include "func1.h"
void func1(int con1, int con2)
{
int x = 1;
if (con1 == 0) {
x = x + 1;
}
if (con2 > 1) {
x = x * 2;
}
printf ("x = %d\n", x);
}
extern void func1(int con1, int con2);
#include <stdio.h>
#include <stdlib.h>
#include "func1.h"
void func2(int con1, int con2)
{
int x = 1;
if (con1 == 0) {
x = x + 1;
}
if (con2 > 1) {
x = x * 2;
}
printf ("x = %d\n", x);
}
extern void func2(int con1, int con2);
all:
gcc -g --coverage fixture.c func1.c func2.c -o fixture
test:
./fixture
gcov -fbc fixture.c
lcov -t example -c -d . -o fixture.info --checksum --rc=lcov_branch_coverage=1
clean:
rm fixture *.gcda *.gcno *.info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment