mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-21 13:29:25 +01:00
build: Enable configuring with gcov
This allows generating code and test coverage reports using lcov & genhtml. Useful for understanding how much of the codebase is currently covered by unit and autotests.
This commit is contained in:
parent
6e98d6bf13
commit
92822bd53a
15
Makefile.am
15
Makefile.am
@ -749,12 +749,25 @@ if WIRED
|
||||
endif
|
||||
endif
|
||||
|
||||
clean-local:
|
||||
gcov-clean:
|
||||
if GCOV
|
||||
-$(LCOV) --quiet --directory $(builddir) -z
|
||||
-rm -rf "$(builddir)/iwd-coverage.info" "$(builddir)/gcov"
|
||||
-find . -name "*.gcda" -o -name "*.gcov" -o -name "*.gcno" -delete
|
||||
endif
|
||||
|
||||
clean-local: gcov-clean
|
||||
-rm -f unit/cert-*.pem unit/cert-*.csr unit/cert-*.srl unit/*-settings.8021x
|
||||
|
||||
maintainer-clean-local:
|
||||
-rm -rf build-aux ell
|
||||
|
||||
gcov-report:
|
||||
if GCOV
|
||||
$(LCOV) --quiet --directory $(builddir) --capture --output-file "iwd-coverage.info"
|
||||
LANG=C $(GENHTML) --quiet --prefix $(builddir) --output-directory "$(builddir)/gcov" --title "iwd Code Coverage" --legend "$(builddir)/iwd-coverage.info"
|
||||
endif
|
||||
|
||||
src/builtin.h: src/genbuiltin config.status
|
||||
$(AM_V_at)$(MKDIR_P) $(@D)
|
||||
$(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@
|
||||
|
21
acinclude.m4
21
acinclude.m4
@ -46,6 +46,27 @@ AC_DEFUN([AC_PROG_CC_UBSAN], [
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([AC_PROG_CC_GCOV], [
|
||||
AC_CACHE_CHECK([whether ${CC-cc} accepts -fprofile-arcs], ac_cv_prog_cc_profile_arcs, [
|
||||
echo 'void f(){}' > conftest.c
|
||||
if test -z "`${CC-cc} -fprofile-arcs -c conftest.c 2>&1`"; then
|
||||
ac_cv_prog_cc_profile_arcs=yes
|
||||
else
|
||||
ac_cv_prog_cc_profile_arcs=no
|
||||
fi
|
||||
rm -rf conftest*
|
||||
])
|
||||
AC_CACHE_CHECK([whether ${CC-cc} accepts -ftest_coverage], ac_cv_prog_cc_test_coverage, [
|
||||
echo 'void f(){}' > conftest.c
|
||||
if test -z "`${CC-cc} -ftest-coverage -c conftest.c 2>&1`"; then
|
||||
ac_cv_prog_cc_test_coverage=yes
|
||||
else
|
||||
ac_cv_prog_cc_test_coverage=no
|
||||
fi
|
||||
rm -rf conftest*
|
||||
])
|
||||
])
|
||||
|
||||
AC_DEFUN([COMPILER_FLAGS], [
|
||||
if (test "${CFLAGS}" = ""); then
|
||||
CFLAGS="-Wall -fsigned-char -fno-exceptions"
|
||||
|
23
configure.ac
23
configure.ac
@ -25,6 +25,7 @@ AC_PROG_CC_PIE
|
||||
AC_PROG_CC_ASAN
|
||||
AC_PROG_CC_LSAN
|
||||
AC_PROG_CC_UBSAN
|
||||
AC_PROG_CC_GCOV
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_MKDIR_P
|
||||
AC_PROG_LN_S
|
||||
@ -54,6 +55,28 @@ AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug],
|
||||
fi
|
||||
])
|
||||
|
||||
AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],
|
||||
[enable compiling with code coverage information]), [
|
||||
if (test "${enableval}" = "yes" &&
|
||||
test "${ac_cv_prog_cc_profile_arcs}" = "yes" &&
|
||||
test "${ac_cv_prog_cc_test_coverage}" = "yes"); then
|
||||
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
|
||||
fi
|
||||
])
|
||||
|
||||
if (test "${enable_gcov}" = "yes"); then
|
||||
AC_CHECK_PROGS(LCOV, [lcov], "no")
|
||||
AC_CHECK_PROGS(GENHTML, [genhtml], "no")
|
||||
if (test "${LCOV}" == "no"); then
|
||||
AC_MSG_ERROR([lcov is required])
|
||||
fi
|
||||
if (test "${GENHTML}" == "no"); then
|
||||
AC_MSG_ERROR([genhtml is required])
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(GCOV, test "${enable_gcov}" != "no")
|
||||
|
||||
AC_ARG_ENABLE(pie, AS_HELP_STRING([--enable-pie],
|
||||
[enable position independent executables flag]), [
|
||||
if (test "${enableval}" = "yes" &&
|
||||
|
Loading…
Reference in New Issue
Block a user