Skip to content

Commit

Permalink
Add add-tracefile test
Browse files Browse the repository at this point in the history
  • Loading branch information
CezaryGapinski committed Aug 21, 2019
1 parent fff2d5c commit 16e97e6
Show file tree
Hide file tree
Showing 10 changed files with 632 additions and 0 deletions.
40 changes: 40 additions & 0 deletions gcovr/tests/add_coverages/Makefile
@@ -0,0 +1,40 @@
CFLAGS= -fprofile-arcs -ftest-coverage -fPIC

all:
$(CXX) $(CFLAGS) -c foo.cpp -o foo.o
$(CXX) $(CFLAGS) -c bar.cpp -o bar.o
$(CXX) $(CFLAGS) -DFOO -c main.cpp -o main_foo.o
$(CXX) $(CFLAGS) main_foo.o foo.o -o testcase_foo
$(CXX) $(CFLAGS) -DBAR -c main.cpp -o main_bar.o
$(CXX) $(CFLAGS) main_bar.o bar.o -o testcase_bar

run: txt xml html sonarqube json

json_foo:
./testcase_foo
$(GCOVR) -d --json-pretty -o coverage_foo.json

json_bar:
./testcase_bar
$(GCOVR) -d --json -o coverage_bar.json

txt: json_foo json_bar
$(GCOVR) -a coverage_foo.json -a coverage_bar.json -o coverage.txt

xml: json_foo json_bar
$(GCOVR) -a coverage_foo.json -a coverage_bar.json -x -o coverage.xml

html: json_foo json_bar
$(GCOVR) -a coverage_foo.json -a coverage_bar.json --html-details -o coverage.html

sonarqube: json_foo json_bar
$(GCOVR) -a coverage_foo.json -a coverage_bar.json --sonarqube sonarqube.xml

json: json_foo json_bar
$(GCOVR) -a coverage_foo.json -a coverage_bar.json --json-pretty -o coverage.json

clean:
rm -f testcase_*
rm -f *.gc*
rm -f *.o
rm -f coverage.txt coverage.xml coverage*.html sonarqube.xml coverage*.json
1 change: 1 addition & 0 deletions gcovr/tests/add_coverages/README
@@ -0,0 +1 @@
A simple test that verifies adding coverages.
7 changes: 7 additions & 0 deletions gcovr/tests/add_coverages/bar.cpp
@@ -0,0 +1,7 @@
int bar()
{
int x=2;
int y=2;
return x-y;
}

6 changes: 6 additions & 0 deletions gcovr/tests/add_coverages/foo.cpp
@@ -0,0 +1,6 @@
int foo()
{
int x=2;
int y=2;
return x+y;
}
19 changes: 19 additions & 0 deletions gcovr/tests/add_coverages/main.cpp
@@ -0,0 +1,19 @@
#include <iostream>

#ifdef FOO
extern int foo();
#endif
#ifdef BAR
extern int bar();
#endif

int main(int argc, char* argv[]) {
#ifdef FOO
foo();
#endif
#ifdef BAR
bar();
#endif

return 0;
}

0 comments on commit 16e97e6

Please sign in to comment.