mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
Test getentropy
We want to ensure that tools that call getentropy() are also controlled appropriately.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
14
test/getentropy_test.c
Normal file
14
test/getentropy_test.c
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user