Compare commits
1 commit
93aea417c0
...
988154ebea
Author | SHA1 | Date | |
---|---|---|---|
|
988154ebea |
3 changed files with 37 additions and 42 deletions
25
Makefile.am
25
Makefile.am
|
@ -17,3 +17,28 @@ EXTRA_DIST = \
|
||||||
RELNOTES \
|
RELNOTES \
|
||||||
autogen.sh \
|
autogen.sh \
|
||||||
misc/gendoc.pl
|
misc/gendoc.pl
|
||||||
|
|
||||||
|
if WITH_CODE_COVERAGE
|
||||||
|
covdir = @abs_top_builddir@/cov
|
||||||
|
coverage: coverage-clean all coverage-prepare coverage-run coverage-report
|
||||||
|
coverage-clean:
|
||||||
|
-rm -rf "${covdir}"
|
||||||
|
coverage-prepare:
|
||||||
|
mkdir "${covdir}"
|
||||||
|
if CLANG_CODE_COVERAGE
|
||||||
|
profdata = ${covdir}/@PACKAGE@.profdata
|
||||||
|
# hardcoding libpam.so here is horrible, need to find a better solution
|
||||||
|
coverage-run:
|
||||||
|
LLVM_PROFILE_FILE="${covdir}/@PACKAGE@.%p.raw" \
|
||||||
|
${MAKE} -C "@abs_top_builddir@" check
|
||||||
|
coverage-report:
|
||||||
|
llvm-profdata merge -sparse "${covdir}/@PACKAGE@".*.raw -o "${profdata}"
|
||||||
|
llvm-cov show -instr-profile="${profdata}" -format=html -output-dir="${covdir}" \
|
||||||
|
--object "@abs_top_builddir@/lib/libpam/.libs/libpam.so"
|
||||||
|
@echo "coverage report: file://${covdir}/index.html"
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
coverage:
|
||||||
|
echo "code coverage is not enabled." >&2
|
||||||
|
false
|
||||||
|
endif
|
||||||
|
|
20
configure.ac
20
configure.ac
|
@ -127,17 +127,22 @@ AC_ARG_ENABLE([werror],
|
||||||
AC_ARG_ENABLE([code-coverage],
|
AC_ARG_ENABLE([code-coverage],
|
||||||
AS_HELP_STRING([--enable-code-coverage],
|
AS_HELP_STRING([--enable-code-coverage],
|
||||||
[enable code coverage]))
|
[enable code coverage]))
|
||||||
AM_CONDITIONAL([CODE_COVERAGE], [test x"$enable_code_coverage" = x"yes"])
|
|
||||||
AS_IF([test x"$enable_code_coverage" = x"yes"], [
|
AS_IF([test x"$enable_code_coverage" = x"yes"], [
|
||||||
AS_IF([test x"$ax_cv_c_compiler_vendor" = x"clang"], [
|
AM_COND_IF([WITH_TEST], [
|
||||||
CFLAGS="${CFLAGS} -fprofile-instr-generate -fcoverage-mapping"
|
AS_IF([test x"$ax_cv_c_compiler_vendor" = x"clang"], [
|
||||||
|
CFLAGS="${CFLAGS} -fprofile-instr-generate -fcoverage-mapping"
|
||||||
|
clang_code_coverage="yes"
|
||||||
|
], [
|
||||||
|
AC_MSG_ERROR([code coverage is only supported with clang])
|
||||||
|
])
|
||||||
|
AC_DEFINE([WITH_CODE_COVERAGE], [1], [Define to 1 if code coverage is enabled])
|
||||||
|
AC_MSG_NOTICE([code coverage enabled])
|
||||||
], [
|
], [
|
||||||
AC_MSG_ERROR([code coverage is only supported with clang])
|
AC_MSG_ERROR([code coverage requires unit tests])
|
||||||
])
|
])
|
||||||
AC_DEFINE([CODE_COVERAGE], [1], [Define to 1 if code coverage is enabled])
|
|
||||||
AC_MSG_NOTICE([code coverage enabled])
|
|
||||||
])
|
])
|
||||||
AC_SUBST([enable_code_coverage], [$enable_code_coverage])
|
AM_CONDITIONAL([WITH_CODE_COVERAGE], [test x"$enable_code_coverage" = x"yes"])
|
||||||
|
AM_CONDITIONAL([CLANG_CODE_COVERAGE], [test x"$clang_code_coverage" = x"yes"])
|
||||||
|
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
Makefile
|
Makefile
|
||||||
|
@ -160,6 +165,5 @@ AC_CONFIG_FILES([
|
||||||
modules/pam_unix/Makefile
|
modules/pam_unix/Makefile
|
||||||
t/Makefile
|
t/Makefile
|
||||||
])
|
])
|
||||||
AC_CONFIG_FILES([misc/coverage.sh],[chmod +x misc/coverage.sh])
|
|
||||||
AC_CONFIG_FILES([misc/coverity.sh],[chmod +x misc/coverity.sh])
|
AC_CONFIG_FILES([misc/coverity.sh],[chmod +x misc/coverity.sh])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
usage() {
|
|
||||||
echo "usage: ${0##*/} [-jN]" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
while getopts "j:" opt ; do
|
|
||||||
case $opt in
|
|
||||||
j)
|
|
||||||
j="-j$OPTARG"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if ! [ "@enable_code_coverage@" = "yes" ] ; then
|
|
||||||
echo "Code coverage disabled." >&2
|
|
||||||
echo "Re-run ./configure with --enable-code-coverage and try again." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
srcdir="@abs_top_srcdir@"
|
|
||||||
profdir="@abs_top_builddir@/cov"
|
|
||||||
profraw="${profdir}/@PACKAGE@.%p.raw"
|
|
||||||
profdata="${profdir}/@PACKAGE@.profdata"
|
|
||||||
export LLVM_PROFILE_FILE="${profraw}"
|
|
||||||
[ -e "${profdir}" ] && rm -r "${profdir}"
|
|
||||||
gmake -C "${srcdir}" $j check
|
|
||||||
llvm-profdata merge -sparse "${profdir}/@PACKAGE@".*.raw -o "${profdata}"
|
|
||||||
llvm-cov show -instr-profile="${profdata}" -format=html -output-dir="${profdir}" \
|
|
||||||
--object "@abs_top_builddir@/lib/libpam/.libs/libpam.so"
|
|
Loading…
Reference in a new issue