diff --git a/.gitignore b/.gitignore index 5202b53ad2514..192b55fb438ca 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ deps libs objs *.pyc +*.gcno diff --git a/Makefile b/Makefile index 35c2d848003da..ae78f8259d0cd 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 0000000000000..6f22b0e8a4110 --- /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 7ddf50c4a88d2..4cf442287a6e7 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -37,6 +37,7 @@ def run_command(self, binary): 'tsan': SimpleConfig('tsan'), 'msan': SimpleConfig('msan'), 'asan': SimpleConfig('asan'), + 'gcov': SimpleConfig('gcov'), 'valgrind': ValgrindConfig('dbg'), }