diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-05-14 19:49:50 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-05-15 07:50:56 -0400 |
commit | 261d43cdd5f9dbd9b67303f8c8042a38a37995ca (patch) | |
tree | de33d88705aebb2f30239c8fc326a031f4709833 /src/test/rng_test_helpers.c | |
parent | e4feb4ad01e7f3de592adbecd7f1ffae040f51ed (diff) | |
download | tor-261d43cdd5f9dbd9b67303f8c8042a38a37995ca.tar.gz tor-261d43cdd5f9dbd9b67303f8c8042a38a37995ca.zip |
Make testing_disable_reproducible_rng() log seed on test failure
This should let us simplify test_prob_distr.c and other stuff in the
future.
Diffstat (limited to 'src/test/rng_test_helpers.c')
-rw-r--r-- | src/test/rng_test_helpers.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/test/rng_test_helpers.c b/src/test/rng_test_helpers.c index 262d380bda..c4243f5e9a 100644 --- a/src/test/rng_test_helpers.c +++ b/src/test/rng_test_helpers.c @@ -17,6 +17,7 @@ #include "core/or/or.h" #include "lib/crypt_ops/crypto_rand.h" +#include "ext/tinytest.h" #include "test/rng_test_helpers.h" @@ -54,7 +55,8 @@ static uint8_t rng_seed[16]; static crypto_xof_t *rng_xof = NULL; /** - * Print the seed for our PRNG to stdout. We use this when we're + * Print the seed for our PRNG to stdout. We use this when we're failed + * test that had a reproducible RNG set. **/ void testing_dump_reproducible_rng_seed(void) @@ -224,3 +226,16 @@ testing_disable_rng_override(void) rng_is_replaced = false; } + +/** + * As testing_disable_rng_override(), but dump the seed if the current + * test has failed. + */ +void +testing_disable_reproducible_rng(void) +{ + if (tinytest_cur_test_has_failed()) { + testing_dump_reproducible_rng_seed(); + } + testing_disable_rng_override(); +} |