strace/tests/getrandom.c
Dmitry V. Levin fef09070d6 Implement getrandom syscall decoding
* getrandom.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/dummy.h (sys_getrandom): Remove.
* linux/syscall.h (sys_getrandom): New prototype.
* xlat/getrandom_flags.in: New file.
* tests/getrandom.c: New file.
* tests/getrandom.awk: New file.
* tests/getrandom.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add getrandom.
(TESTS): Add getrandom.test.
(EXTRA_DIST): Add getrandom.awk.
* tests/.gitignore: Add getrandom.
2015-02-05 01:10:47 +00:00

22 lines
380 B
C

#include <unistd.h>
#include <sys/syscall.h>
int
main(void)
{
#ifdef __NR_getrandom
char buf[4];
if (syscall(__NR_getrandom, buf, sizeof(buf) - 1, 0) != sizeof(buf) - 1)
return 77;
if (syscall(__NR_getrandom, buf, sizeof(buf), 1) != sizeof(buf))
return 77;
if (syscall(__NR_getrandom, buf, sizeof(buf), 0x3003) != -1)
return 77;
return 0;
#else
return 77;
#endif
}