summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2018-12-13 14:42:32 -0500
committerDaniel Borkmann <daniel@iogearbox.net>2018-12-14 19:28:32 -0500
commit730ff40f80c5b09b2402958321f2762a3f852e30 (patch)
tree8f9343d755afbcef24f6761aaae75a5919a654c1 /tools
parentb233920c97a6201eb47fbafd78365c6946e6d7b6 (diff)
selftests/bpf: check insn processed in test_verifier
Teach test_verifier to parse verifier output for insn processed and compare with expected number. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Edward Cree <ecree@solarflare.com> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/selftests/bpf/test_verifier.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c
index a08c67c8767e..82359cdbc805 100644
--- a/tools/testing/selftests/bpf/test_verifier.c
+++ b/tools/testing/selftests/bpf/test_verifier.c
@@ -76,7 +76,7 @@ struct bpf_test {
76 int fixup_percpu_cgroup_storage[MAX_FIXUPS]; 76 int fixup_percpu_cgroup_storage[MAX_FIXUPS];
77 const char *errstr; 77 const char *errstr;
78 const char *errstr_unpriv; 78 const char *errstr_unpriv;
79 uint32_t retval, retval_unpriv; 79 uint32_t retval, retval_unpriv, insn_processed;
80 enum { 80 enum {
81 UNDEF, 81 UNDEF,
82 ACCEPT, 82 ACCEPT,
@@ -14444,6 +14444,19 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
14444 } 14444 }
14445 } 14445 }
14446 14446
14447 if (test->insn_processed) {
14448 uint32_t insn_processed;
14449 char *proc;
14450
14451 proc = strstr(bpf_vlog, "processed ");
14452 insn_processed = atoi(proc + 10);
14453 if (test->insn_processed != insn_processed) {
14454 printf("FAIL\nUnexpected insn_processed %u vs %u\n",
14455 insn_processed, test->insn_processed);
14456 goto fail_log;
14457 }
14458 }
14459
14447 if (fd_prog >= 0) { 14460 if (fd_prog >= 0) {
14448 __u8 tmp[TEST_DATA_LEN << 2]; 14461 __u8 tmp[TEST_DATA_LEN << 2];
14449 __u32 size_tmp = sizeof(tmp); 14462 __u32 size_tmp = sizeof(tmp);