mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
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.
This commit is contained in:
parent
e4feb4ad01
commit
261d43cdd5
@ -17,6 +17,7 @@
|
|||||||
#include "core/or/or.h"
|
#include "core/or/or.h"
|
||||||
|
|
||||||
#include "lib/crypt_ops/crypto_rand.h"
|
#include "lib/crypt_ops/crypto_rand.h"
|
||||||
|
#include "ext/tinytest.h"
|
||||||
|
|
||||||
#include "test/rng_test_helpers.h"
|
#include "test/rng_test_helpers.h"
|
||||||
|
|
||||||
@ -54,7 +55,8 @@ static uint8_t rng_seed[16];
|
|||||||
static crypto_xof_t *rng_xof = NULL;
|
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
|
void
|
||||||
testing_dump_reproducible_rng_seed(void)
|
testing_dump_reproducible_rng_seed(void)
|
||||||
@ -224,3 +226,16 @@ testing_disable_rng_override(void)
|
|||||||
|
|
||||||
rng_is_replaced = false;
|
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();
|
||||||
|
}
|
||||||
|
@ -14,8 +14,7 @@ void testing_prefilled_rng_reset(void);
|
|||||||
|
|
||||||
void testing_disable_rng_override(void);
|
void testing_disable_rng_override(void);
|
||||||
|
|
||||||
#define testing_disable_reproducible_rng() \
|
void testing_disable_reproducible_rng(void);
|
||||||
testing_disable_rng_override()
|
|
||||||
#define testing_disable_deterministic_rng() \
|
#define testing_disable_deterministic_rng() \
|
||||||
testing_disable_rng_override()
|
testing_disable_rng_override()
|
||||||
#define testing_disable_prefilled_rng() \
|
#define testing_disable_prefilled_rng() \
|
||||||
|
Loading…
Reference in New Issue
Block a user