Loading Makefile.am +20 −0 Original line number Diff line number Diff line Loading @@ -35,8 +35,10 @@ EXTRA_DIST+= \ if COVERAGE_ENABLED TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE else TEST_CFLAGS= TEST_CPPFLAGS=-DTOR_UNIT_TESTS endif #install-data-local: Loading Loading @@ -80,6 +82,13 @@ test-stem: $(TESTING_TOR_BINARY) echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \ fi test-stem-full: $(TESTING_TOR_BINARY) @if test -d "$$STEM_SOURCE_DIR"; then \ "$$STEM_SOURCE_DIR"/run_tests.py --tor $(TESTING_TOR_BINARY) --all --log notice --target RUN_ALL,ONLINE -v; \ else \ echo '$$STEM_SOURCE_DIR was not set.'; echo; \ echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \ fi reset-gcov: rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda Loading @@ -99,6 +108,17 @@ else @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n" endif coverage-html-full: all test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false) test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)" lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters $(MAKE) reset-gcov $(MAKE) check $(MAKE) test-stem-full lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp" lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info" genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info" # Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c, # eventdns.[hc], tinytest*.[ch] check-spaces: Loading changes/coverage 0 → 100644 +6 −0 Original line number Diff line number Diff line o Minor features: - Remove assertions during builds to determine Tor's test coverage. We don't want to trigger these even in assertions, so including them artificially makes our branch coverage look worse than it is. This patch provides the new test-stem-full and coverage-html-full configure options. Implements ticket 15400. src/common/include.am +3 −3 Original line number Diff line number Diff line Loading @@ -96,9 +96,9 @@ src_common_libor_testing_a_SOURCES = $(LIBOR_A_SOURCES) src_common_libor_crypto_testing_a_SOURCES = $(LIBOR_CRYPTO_A_SOURCES) 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_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_common_libor_crypto_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_common_libor_event_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_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) Loading src/common/util.h +8 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,13 @@ #error "Sorry; we don't support building with NDEBUG." #endif /* Don't use assertions during coverage. It leads to tons of unreached * branches which in reality are only assertions we didn't hit. */ #ifdef TOR_COVERAGE #define tor_assert(a) STMT_BEGIN \ (void)(a); \ STMT_END #else /** Like assert(3), but send assertion failures to the log as well as to * stderr. */ #define tor_assert(expr) STMT_BEGIN \ Loading @@ -52,6 +59,7 @@ tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr); \ abort(); \ } STMT_END #endif void tor_assertion_failed_(const char *fname, unsigned int line, const char *func, const char *expr); Loading src/or/include.am +2 −2 Original line number Diff line number Diff line Loading @@ -99,7 +99,7 @@ AM_CPPFLAGS += -DSHARE_DATADIR="\"$(datadir)\"" \ -DLOCALSTATEDIR="\"$(localstatedir)\"" \ -DBINDIR="\"$(bindir)\"" src_or_libtor_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS) src_or_libtor_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_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. Loading @@ -116,7 +116,7 @@ src_or_tor_LDADD = src/or/libtor.a src/common/libor.a \ 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_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_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 \ Loading Loading
Makefile.am +20 −0 Original line number Diff line number Diff line Loading @@ -35,8 +35,10 @@ EXTRA_DIST+= \ if COVERAGE_ENABLED TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE else TEST_CFLAGS= TEST_CPPFLAGS=-DTOR_UNIT_TESTS endif #install-data-local: Loading Loading @@ -80,6 +82,13 @@ test-stem: $(TESTING_TOR_BINARY) echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \ fi test-stem-full: $(TESTING_TOR_BINARY) @if test -d "$$STEM_SOURCE_DIR"; then \ "$$STEM_SOURCE_DIR"/run_tests.py --tor $(TESTING_TOR_BINARY) --all --log notice --target RUN_ALL,ONLINE -v; \ else \ echo '$$STEM_SOURCE_DIR was not set.'; echo; \ echo "To run these tests, git clone https://git.torproject.org/stem.git/ ; export STEM_SOURCE_DIR=\`pwd\`/stem"; \ fi reset-gcov: rm -f $(top_builddir)/src/*/*.gcda $(top_builddir)/src/*/*/*.gcda Loading @@ -99,6 +108,17 @@ else @printf "Not configured with --enable-coverage, run ./configure --enable-coverage\n" endif coverage-html-full: all test -e "`which lcov`" || (echo "lcov must be installed. See <http://ltp.sourceforge.net/coverage/lcov.php>." && false) test -d "$(HTML_COVER_DIR)" || mkdir -p "$(HTML_COVER_DIR)" lcov --rc lcov_branch_coverage=1 --directory ./src --zerocounters $(MAKE) reset-gcov $(MAKE) check $(MAKE) test-stem-full lcov --capture --rc lcov_branch_coverage=1 --no-external --directory . --output-file "$(HTML_COVER_DIR)/lcov.tmp" lcov --remove "$(HTML_COVER_DIR)/lcov.tmp" --rc lcov_branch_coverage=1 'test/*' 'ext/tinytest*' '/usr/*' --output-file "$(HTML_COVER_DIR)/lcov.info" genhtml --branch-coverage -o "$(HTML_COVER_DIR)" "$(HTML_COVER_DIR)/lcov.info" # Avoid strlcpy.c, strlcat.c, aes.c, OpenBSD_malloc_Linux.c, sha256.c, # eventdns.[hc], tinytest*.[ch] check-spaces: Loading
changes/coverage 0 → 100644 +6 −0 Original line number Diff line number Diff line o Minor features: - Remove assertions during builds to determine Tor's test coverage. We don't want to trigger these even in assertions, so including them artificially makes our branch coverage look worse than it is. This patch provides the new test-stem-full and coverage-html-full configure options. Implements ticket 15400.
src/common/include.am +3 −3 Original line number Diff line number Diff line Loading @@ -96,9 +96,9 @@ src_common_libor_testing_a_SOURCES = $(LIBOR_A_SOURCES) src_common_libor_crypto_testing_a_SOURCES = $(LIBOR_CRYPTO_A_SOURCES) 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_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_common_libor_crypto_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_CPPFLAGS) src_common_libor_event_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_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) Loading
src/common/util.h +8 −0 Original line number Diff line number Diff line Loading @@ -45,6 +45,13 @@ #error "Sorry; we don't support building with NDEBUG." #endif /* Don't use assertions during coverage. It leads to tons of unreached * branches which in reality are only assertions we didn't hit. */ #ifdef TOR_COVERAGE #define tor_assert(a) STMT_BEGIN \ (void)(a); \ STMT_END #else /** Like assert(3), but send assertion failures to the log as well as to * stderr. */ #define tor_assert(expr) STMT_BEGIN \ Loading @@ -52,6 +59,7 @@ tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr); \ abort(); \ } STMT_END #endif void tor_assertion_failed_(const char *fname, unsigned int line, const char *func, const char *expr); Loading
src/or/include.am +2 −2 Original line number Diff line number Diff line Loading @@ -99,7 +99,7 @@ AM_CPPFLAGS += -DSHARE_DATADIR="\"$(datadir)\"" \ -DLOCALSTATEDIR="\"$(localstatedir)\"" \ -DBINDIR="\"$(bindir)\"" src_or_libtor_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS $(AM_CPPFLAGS) src_or_libtor_testing_a_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_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. Loading @@ -116,7 +116,7 @@ src_or_tor_LDADD = src/or/libtor.a src/common/libor.a \ 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_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_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 \ Loading