From 2e613fae7c30f3dfccd291fd9aad7bdddcb08f86 Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Thu, 30 Apr 2020 14:56:21 +0200 Subject: [PATCH] meson: add test_coverage build option MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Hrdina Reviewed-by: Ján Tomko Reviewed-by: Peter Krempa Reviewed-by: Neal Gompa --- configure.ac | 21 --------------------- meson.build | 16 ++++++++++++++++ meson_options.txt | 1 + 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index f7e665bd45..d5b3a653dc 100644 --- a/configure.ac +++ b/configure.ac @@ -614,23 +614,6 @@ if test -z "$PERL"; then AC_MSG_ERROR(['perl' binary is required to build libvirt]) fi -LIBVIRT_ARG_ENABLE([TEST_COVERAGE], [turn on code coverage instrumentation], [no]) -case "$enable_test_coverage" in - yes|no) ;; - *) AC_MSG_ERROR([bad value ${enable_test_coverga} for test-coverage option]) ;; -esac - -if test "$enable_test_coverage" = yes; then - save_WARN_CFLAGS=$WARN_CFLAGS - WARN_CFLAGS= - gl_WARN_ADD([-fprofile-arcs]) - gl_WARN_ADD([-ftest-coverage]) - COVERAGE_FLAGS=$WARN_CFLAGS - AC_SUBST([COVERAGE_CFLAGS], [$COVERAGE_FLAGS]) - AC_SUBST([COVERAGE_LDFLAGS], [$COVERAGE_FLAGS]) - WARN_CFLAGS=$save_WARN_CFLAGS -fi - dnl MinGW checks LIBVIRT_WIN_CHECK_COMMON LIBVIRT_WIN_CHECK_MINGW @@ -876,10 +859,6 @@ AC_MSG_NOTICE([]) LIBVIRT_WIN_RESULT_COMMON LIBVIRT_WIN_RESULT_WINDRES AC_MSG_NOTICE([]) -AC_MSG_NOTICE([Test suite]) -AC_MSG_NOTICE([]) -LIBVIRT_RESULT([Coverage], [$enable_test_coverage]) -AC_MSG_NOTICE([]) AC_MSG_NOTICE([Miscellaneous]) AC_MSG_NOTICE([]) LIBVIRT_RESULT([Use -Werror], [$enable_werror]) diff --git a/meson.build b/meson.build index f9173b1acd..ff4fcd3166 100644 --- a/meson.build +++ b/meson.build @@ -137,6 +137,14 @@ else use_expensive_tests = get_option('expensive_tests').enabled() endif +coverage_flags = [] +if get_option('test_coverage') + coverage_flags = [ + '-fprofile-arcs', + '-ftest-coverage', + ] +endif + # figure out libvirt version strings @@ -190,3 +198,11 @@ top_inc_dir = include_directories('.') # generate meson-config.h file configure_file(output: 'meson-config.h', configuration: conf) + + +# print configuration summary + +test_summary = { + 'Coverage': coverage_flags.length() > 0, +} +summary(test_summary, section: 'Test suite', bool_yn: true) diff --git a/meson_options.txt b/meson_options.txt index 390c7d33fa..7171d4c17b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -5,3 +5,4 @@ option('packager_version', type: 'string', value: '', description: 'Extra packag option('system', type: 'boolean', value: false, description: 'Set install paths to system ones') option('runstatedir', type: 'string', value: '', description: 'State directory for temporary sockets, pid files, etc') option('expensive_tests', type: 'feature', value: 'auto', description: 'set the default for enabling expensive tests (long timeouts), use VIR_TEST_EXPENSIVE to override') +option('test_coverage', type: 'boolean', value: false, description: 'turn on code coverage instrumentation')