Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Add a --with-coverage to have a facilitate code coverage checking
Baptiste Daroussin committed 6 years ago
commit f66e4acbd09c167a057d4c9d553376d3f0012410
parent 50b4e28
3 files changed +36 -5
modified Makefile.autosetup
@@ -3,8 +3,16 @@ DIRS= external compat libpkg/repo libpkg src docs scripts @testsdir@

include $(MK)/dir.mk

+
@if coverage == "1"
+
check: clean-profiles
+

+
clean-profiles:
+
	rm -f /tmp/pkg.*.profraw
+
@endif
+

check: all
@if testsdir == "tests"
+
	export LLVM_PROFILE_FILE=/tmp/pkg.%p.profraw
	if [ "$(HTML)" != "" ]; then \
		args="-r $(top_builddir)/res.db" ; \
	fi ; \
@@ -18,6 +26,14 @@ check: all
	exit $${FAILED}
@endif

+
@if coverage == "1"
+
check-coverage: check
+
	llvm-profdata merge --output=pkg.profdata /tmp/pkg.*.profraw
+

+
report-coverage:
+
	llvm-cov report ./src/pkg -instr-profile=pkg.profdata --use-color -ignore-filename-regex=external -ignore-filename-regex=compat
+
@endif
+

COCCI_ARGS=	-I ${top_srcdir} \
		-I /usr/include \
		-I /usr/local/include \
modified auto.def
@@ -15,6 +15,7 @@ options {
	pkgconfigdir:WHERE => "path to the directory where to install pc files"
	with-ldns => "add support for libldns"
	with-libarchive.pc => "build with libarchive getting flags via pc files"
+
	with-coverage => "build with llvm coverage support"
}

if {[opt-str pkgconfigdir dir]} {
@@ -53,7 +54,7 @@ if {[string match *-linux* [get-define host]]} {
	define-feature static
}

-
if {![opt-bool with-libarchive.pc]} {
+
if {[opt-bool with-libarchive.pc]} {
	cc-with { -libs { -larchive }} {
		if {![cc-check-functions archive_read_open]} {
			user-error "Unable to find libarchive"
@@ -232,10 +233,20 @@ cc-check-includes bsd/err.h bsd/libutil.h bsd/readpassphrase.h \
	bsd/stdio.h bsd/strlib.h bsd/string.h bsd/sys/cdefs.h \
	bsd/unistd.h
 
-
# capsicum
-
if {[cc-check-functions cap_sandboxed]} {
-
	define-feature capsicum
-
	cc-check-includes sys/capsicum.h
+
if {[opt-bool with-coverage]} {
+
	define-append COVERAGE_CFLAGS -O0 -ggdb -fprofile-instr-generate -fcoverage-mapping
+
	define-append COVERAGE_LDFLAGS -fprofile-instr-generate -fuse-ld=/usr/local/bin/ld.lld
+
	define CC /usr/local/bin/clang
+
	define CC_FOR_BUILD /usr/local/bin/clang
+
	define coverage 1
+
# disable capsicum when coverage is used because coverage does not work in
+
# capsicum mode
+
} else {
+
# capsicum 
+
	if {[cc-check-functions cap_sandboxed]} {
+
		define-feature capsicum
+
			cc-check-includes sys/capsicum.h
+
	}
}

define testsdir ""
modified mk/defs.mk.in
@@ -1,6 +1,10 @@
RANLIB=	@RANLIB@
AR=	@AR@
CC=	@CC@
+
@if coverage == "1"
+
CFLAGS+=	@COVERAGE_CFLAGS@
+
LDFLAGS+=	@COVERAGE_LDFLAGS@
+
@endif
SHOBJ_CFLAGS=	@SHOBJ_CFLAGS@
LIBSOEXT=	@LIBSOEXT@
SH_SOEXT=	@SH_SOEXT@