diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2023-05-17 18:44:37 +0200 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2023-05-28 22:43:44 +0200 |
commit | 2b0c34c8d13ab4a899a722ae272a366bf6051168 (patch) | |
tree | a38de48cf86b8e9c012b116f18d75f44c8438eea /src/development/gcov | |
parent | e526873c5277ad28f7efb24d949240f07a95dd43 (diff) | |
download | notes-2b0c34c8d13ab4a899a722ae272a366bf6051168.tar.gz notes-2b0c34c8d13ab4a899a722ae272a366bf6051168.zip |
gcov: example to generate coverage
Diffstat (limited to 'src/development/gcov')
-rw-r--r-- | src/development/gcov/Makefile | 24 | ||||
-rw-r--r-- | src/development/gcov/cov.cc | 17 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/development/gcov/Makefile b/src/development/gcov/Makefile new file mode 100644 index 0000000..f27f8d8 --- /dev/null +++ b/src/development/gcov/Makefile @@ -0,0 +1,24 @@ +# Copyright (C) 2023 johannst + +CXXFLAGS = -fprofile-arcs -ftest-coverage +# or the alias +#CXXFLAGS = --coverage + +cov-gcc: clean + g++ $(CXXFLAGS) -c -o cov.o cov.cc + g++ $(CXXFLAGS) -o $@ cov.o + ./$@ + gcov --demangled-names cov.cc + cat cov.cc.gcov +.PHONY: cov-gcc + +cov-clang: clean + clang++ $(CXXFLAGS) -c -o cov.o cov.cc + clang++ $(CXXFLAGS) -o $@ cov.o + ./$@ + llvm-cov gcov --demangled-names cov.cc + cat cov.cc.gcov +.PHONY: cov-clang + +clean: + $(RM) *.gcov *.gcno *.gcda *.o cov-* diff --git a/src/development/gcov/cov.cc b/src/development/gcov/cov.cc new file mode 100644 index 0000000..3737d81 --- /dev/null +++ b/src/development/gcov/cov.cc @@ -0,0 +1,17 @@ +// Copyright (C) 2023 johannst + +#include <cstdio> + +void tell_me(int desc) { + if (desc & 1) { + std::puts("this"); + } else { + std::puts("that"); + } +} + +int main(int argc, char *argv[]) { + tell_me(argc); + tell_me(argc); + return 0; +} |