summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2019-01-17 16:24:08 -0500
committerNick Mathewson <nickm@torproject.org>2019-01-17 17:27:13 -0500
commit81f1b89efc94723f2c13b0b80d311364a2245d85 (patch)
tree83b2807a2caae978c0e74a69208712d14b34538f
parentc08fc2e19e7695c5d3fd111fb8c1a46afc23b5e8 (diff)
downloadtor-0.4.0.1-alpha.tar.gz
tor-0.4.0.1-alpha.zip
Better failure message on stochastic test failuretor-0.4.0.1-alpha
-rw-r--r--src/test/test_prob_distr.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/test/test_prob_distr.c b/src/test/test_prob_distr.c
index 114057feca..42cc6d70f6 100644
--- a/src/test/test_prob_distr.c
+++ b/src/test/test_prob_distr.c
@@ -1137,7 +1137,11 @@ teardown_deterministic_rand(void)
static void
dump_seed(void)
{
- printf("\nSeed: %s\n",
+ printf("\n"
+ "NOTE: This is a stochastic test, and we expect it to fail from\n"
+ "time to time, with some low probability. If you see it fail more\n"
+ "than one trial in 100, though, please tell us.\n\n"
+ "Seed: %s\n",
hex_str((const char*)rng_seed, sizeof(rng_seed)));
}
@@ -1190,7 +1194,7 @@ test_stochastic_uniform(void *arg)
.a = -4e-324,
.b = 4e-310,
};
- bool ok = true;
+ bool ok = true, tests_failed = true;
init_deterministic_rand();
MOCK(crypto_rand, crypto_rand_deterministic);
@@ -1204,8 +1208,14 @@ test_stochastic_uniform(void *arg)
tt_assert(ok);
+ tests_failed = false;
+
done:
- ;
+ if (tests_failed) {
+ dump_seed();
+ }
+ teardown_deterministic_rand();
+ UNMOCK(crypto_rand);
}
static bool