aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-01-12 18:19:45 -0800
committerGravatar Craig Tiller <ctiller@google.com>2015-01-12 18:19:45 -0800
commit934baa3bb14594428427bac31bf98b081c2156e0 (patch)
tree15a9ccf3c7bbc31ec17946f01b49b937ad8b9ff4
parent9fef05c2f07a20c2e32746cd4bbb14e85e1e64fc (diff)
Add tools/run_tests/run_lcov.sh
This is a tool for collecting coverage reports from our tests and combining them with the open-source tool 'lcov'.
-rw-r--r--.gitignore1
-rw-r--r--Makefile9
-rwxr-xr-xtools/run_tests/run_lcov.sh18
-rwxr-xr-xtools/run_tests/run_tests.py1
4 files changed, 29 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 5202b53ad2..192b55fb43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,4 +3,5 @@ deps
libs
objs
*.pyc
+*.gcno
diff --git a/Makefile b/Makefile
index 35c2d84800..ae78f8259d 100644
--- a/Makefile
+++ b/Makefile
@@ -49,6 +49,15 @@ CPPFLAGS_msan = -O1 -fsanitize=memory -fno-omit-frame-pointer
LDFLAGS_msan = -fsanitize=memory
DEFINES_msan = NDEBUG
+VALID_CONFIG_gcov = 1
+CC_gcov = gcc
+CXX_gcov = g++
+LD_gcov = gcc
+LDXX_gcov = g++
+CPPFLAGS_gcov = -O0 -fprofile-arcs -ftest-coverage
+LDFLAGS_gcov = -fprofile-arcs -ftest-coverage
+DEFINES_gcov = NDEBUG
+
# General settings.
# You may want to change these depending on your system.
diff --git a/tools/run_tests/run_lcov.sh b/tools/run_tests/run_lcov.sh
new file mode 100755
index 0000000000..6f22b0e8a4
--- /dev/null
+++ b/tools/run_tests/run_lcov.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -ex
+
+out=`realpath ${1:-coverage}`
+
+root=`realpath $(dirname $0)/../..`
+tmp=`mktemp`
+cd $root
+tools/run_tests/run_tests.py -c gcov
+lcov --capture --directory . --output-file $tmp
+genhtml $tmp --output-directory $out
+rm $tmp
+if which xdg-open > /dev/null
+then
+ xdg-open file://$out/index.html
+fi
+
diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py
index 7ddf50c4a8..4cf442287a 100755
--- a/tools/run_tests/run_tests.py
+++ b/tools/run_tests/run_tests.py
@@ -37,6 +37,7 @@ _CONFIGS = {
'tsan': SimpleConfig('tsan'),
'msan': SimpleConfig('msan'),
'asan': SimpleConfig('asan'),
+ 'gcov': SimpleConfig('gcov'),
'valgrind': ValgrindConfig('dbg'),
}