mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
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.
This commit is contained in:
@@ -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 \
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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 = \
|
||||
|
||||
Reference in New Issue
Block a user