Force ztest to always use /dev/urandom

For ztest, which is solely for testing, using a pseudo random
is entirely reasonable.  Using /dev/urandom ensures the system
entropy pool doesn't get depleted thus stalling the testing.
This is a particular problem when testing in VMs.

Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed by: Thomas Caputi <tcaputi@datto.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7017 
Closes #7036
This commit is contained in:
Brian Behlendorf
2018-01-12 09:36:26 -08:00
committed by GitHub
parent 6df9f8ebd7
commit e1a0850c35
5 changed files with 12 additions and 16 deletions
+6 -1
View File
@@ -7064,7 +7064,12 @@ main(int argc, char **argv)
exit(EXIT_FAILURE);
}
ztest_fd_rand = open("/dev/urandom", O_RDONLY);
/*
* Force random_get_bytes() to use /dev/urandom in order to prevent
* ztest from needlessly depleting the system entropy pool.
*/
random_path = "/dev/urandom";
ztest_fd_rand = open(random_path, O_RDONLY);
ASSERT3S(ztest_fd_rand, >=, 0);
if (!fd_data_str) {