aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@pelagicore.com>2018-02-06 15:44:52 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2018-02-07 13:08:01 +0000
commit7d9598740374db338687b9c3d2d6fb7d89b6ae67 (patch)
tree8d053a9ca3c0304b8c9ffb82c116866e09642723
parent0448ec8f0cb3fb52d41e156c2ec15fcff225d2f9 (diff)
Add a easy way to do a test-coverage run
This is inspired by QtApplicationManagers version, but adapted for qtivi and it's autogeneration. Change-Id: I8880e277646f66b976787739e56206044577560a Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r--.qmake.conf2
-rw-r--r--mkspecs/features/ivi-coverage.prf18
-rw-r--r--qtivi.pro34
3 files changed, 54 insertions, 0 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 120586f..c39c219 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -7,3 +7,5 @@ DEFINES += QT_NO_FOREACH
QMAKEFEATURES=$$PWD/mkspecs/features
MODULE_VERSION = 2.0.0
+
+!win32: CONFIG += ivi-coverage
diff --git a/mkspecs/features/ivi-coverage.prf b/mkspecs/features/ivi-coverage.prf
new file mode 100644
index 0000000..b642b4a
--- /dev/null
+++ b/mkspecs/features/ivi-coverage.prf
@@ -0,0 +1,18 @@
+# generate code coverage information using gcov/lcov/genhtml
+CONFIG(debug,debug|release) {
+ equals(TEMPLATE, "subdirs") {
+ sub-coverage.target = coverage
+ sub-coverage.CONFIG = recursive
+ QMAKE_EXTRA_TARGETS += sub-coverage
+ } else {
+ coverage_pre.commands += @echo && echo "Building with coverage support..." && echo $(eval CXXFLAGS += -O0 -fprofile-arcs -ftest-coverage)$(eval LFLAGS += -O0 -fprofile-arcs -ftest-coverage)
+
+ coverage.CONFIG += recursive
+ coverage.commands = @echo && echo "Finished building with coverage support." && echo
+ build_pass|!debug_and_release:coverage.depends = coverage_pre all
+
+ QMAKE_EXTRA_TARGETS *= coverage_pre coverage
+ }
+}
+
+QMAKE_CLEAN += $(OBJECTS_DIR)/*.gcda $(OBJECTS_DIR)/*.gcno $(TARGET).gcov-info
diff --git a/qtivi.pro b/qtivi.pro
index 03999c7..54c951c 100644
--- a/qtivi.pro
+++ b/qtivi.pro
@@ -21,4 +21,38 @@ load(qt_parts)
SUBDIRS += mkspecs
mkspecs.depends = sub_src
+GCOV_EXCLUDE = /usr/* \
+ $$[QT_INSTALL_PREFIX]/* \
+ $$[QT_INSTALL_PREFIX/src]/* \
+ $$_PRO_FILE_PWD_/tests/* \
+ $$OUT_PWD/*/.moc/* \
+ $$OUT_PWD/*/.rcc/* \
+ $$OUT_PWD/*/.uic/* \
+ $$OUT_PWD/tests/* \
+ $$OUT_PWD/examples/* \
+ $$_PRO_FILE_PWD_/examples/* \
+
+
+!prefix_build: GCOV_EXCLUDE += $$clean_path($$[QT_INSTALL_PREFIX]/../*) $$clean_path($$[QT_INSTALL_PREFIX/src]/../*)
+
+for (f, GCOV_EXCLUDE) {
+ GCOV_EXCLUDE_STR += $$shell_quote($$f)
+}
+
+global-check-coverage.target = check-coverage
+global-check-coverage.depends = coverage
+global-check-coverage.commands = ( \
+ find . -name \"*.gcov-info\" -print0 | xargs -0 rm -f && \
+ lcov -c -i -d . --rc lcov_branch_coverage=1 --rc geninfo_auto_base=1 -o $$OUT_PWD/base.gcov-info && \
+ cd tests && make check && cd .. && \
+ lcov -c -d . --rc lcov_branch_coverage=1 --rc geninfo_auto_base=1 -o $$OUT_PWD/test.gcov-info && \
+ lcov --rc lcov_branch_coverage=1 -o $$OUT_PWD/temp.gcov-info `find . -name \"*.gcov-info\" | xargs -n1 echo -a` && \
+ lcov --rc lcov_branch_coverage=1 -o $$OUT_PWD/qtivi.gcov-info -r temp.gcov-info $$GCOV_EXCLUDE_STR && \
+ rm -f base.gcov-info test.gcov-info temp.gcov-info && \
+ genhtml -o branch-coverage -s -f --legend --branch-coverage --rc lcov_branch_coverage=1 --demangle-cpp qtivi.gcov-info && echo \"\\n\\nCoverage info is available at file://`pwd`/branch-coverage/index.html\" \
+)
+
+QMAKE_EXTRA_TARGETS -= sub-check-coverage
+QMAKE_EXTRA_TARGETS *= global-check-coverage
+
OTHER_FILES += sync.profile