summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2020-05-31 23:29:21 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2020-05-31 23:30:39 -0700
commite3c038e4c08d68cc3ca03cf0c3dc09c3182e216a (patch)
treebc3b8caf3e94dfc25d83fc0b9215ae9785b628e8 /tests
parent8f8da7c809b6908d074ac64c91d0cedfd4236f2e (diff)
downloadgnulib-e3c038e4c08d68cc3ca03cf0c3dc09c3182e216a.tar.gz
getrandom-tests: do not assume GRND_RANDOM yields short read
* tests/test-getrandom.c (main): Omit assertion that getrandom (b, sizeof b, GRND_RANDOM | GRND_NONBLOCK) < sizeof b when b’s size is 100000. This assertion fails with Linux kernel 5.6.13, as that kernel ignores the GRND_RANDOM flag. The separate blocking pool is going away in the Linux kernel, and they’ve added a flag GRND_INSECURE instead; see: https://lore.kernel.org/linux-api/705c5a091b63cc5da70c99304bb97e0109be0a26.1577088521.git.luto@kernel.org/ The assertion was iffy anyway; what’s to prevent a kernel from lazily filling a large buffer with random bytes?
Diffstat (limited to 'tests')
-rw-r--r--tests/test-getrandom.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/tests/test-getrandom.c b/tests/test-getrandom.c
index f4a31c62d8..0e9fbb0c26 100644
--- a/tests/test-getrandom.c
+++ b/tests/test-getrandom.c
@@ -79,24 +79,7 @@ main (void)
ASSERT (errno == ENOSYS || errno == EAGAIN
|| errno == EINVAL /* Solaris */);
else
- {
- ASSERT (ret > 0);
- /* This assertion fails on
- - GNU/Hurd,
- - Mac OS X,
- - GNU/kFreeBSD, FreeBSD 12.0,
- - OpenBSD 6.5,
- - Minix 3.3,
- - AIX 7.1,
- - Haiku,
- - native Windows.
- This indicates that the function, when called with GRND_RANDOM flag,
- probably does not return truly random numbers, but instead uses a
- pseudo-random number generator. */
-#if !(defined __GNU__ || (defined __APPLE__ && defined __MACH__) || defined __FreeBSD_kernel__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __minix || defined _AIX || defined __HAIKU__ || (defined _WIN32 && ! defined __CYGWIN__))
- ASSERT (ret < (ssize_t) sizeof (large_buf));
-#endif
- }
+ ASSERT (ret > 0);
if (getrandom (buf1, 1, 0) < 1)
if (getrandom (buf1, 1, GRND_RANDOM) < 1)