-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.am.coverage
72 lines (60 loc) · 2.87 KB
/
Makefile.am.coverage
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
# Build rules for measuring coverage
COVERAGE_INFO_FILE = $(top_builddir)/coverage.info
COVERAGE_REPORT_DIR = $(top_builddir)/coverage
.PHONY: coverage-requirement-check \
coverage coverage-build coverage-check coverage-report \
clean-coverage-report clean-coverage clean-coverage-hook-for-clean-local
coverage-requirement-check:
@if test "x$(ENABLE_COVERAGE)" = "xno"; then \
echo "Coverage feature is disabled. Please execute configure with --enable-gcov option."; \
exit 1; \
fi
coverage: coverage-requirement-check clean-coverage coverage-build coverage-check coverage-report
coverage-build: coverage-requirement-check
@if test `find $(top_builddir) -name "*.gcno" | wc -l` -eq 0 -a \
`find $(top_builddir) -name "*.bb" -o -name "*.bbg" | wc -l` -eq 0; then \
echo "Starting to remove old non-instrumented object files..."; \
$(MAKE) $(AM_MAKEFLAGS) clean; \
echo "Successfully removed old non-instrumented object files."; \
fi
@echo "Starting to build libraries with coverage options..."
$(MAKE) $(AM_MAKEFLAGS) \
CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) $(COVERAGE_OPTIMIZATION_FLAGS)" \
CXXFLAGS="$(CXXFLAGS) $(COVERAGE_CXXFLAGS) $(COVERAGE_OPTIMIZATION_FLAGS)" \
LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS)"
@echo "Successfully built libraries with coverage options."
coverage-check: coverage-requirement-check
@echo "Starting to run tests with instrumented libraries..."
$(MAKE) $(AM_MAKEFLAGS) check \
CFLAGS="$(CFLAGS) $(COVERAGE_CFLAGS) $(COVERAGE_OPTIMIZATION_FLAGS)" \
CXXFLAGS="$(CXXFLAGS) $(COVERAGE_CXXFLAGS) $(COVERAGE_OPTIMIZATION_FLAGS)" \
LDFLAGS="$(LDFLAGS) $(COVERAGE_LDFLAGS)"
@echo "Successfully run tests with instrumented libraries."
# TODO(Eiichiro Iwata): Remove GNU make extension(abspath function)
# Automake treat GNU make extension as warning
# when using -Wall or -Wportability in AM_INIT_AUTOMAKE.
coverage-report: coverage-requirement-check
@echo "Starting to create coverage reports..."
$(LCOV) --capture \
--directory "$(top_builddir)/src" \
--base-directory "$(abspath $(top_builddir))/src" \
--output-file $(COVERAGE_INFO_FILE) \
--compat-libtool --checksum
$(LCOV) --extract $(COVERAGE_INFO_FILE) "$(abspath $(top_srcdir))/src/*" \
--output-file $(COVERAGE_INFO_FILE)
$(GENHTML) --prefix "$(abspath $(top_srcdir))" \
--output-directory $(COVERAGE_REPORT_DIR) \
--title autotools-unittest \
--legend --show-details \
$(GENHTML_OPTIONS) \
$(COVERAGE_INFO_FILE)
@echo "Successfully created coverage reports into $(COVERAGE_REPORT_DIR) directory."
clean-coverage-report:
-rm -rf $(COVERAGE_INFO_FILE)
-rm -rf $(COVERAGE_REPORT_DIR)
clean-coverage: clean-coverage-report
-$(LCOV) --zerocounters --directory $(top_builddir)
clean-coverage-hook-for-clean-local:
-find $(top_builddir) -name "*.gcno" -print | xargs -r rm
mostlyclean-local: clean-coverage
clean-local: clean-coverage-hook-for-clean-local