diff --git a/.gitignore b/.gitignore index 14c308f..6a63c72 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ test/lib*.so test/use_lib_random test/use_lib_getpid test/repeat_random +test/getentropy_test src/libfaketime.dylib.1 src/libfaketime.1.dylib diff --git a/test/Makefile b/test/Makefile index 8959b71..47da88f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -25,7 +25,7 @@ functest: %_test: %_test.c ${CC} -o $@ ${CFLAGS} $< -randomtest: getrandom_test use_lib_random librandom.so repeat_random +randomtest: getrandom_test use_lib_random librandom.so repeat_random getentropy_test ./randomtest.sh getpidtest: use_lib_getpid libgetpid.so diff --git a/test/getentropy_test.c b/test/getentropy_test.c new file mode 100644 index 0000000..a3d02e6 --- /dev/null +++ b/test/getentropy_test.c @@ -0,0 +1,14 @@ +#include +#include + +int main() { + unsigned char buf[16]; + if (getentropy(buf, sizeof(buf))) { + perror("failed to getentropy()"); + return 1; + } + for (size_t i = 0; i < sizeof(buf); i++) + printf("%02x", buf[i]); + printf("\n"); + return 0; +} diff --git a/test/randomtest.sh b/test/randomtest.sh index 6f8d124..4055188 100755 --- a/test/randomtest.sh +++ b/test/randomtest.sh @@ -6,7 +6,7 @@ set -e error=0 -for iface in getrandom; do +for iface in getrandom getentropy; do printf "Testing %s() interception...\n" "$iface" "./${iface}_test" > "${iface}.alone"