Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / bpf / urandom_read.c
blob9de8b7cb4e6df6b5929c915566dff74163efbcf2
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdlib.h>
8 #define BUF_SIZE 256
10 int main(int argc, char *argv[])
12 int fd = open("/dev/urandom", O_RDONLY);
13 int i;
14 char buf[BUF_SIZE];
15 int count = 4;
17 if (fd < 0)
18 return 1;
20 if (argc == 2)
21 count = atoi(argv[1]);
23 for (i = 0; i < count; ++i)
24 read(fd, buf, BUF_SIZE);
26 close(fd);
27 return 0;