aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-07-09 12:37:11 -0400
committerNick Mathewson <nickm@torproject.org>2013-07-10 15:22:16 -0400
commit17e9fc09c31dffdc647385220a14daef5a35273a (patch)
tree66b1a0ccb2e176bc2646a25cdd03fd6eb0d90435 /src
parenta3e0a87d951b1323ca542c9b115d5525d0d022c9 (diff)
downloadtor-17e9fc09c31dffdc647385220a14daef5a35273a.tar
tor-17e9fc09c31dffdc647385220a14daef5a35273a.tar.gz
Coverage support: build with --enable-coverage to have tests run with gcov
If you pass the --enable-coverage flag on the command line, we build our testing binaries with appropriate options eo enable coverage testing. We also build a "tor-cov" binary that has coverage enabled, for integration tests. On recent OSX versions, test coverage only works with clang, not gcc. So we warn about that. Also add a contrib/coverage script to actually run gcov with the appropriate options to generate useful .gcov files. (Thanks to automake, the .o files will not have the names that gcov expects to find.) Also, remove generated gcda and gcno files on clean.
Diffstat (limited to 'src')
-rw-r--r--src/common/include.am4
-rw-r--r--src/or/include.am16
-rw-r--r--src/test/include.am2
3 files changed, 22 insertions, 0 deletions
diff --git a/src/common/include.am b/src/common/include.am
index 3d8cc8e9e..3f5a0e0d0 100644
--- a/src/common/include.am
+++ b/src/common/include.am
@@ -82,6 +82,10 @@ src_common_libor_event_testing_a_SOURCES = $(LIBOR_EVENT_A_SOURCES)
src_common_libor_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS)
src_common_libor_crypto_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS)
src_common_libor_event_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS)
+src_common_libor_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+src_common_libor_crypto_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+src_common_libor_event_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+
COMMONHEADERS = \
src/common/address.h \
diff --git a/src/or/include.am b/src/or/include.am
index 91b9bfce7..f5002e698 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -5,6 +5,9 @@ if UNITTESTS_ENABLED
noinst_LIBRARIES += \
src/or/libtor-testing.a
endif
+if COVERAGE_ENABLED
+noinst_PROGRAMS+= src/or/tor-cov
+endif
if BUILD_NT_SERVICES
tor_platform_source=src/or/ntmain.c
@@ -99,6 +102,7 @@ AM_CPPFLAGS += -DSHARE_DATADIR="\"$(datadir)\"" \
-DBINDIR="\"$(bindir)\""
src_or_libtor_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS)
+src_or_libtor_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
# -L flags need to go in LDFLAGS. -l flags need to go in LDADD.
# This seems to matter nowhere but on windows, but I assure you that it
@@ -112,6 +116,18 @@ src_or_tor_LDADD = src/or/libtor.a src/common/libor.a \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
@TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
+if COVERAGE_ENABLED
+src_or_tor_cov_SOURCES = src/or/tor_main.c
+src_or_tor_cov_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS)
+src_or_tor_cov_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+src_or_tor_cov_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ @TOR_LDFLAGS_libevent@
+src_or_tor_cov_LDADD = src/or/libtor-testing.a src/common/libor-testing.a \
+ src/common/libor-crypto-testing.a $(LIBDONNA) \
+ src/common/libor-event-testing.a \
+ @TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ @TOR_OPENSSL_LIBS@ \
+ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
+endif
+
ORHEADERS = \
src/or/addressmap.h \
src/or/buffers.h \
diff --git a/src/test/include.am b/src/test/include.am
index 08eb7fba6..989cf4ebf 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -31,6 +31,8 @@ src_test_test_SOURCES = \
src/test/test_config.c \
src/ext/tinytest.c
+src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+
src_test_test_CPPFLAGS= $(src_test_AM_CPPFLAGS)
src_test_bench_SOURCES = \