From owner-svn-src-projects@freebsd.org Tue Oct 31 05:04:04 2017 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B541AE4E02B for ; Tue, 31 Oct 2017 05:04:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E9203D82; Tue, 31 Oct 2017 05:04:04 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9V543Wk072940; Tue, 31 Oct 2017 05:04:03 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9V543pD072936; Tue, 31 Oct 2017 05:04:03 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201710310504.v9V543pD072936@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Tue, 31 Oct 2017 05:04:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r325212 - in projects/runtime-coverage: etc/mtree tests tests/tools X-SVN-Group: projects X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: in projects/runtime-coverage: etc/mtree tests tests/tools X-SVN-Commit-Revision: 325212 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Oct 2017 05:04:04 -0000 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 + +BINDIR= ${TESTSBASE}/tools + +.if ${MK_COVERAGE} != "no" +SCRIPTS+= gather_coverage +.endif + +.include 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"