From f7e16d9f3e84a0503799f0d5619f790751793230 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Mon, 16 Nov 2009 21:23:43 +0000 Subject: [PATCH] Code coverage measurement support (with lcov) This was SVN commit r7203. --- build/coverage/gen.sh | 31 +++++++++++++++++++++++++++++++ build/premake/premake.lua | 5 +++++ 2 files changed, 36 insertions(+) create mode 100755 build/coverage/gen.sh diff --git a/build/coverage/gen.sh b/build/coverage/gen.sh new file mode 100755 index 0000000000..e15d49acff --- /dev/null +++ b/build/coverage/gen.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Run "update-workspaces.sh --coverage" (in the appropriate directory) then +# do "make test Collada", before running this script. +# Also make sure you don't build via ccache. Also you might need a patch like +# http://ltp.cvs.sourceforge.net/viewvc/ltp/utils/analysis/lcov/bin/lcov?r1=1.33&r2=1.34 + +rm -f app.info + +for APPDIR in ../workspaces/gcc/obj/*; do + lcov -d $APPDIR --zerocounters + lcov -d $APPDIR -b ../workspaces/gcc --capture --initial -o temp.info + if [[ -e app.info ]]; then + lcov -a app.info -a temp.info -o app.info + else + mv temp.info app.info + fi +done + +(cd ../../binaries/system/; ./test_dbg) + +for APPDIR in ../workspaces/gcc/obj/*; do + lcov -d $APPDIR -b ../workspaces/gcc --capture -o temp.info && + lcov -a app.info -a temp.info -o app.info +done + +lcov -r app.info '/usr/*' -o app.info +lcov -r app.info '*/libraries/*' -o app.info + +mkdir output +(cd output; genhtml ../app.info) diff --git a/build/premake/premake.lua b/build/premake/premake.lua index d882085b69..976a721454 100755 --- a/build/premake/premake.lua +++ b/build/premake/premake.lua @@ -1,5 +1,6 @@ addoption("atlas", "Include Atlas scenario editor packages") addoption("collada", "Include COLLADA packages (requires FCollada library)") +addoption("coverage", "Enable code coverage data collection (GCC only)") addoption("aoe3ed", "Include AoE3Ed") addoption("icc", "Use Intel C++ Compiler (Linux only; should use either \"--cc icc\" or --without-pch too, and then set CXX=icpc before calling make)") addoption("outpath", "Location for generated project files") @@ -196,6 +197,10 @@ function package_set_build_flags() "-Wl,--as-needed", }) end + if options["coverage"] then + tinsert(package.buildoptions, {"-fprofile-arcs", "-ftest-coverage"}) + tinsert(package.links, "gcov") + end end tinsert(package.buildoptions, {