getentropy tests: Update after commit 473681a1a506da

- Use GETENTROPY_MAX instead of hard-coding the value.
- Check for EINVAL instead of EIO

Fixes:	473681a1a506 ("libc: Fix getentropy POSIX 2024 conformance issues")
(cherry picked from commit c5056a3931b41a803a24b89400d38d5c5f843612)
This commit is contained in:
Mark Johnston 2025-01-19 16:17:05 +00:00 committed by Enji Cooper
parent 8d95e941d4
commit bcd9c0cfb6

View file

@ -28,6 +28,7 @@
#include <sys/param.h>
#include <errno.h>
#include <limits.h>
#include <signal.h>
#include <unistd.h>
@ -62,13 +63,13 @@ ATF_TC_BODY(getentropy_sizes, tc)
char buf[512];
ATF_REQUIRE_EQ(getentropy(buf, sizeof(buf)), -1);
ATF_REQUIRE_EQ(errno, EIO);
ATF_REQUIRE_EQ(getentropy(buf, 257), -1);
ATF_REQUIRE_EQ(errno, EIO);
ATF_REQUIRE_EQ(errno, EINVAL);
ATF_REQUIRE_EQ(getentropy(buf, GETENTROPY_MAX + 1), -1);
ATF_REQUIRE_EQ(errno, EINVAL);
/* Smaller sizes always succeed: */
ATF_REQUIRE_EQ(getentropy(buf, 256), 0);
ATF_REQUIRE_EQ(getentropy(buf, 128), 0);
ATF_REQUIRE_EQ(getentropy(buf, GETENTROPY_MAX), 0);
ATF_REQUIRE_EQ(getentropy(buf, GETENTROPY_MAX / 2), 0);
ATF_REQUIRE_EQ(getentropy(buf, 0), 0);
}