On Tue, Sep 15, 2020 at 5:50 PM Toke Høiland-Jørgensen <toke@xxxxxxxxxx> wrote: > > From: Jiri Olsa <jolsa@xxxxxxxxxx> > > Adding test that setup following program: > > SEC("classifier/test_pkt_md_access") > int test_pkt_md_access(struct __sk_buff *skb) > > with its extension: > > SEC("freplace/test_pkt_md_access") > int test_pkt_md_access_new(struct __sk_buff *skb) > > and tracing that extension with: > > SEC("fentry/test_pkt_md_access_new") > int BPF_PROG(fentry, struct sk_buff *skb) > > The test verifies that the tracing program can > dereference skb argument properly. > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > Signed-off-by: Toke Høiland-Jørgensen <toke@xxxxxxxxxx> > --- Looks good, with a minor CHECK() complaint below. Acked-by: Andrii Nakryiko <andriin@xxxxxx> > tools/testing/selftests/bpf/prog_tests/trace_ext.c | 113 ++++++++++++++++++++ > tools/testing/selftests/bpf/progs/test_trace_ext.c | 18 +++ > .../selftests/bpf/progs/test_trace_ext_tracing.c | 25 ++++ > 3 files changed, 156 insertions(+) > create mode 100644 tools/testing/selftests/bpf/prog_tests/trace_ext.c > create mode 100644 tools/testing/selftests/bpf/progs/test_trace_ext.c > create mode 100644 tools/testing/selftests/bpf/progs/test_trace_ext_tracing.c > [...] > + err = test_trace_ext_tracing__attach(skel_trace); > + if (CHECK(err, "setup", "tracing/test_pkt_md_access_new attach failed: %d\n", err)) > + goto cleanup; > + > + /* trigger the test */ > + err = bpf_prog_test_run(pkt_fd, 1, &pkt_v4, sizeof(pkt_v4), > + NULL, NULL, &retval, &duration); > + CHECK(err || retval, "", please don't use empty string here > + "err %d errno %d retval %d duration %d\n", > + err, errno, retval, duration); who and why cares about duration here?.. > + > + bss_ext = skel_ext->bss; > + bss_trace = skel_trace->bss; > + > + len = bss_ext->ext_called; > + > + CHECK(bss_ext->ext_called == 0, > + "check", "failed to trigger freplace/test_pkt_md_access\n"); > + CHECK(bss_trace->fentry_called != len, > + "check", "failed to trigger fentry/test_pkt_md_access_new\n"); > + CHECK(bss_trace->fexit_called != len, > + "check", "failed to trigger fexit/test_pkt_md_access_new\n"); > + > +cleanup: > + test_trace_ext_tracing__destroy(skel_trace); > + test_trace_ext__destroy(skel_ext); > + test_pkt_md_access__destroy(skel_pkt); > +} [...]