Date: Tue, 31 Oct 2017 05:04:03 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r325212 - in projects/runtime-coverage: etc/mtree tests tests/tools Message-ID: <201710310504.v9V543pD072936@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Tue Oct 31 05:04:03 2017 New Revision: 325212 URL: https://svnweb.freebsd.org/changeset/base/325212 Log: Start adding in simple wrapper around lgov/genhtml called gather_coverage It will be installed to /usr/tests/tools for the time being Based loosely on make snippet seen in https://github.com/yaneurabeya/scratch/blob/master/demos/freebsd/runtime-coverage/Makefile . The real difference is that one needs to run a binary with coverage compiled in before running this script, so it can hoover up the .gcda's. Added: projects/runtime-coverage/tests/tools/ projects/runtime-coverage/tests/tools/Makefile (contents, props changed) projects/runtime-coverage/tests/tools/gather_coverage.sh (contents, props changed) Modified: projects/runtime-coverage/etc/mtree/BSD.tests.dist projects/runtime-coverage/tests/Makefile Modified: projects/runtime-coverage/etc/mtree/BSD.tests.dist ============================================================================== --- projects/runtime-coverage/etc/mtree/BSD.tests.dist Tue Oct 31 04:27:06 2017 (r325211) +++ projects/runtime-coverage/etc/mtree/BSD.tests.dist Tue Oct 31 05:04:03 2017 (r325212) @@ -527,6 +527,8 @@ vm .. .. + tools + .. usr.bin apply .. Modified: projects/runtime-coverage/tests/Makefile ============================================================================== --- projects/runtime-coverage/tests/Makefile Tue Oct 31 04:27:06 2017 (r325211) +++ projects/runtime-coverage/tests/Makefile Tue Oct 31 05:04:03 2017 (r325212) @@ -10,6 +10,7 @@ KYUAFILE= yes SUBDIR+= etc SUBDIR+= sys +SUBDIR+= tools SUBDIR_PARALLEL= Added: projects/runtime-coverage/tests/tools/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage/tests/tools/Makefile Tue Oct 31 05:04:03 2017 (r325212) @@ -0,0 +1,11 @@ +# $FreeBSD$ + +.include <src.opts.mk> + +BINDIR= ${TESTSBASE}/tools + +.if ${MK_COVERAGE} != "no" +SCRIPTS+= gather_coverage +.endif + +.include <bsd.prog.mk> Added: projects/runtime-coverage/tests/tools/gather_coverage.sh ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/runtime-coverage/tests/tools/gather_coverage.sh Tue Oct 31 05:04:03 2017 (r325212) @@ -0,0 +1,74 @@ +#!/bin/sh +# +# Copyright (c) 2017 Ngie Cooper +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +# usage: gather_coverage + +SCRIPT=${0##*/} + +: ${COVERAGE_OUTPUT=coverage-output} +: ${GCOV=gcov} + +error() +{ + printf >&2 "${SCRIPT}: ERROR: $@\n" +} + +require_command() +{ + local cmd=$1; shift + + if ! command -v $cmd >/dev/null; then + error "required command not found: $cmd" + if [ $# -gt 0 ]; then + printf >&2 "$@\n" + fi + exit 1 + fi +} + + + +require_command ${GCOV} \ + "Install gcov from base or the appropriate version from ports" +for cmd in lcov genhtml; do + require_command ${cmd} "Install devel/lcov from ports" +done + +if ! COVERAGE_TMP=$(mktemp -d tmp.XXXXXX); then + error "failed to create COVERAGE_TMP" + exit 1 +fi +trap "rm -Rf '$COVERAGE_TMP'" EXIT INT TERM + +set -e + +lcov --gcov-tool ${GCOV} --capture --directory ${COVERAGE_TMP} --output-file \ + ${COVERAGE_TMP}/coverage.info +genhtml ${COVERAGE_TMP}/coverage.info --output-directory ${COVERAGE_OUTPUT} + +printf "${SCRIPT}: INFO: coverage output successfully placed in ${COVERAGE_OUTPUT}\n"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710310504.v9V543pD072936>