tor

The Tor anonymity network
git clone https://git.dasho.dev/tor.git
Log | Files | Refs | README | LICENSE

commit ff9aa32143849c69097000290b939f14c9bbcb36
parent 0a86f14addd031ac69647f4ab6fc66c1835cd31e
Author: David Goulet <dgoulet@torproject.org>
Date:   Tue, 28 May 2019 14:59:07 -0400

Merge branch 'tor-github/pr/1047'

Diffstat:
Achanges/ticket30519 | 4++++
Mscripts/test/cov-test-determinism.sh | 3+++
Msrc/lib/log/log.h | 6++++++
Msrc/lib/wallclock/timeval.h | 21+++++++++++++++++++++
Msrc/test/include.am | 7+++++++
5 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/changes/ticket30519 b/changes/ticket30519 @@ -0,0 +1,4 @@ + o Minor features (testing): + - When running tests in coverage mode, take additional care to make + our coverage deterministic, so that we can accurately track changes in + code coverage. Closes ticket 30519. diff --git a/scripts/test/cov-test-determinism.sh b/scripts/test/cov-test-determinism.sh @@ -25,6 +25,9 @@ else fi if test "$run" = 1; then + # same seed as in travis.yml + TOR_TEST_RNG_SEED="636f766572616765" + export TOR_TEST_RNG_SEED while true; do make reset-gcov CD=coverage-raw/coverage-$(date +%s) diff --git a/src/lib/log/log.h b/src/lib/log/log.h @@ -194,6 +194,11 @@ void tor_log_get_logfile_names(struct smartlist_t *out); extern int log_global_min_severity_; +#ifdef TOR_COVERAGE +/* For coverage builds, we try to avoid our log_debug optimization, since it + * can have weird effects on internal macro coverage. */ +#define debug_logging_enabled() (1) +#else static inline bool debug_logging_enabled(void); /** * Return true iff debug logging is enabled for at least one domain. @@ -202,6 +207,7 @@ static inline bool debug_logging_enabled(void) { return PREDICT_UNLIKELY(log_global_min_severity_ == LOG_DEBUG); } +#endif void log_fn_(int severity, log_domain_mask_t domain, const char *funcname, const char *format, ...) diff --git a/src/lib/wallclock/timeval.h b/src/lib/wallclock/timeval.h @@ -20,6 +20,27 @@ #include <sys/time.h> #endif +#ifdef TOR_COVERAGE +/* For coverage builds, we use a slower definition of these macros without + * branches, to make coverage consistent. */ +#undef timeradd +#undef timersub +#define timeradd(tv1,tv2,tvout) \ + do { \ + (tvout)->tv_sec = (tv1)->tv_sec + (tv2)->tv_sec; \ + (tvout)->tv_usec = (tv1)->tv_usec + (tv2)->tv_usec; \ + (tvout)->tv_sec += (tvout)->tv_usec / 1000000; \ + (tvout)->tv_usec %= 1000000; \ + } while (0) +#define timersub(tv1,tv2,tvout) \ + do { \ + (tvout)->tv_sec = (tv1)->tv_sec - (tv2)->tv_sec - 1; \ + (tvout)->tv_usec = (tv1)->tv_usec - (tv2)->tv_usec + 1000000; \ + (tvout)->tv_sec += (tvout)->tv_usec / 1000000; \ + (tvout)->tv_usec %= 1000000; \ + } while (0) +#endif + #ifndef timeradd /** Replacement for timeradd on platforms that do not have it: sets tvout to * the sum of tv1 and tv2. */ diff --git a/src/test/include.am b/src/test/include.am @@ -32,8 +32,15 @@ endif if USEPYTHON TESTSCRIPTS += src/test/test_ntor.sh src/test/test_hs_ntor.sh src/test/test_bt.sh + +if COVERAGE_ENABLED +# ... +else +# Only do this when coverage is not on, since it invokes lots of code +# in a kind of unpredictable way. TESTSCRIPTS += src/test/test_rebind.sh endif +endif TESTS += src/test/test src/test/test-slow src/test/test-memwipe \ src/test/test_workqueue \