diff options
Diffstat (limited to 'tools/perf/tests/bpf.c')
| -rw-r--r-- | tools/perf/tests/bpf.c | 68 | 
1 files changed, 32 insertions, 36 deletions
diff --git a/tools/perf/tests/bpf.c b/tools/perf/tests/bpf.c index 34c22cdf4d5d..e8399beca62b 100644 --- a/tools/perf/tests/bpf.c +++ b/tools/perf/tests/bpf.c @@ -3,6 +3,7 @@  #include <sys/epoll.h>  #include <sys/types.h>  #include <sys/stat.h> +#include <fcntl.h>  #include <util/util.h>  #include <util/bpf-loader.h>  #include <util/evlist.h> @@ -19,13 +20,13 @@  #ifdef HAVE_LIBBPF_SUPPORT -static int epoll_wait_loop(void) +static int epoll_pwait_loop(void)  {  	int i;  	/* Should fail NR_ITERS times */  	for (i = 0; i < NR_ITERS; i++) -		epoll_wait(-(i + 1), NULL, 0, 0); +		epoll_pwait(-(i + 1), NULL, 0, 0, NULL);  	return 0;  } @@ -63,46 +64,41 @@ static struct {  	bool	pin;  } bpf_testcase_table[] = {  	{ -		LLVM_TESTCASE_BASE, -		"Basic BPF filtering", -		"[basic_bpf_test]", -		"fix 'perf test LLVM' first", -		"load bpf object failed", -		&epoll_wait_loop, -		(NR_ITERS + 1) / 2, -		false, +		.prog_id	  = LLVM_TESTCASE_BASE, +		.desc		  = "Basic BPF filtering", +		.name		  = "[basic_bpf_test]", +		.msg_compile_fail = "fix 'perf test LLVM' first", +		.msg_load_fail	  = "load bpf object failed", +		.target_func	  = &epoll_pwait_loop, +		.expect_result	  = (NR_ITERS + 1) / 2,  	},  	{ -		LLVM_TESTCASE_BASE, -		"BPF pinning", -		"[bpf_pinning]", -		"fix kbuild first", -		"check your vmlinux setting?", -		&epoll_wait_loop, -		(NR_ITERS + 1) / 2, -		true, +		.prog_id	  = LLVM_TESTCASE_BASE, +		.desc		  = "BPF pinning", +		.name		  = "[bpf_pinning]", +		.msg_compile_fail = "fix kbuild first", +		.msg_load_fail	  = "check your vmlinux setting?", +		.target_func	  = &epoll_pwait_loop, +		.expect_result	  = (NR_ITERS + 1) / 2, +		.pin 		  = true,  	},  #ifdef HAVE_BPF_PROLOGUE  	{ -		LLVM_TESTCASE_BPF_PROLOGUE, -		"BPF prologue generation", -		"[bpf_prologue_test]", -		"fix kbuild first", -		"check your vmlinux setting?", -		&llseek_loop, -		(NR_ITERS + 1) / 4, -		false, +		.prog_id	  = LLVM_TESTCASE_BPF_PROLOGUE, +		.desc		  = "BPF prologue generation", +		.name		  = "[bpf_prologue_test]", +		.msg_compile_fail = "fix kbuild first", +		.msg_load_fail	  = "check your vmlinux setting?", +		.target_func	  = &llseek_loop, +		.expect_result	  = (NR_ITERS + 1) / 4,  	},  #endif  	{ -		LLVM_TESTCASE_BPF_RELOCATION, -		"BPF relocation checker", -		"[bpf_relocation_test]", -		"fix 'perf test LLVM' first", -		"libbpf error when dealing with relocation", -		NULL, -		0, -		false, +		.prog_id	  = LLVM_TESTCASE_BPF_RELOCATION, +		.desc		  = "BPF relocation checker", +		.name		  = "[bpf_relocation_test]", +		.msg_compile_fail = "fix 'perf test LLVM' first", +		.msg_load_fail	  = "libbpf error when dealing with relocation",  	},  }; @@ -167,7 +163,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),  		goto out_delete_evlist;  	} -	err = perf_evlist__mmap(evlist, opts.mmap_pages, false); +	err = perf_evlist__mmap(evlist, opts.mmap_pages);  	if (err < 0) {  		pr_debug("perf_evlist__mmap: %s\n",  			 str_error_r(errno, sbuf, sizeof(sbuf))); @@ -190,7 +186,7 @@ static int do_test(struct bpf_object *obj, int (*func)(void),  	}  	if (count != expect) { -		pr_debug("BPF filter result incorrect\n"); +		pr_debug("BPF filter result incorrect, expected %d, got %d samples\n", expect, count);  		goto out_delete_evlist;  	}  | 
