From 934baa3bb14594428427bac31bf98b081c2156e0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Mon, 12 Jan 2015 18:19:45 -0800 Subject: [PATCH 1/4] 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'. --- .gitignore | 1 + Makefile | 9 +++++++++ tools/run_tests/run_lcov.sh | 18 ++++++++++++++++++ tools/run_tests/run_tests.py | 1 + 4 files changed, 29 insertions(+) create mode 100755 tools/run_tests/run_lcov.sh diff --git a/.gitignore b/.gitignore index 5202b53ad25..192b55fb438 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ deps libs objs *.pyc +*.gcno diff --git a/Makefile b/Makefile index 35c2d848003..ae78f8259d0 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 00000000000..6f22b0e8a41 --- /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 7ddf50c4a88..4cf442287a6 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'), } From 209dc44050578e08786d5c10755ad7a58fea9deb Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 13 Jan 2015 09:54:30 -0800 Subject: [PATCH 2/4] Add some ignores --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 192b55fb438..8087bd6ce5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ bins +coverage deps +gens libs objs *.pyc From d7abc8079ddf9e70e809bb04de4adb4f2485e052 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 13 Jan 2015 12:46:02 -0800 Subject: [PATCH 3/4] Sort gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8087bd6ce5a..3cae07ed12f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ bins coverage deps +*.gcno gens libs objs *.pyc -*.gcno - From 699ba2135a4bea55c431f23ab6e3ebd3981b63ca Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 13 Jan 2015 17:02:20 -0800 Subject: [PATCH 4/4] Fix Makefile.template --- templates/Makefile.template | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/Makefile.template b/templates/Makefile.template index d0ebb102408..b835c337e88 100644 --- a/templates/Makefile.template +++ b/templates/Makefile.template @@ -66,6 +66,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.