WIP FPC-III support
[linux/fpc-iii.git] / tools / testing / selftests / bpf / urandom_read.c
blobdb781052758d3774b42cb891b86b09320e3d95d5
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 static __attribute__((noinline))
11 void urandom_read(int fd, int count)
13 char buf[BUF_SIZE];
14 int i;
16 for (i = 0; i < count; ++i)
17 read(fd, buf, BUF_SIZE);
20 int main(int argc, char *argv[])
22 int fd = open("/dev/urandom", O_RDONLY);
23 int count = 4;
25 if (fd < 0)
26 return 1;
28 if (argc == 2)
29 count = atoi(argv[1]);
31 urandom_read(fd, count);
33 close(fd);
34 return 0;