File: ax_code_coverage.texi

package info (click to toggle)
autoconf-archive 20160916-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 7,960 kB
  • sloc: sh: 694; python: 62; makefile: 49
file content (84 lines) | stat: -rw-r--r-- 3,312 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
@node ax_code_coverage
@unnumberedsec ax_code_coverage

@majorheading Synopsis

@smallexample
AX_CODE_COVERAGE()
@end smallexample

@majorheading Description

Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included
in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every
build target (program or library) which should be built with code
coverage support. Also defines CODE_COVERAGE_RULES which should be
substituted in your Makefile; and $enable_code_coverage which can be
used in subsequent configure output. CODE_COVERAGE_ENABLED is defined
and substituted, and corresponds to the value of the
--enable-code-coverage option, which defaults to being disabled.

Test also for gcov program and create GCOV variable that could be
substituted.

Note that all optimisation flags in CFLAGS must be disabled when code
coverage is enabled.

Usage example:

configure.ac:

@smallexample
  AX_CODE_COVERAGE
@end smallexample

Makefile.am:

@smallexample
  @@CODE_COVERAGE_RULES@@
  my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ...
  my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
  my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
  my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
@end smallexample

This results in a "check-code-coverage" rule being added to any
Makefile.am which includes "@@CODE_COVERAGE_RULES@@" (assuming the module
has been configured with --enable-code-coverage). Running `make
check-code-coverage` in that directory will run the module's test suite
(`make check`) and build a code coverage report detailing the code which
was touched, then print the URI for the report.

In earlier versions of this macro, CODE_COVERAGE_LDFLAGS was defined
instead of CODE_COVERAGE_LIBS. They are both still defined, but use of
CODE_COVERAGE_LIBS is preferred for clarity; CODE_COVERAGE_LDFLAGS is
deprecated. They have the same value.

This code was derived from Makefile.decl in GLib, originally licenced
under LGPLv2.1+.

@majorheading Source Code

Download the
@uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_code_coverage.m4,latest
version of @file{ax_code_coverage.m4}} or browse
@uref{http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=history;f=m4/ax_code_coverage.m4,the
macro's revision history}.

@majorheading License

@w{Copyright @copyright{} 2012, 2016 Philip Withnall} @* @w{Copyright @copyright{} 2012 Xan Lopez} @* @w{Copyright @copyright{} 2012 Christian Persch} @* @w{Copyright @copyright{} 2012 Paolo Borelli} @* @w{Copyright @copyright{} 2012 Dan Winship} @* @w{Copyright @copyright{} 2015 Bastien ROUCARIES}

This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at
your option) any later version.

This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.