Skip to content

Commit

Permalink
Merge 6d9e477 into 29955f1
Browse files Browse the repository at this point in the history
  • Loading branch information
nmathewson committed May 24, 2019
2 parents 29955f1 + 6d9e477 commit 5ac7632
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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.
3 changes: 3 additions & 0 deletions scripts/test/cov-test-determinism.sh
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/lib/log/log.h
Expand Up @@ -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.
Expand All @@ -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, ...)
Expand Down
21 changes: 21 additions & 0 deletions src/lib/wallclock/timeval.h
Expand Up @@ -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. */
Expand Down
7 changes: 7 additions & 0 deletions src/test/include.am
Expand Up @@ -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 \
Expand Down

0 comments on commit 5ac7632

Please sign in to comment.