aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/urandom_read.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2018-05-07 10:50:49 -0700
committerDaniel Borkmann <daniel@iogearbox.net>2018-05-14 23:29:45 +0200
commit13790d1cc72c22f6e7a1248e5f6d20d720797e95 (patch)
tree96449dabaf9685b7cb23b07ecb0ace00b06dd251 /tools/testing/selftests/bpf/urandom_read.c
parentbpf: enable stackmap with build_id in nmi context (diff)
downloadlinux-dev-13790d1cc72c22f6e7a1248e5f6d20d720797e95.tar.xz
linux-dev-13790d1cc72c22f6e7a1248e5f6d20d720797e95.zip
bpf: add selftest for stackmap with build_id in NMI context
This new test captures stackmap with build_id with hardware event PERF_COUNT_HW_CPU_CYCLES. Because we only support one ips-to-build_id lookup per cpu in NMI context, stack_amap will not be able to do the lookup in this test. Therefore, we didn't do compare_stack_ips(), as it will alwasy fail. urandom_read.c is extended to run configurable cycles so that it can be caught by the perf event. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to '')
-rw-r--r--tools/testing/selftests/bpf/urandom_read.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/testing/selftests/bpf/urandom_read.c b/tools/testing/selftests/bpf/urandom_read.c
index 4acfdebf36fa..9de8b7cb4e6d 100644
--- a/tools/testing/selftests/bpf/urandom_read.c
+++ b/tools/testing/selftests/bpf/urandom_read.c
@@ -6,15 +6,21 @@
#include <stdlib.h>
#define BUF_SIZE 256
-int main(void)
+
+int main(int argc, char *argv[])
{
int fd = open("/dev/urandom", O_RDONLY);
int i;
char buf[BUF_SIZE];
+ int count = 4;
if (fd < 0)
return 1;
- for (i = 0; i < 4; ++i)
+
+ if (argc == 2)
+ count = atoi(argv[1]);
+
+ for (i = 0; i < count; ++i)
read(fd, buf, BUF_SIZE);
close(fd);