summaryrefslogtreecommitdiffstats
path: root/test/testutil/driver.c
diff options
context:
space:
mode:
authorPauli <paul.dale@oracle.com>2019-07-26 12:56:01 +1000
committerPauli <paul.dale@oracle.com>2019-07-29 09:16:22 +1000
commit7de305510a07729be3cc80a0fb10561732ee4f31 (patch)
tree46f0bd26df9ee8468d6cb7669f6e71cecd088074 /test/testutil/driver.c
parente4a282fe030363a87d52d4a3214eb7490036015e (diff)
Add weak platform independent PRNG to test framework.
Implement the GNU C library's random(3) pseudorandom number generator. The algorithm is described: https://www.mscs.dal.ca/~selinger/random/ The rationale is to make the tests repeatable across differing platforms with different underlying implementations of the random(3) library call. More specifically: when executing tests with random ordering. [extended tests] Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de> (Merged from https://github.com/openssl/openssl/pull/9463) (cherry picked from commit e9a5932d04f6b7dd25b39a8ff9dc162d64a78c22)
Diffstat (limited to 'test/testutil/driver.c')
-rw-r--r--test/testutil/driver.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/testutil/driver.c b/test/testutil/driver.c
index 6e9914c48d..48f94aea1e 100644
--- a/test/testutil/driver.c
+++ b/test/testutil/driver.c
@@ -112,7 +112,7 @@ void setup_test_framework()
seed = (int)time(NULL);
test_printf_stdout("%*s# RAND SEED %d\n", subtest_level(), "", seed);
test_flush_stdout();
- srand(seed);
+ test_random_seed(seed);
}
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
@@ -190,7 +190,7 @@ int run_tests(const char *test_prog_name)
permute[i] = i;
if (seed != 0)
for (i = num_tests - 1; i >= 1; i--) {
- j = rand() % (1 + i);
+ j = test_random() % (1 + i);
ii = permute[j];
permute[j] = permute[i];
permute[i] = ii;
@@ -228,7 +228,7 @@ int run_tests(const char *test_prog_name)
jstep = 1;
else
do
- jstep = rand() % all_tests[i].num;
+ jstep = test_random() % all_tests[i].num;
while (jstep == 0 || gcd(all_tests[i].num, jstep) != 1);
for (jj = 0; jj < all_tests[i].num; jj++) {