On Wed, Feb 28, 2024 at 10:06:21PM +0200, Eduard Zingerman wrote: > On Wed, 2024-02-28 at 12:15 -0600, David Vernet wrote: > [...] > > > > +static libbpf_print_fn_t old_print_cb; > > > +static bool msg_found; > > > + > > > +static int print_cb(enum libbpf_print_level level, const char *fmt, va_list args) > > > +{ > > > + old_print_cb(level, fmt, args); > > > + if (level == LIBBPF_WARN && strncmp(fmt, EXPECTED_MSG, strlen(EXPECTED_MSG)) == 0) > > > + msg_found = true; > > > + > > > + return 0; > > > +} > > > > Not necessary at all for this patch set / just an observation, but it would be > > nice to have this be something offered by the core prog_tests framework > > (meaning, the ability to assert libbpf output for a testcase). > > This might be useful, I will add a utility function for it (probably two). > > [...] > > > > diff --git a/tools/testing/selftests/bpf/progs/bad_struct_ops.c b/tools/testing/selftests/bpf/progs/bad_struct_ops.c > > > new file mode 100644 > > > index 000000000000..9c103afbfdb1 > > > --- /dev/null > > > +++ b/tools/testing/selftests/bpf/progs/bad_struct_ops.c > > > @@ -0,0 +1,17 @@ > > > +// SPDX-License-Identifier: GPL-2.0 > > > + > > > +#include <vmlinux.h> > > > +#include <bpf/bpf_helpers.h> > > > +#include <bpf/bpf_tracing.h> > > > +#include "../bpf_testmod/bpf_testmod.h" > > > + > > > +char _license[] SEC("license") = "GPL"; > > > + > > > +SEC("struct_ops/test_1") > > > +int BPF_PROG(test_1) { return 0; } > > > + > > > +SEC(".struct_ops.link") > > > +struct bpf_testmod_ops testmod_1 = { .test_1 = (void *)test_1 }; > > > > Just to make be 100% sure that we're isolating the issue under test, should we > > also add a .test_2 prog and add it to the struct bpf_testmod_ops map? > > You are concerned that error might be confused with libbpf insisting > that '.test_2' should be present, right? > libbpf allows NULL members but I can add '.test_2' here, no problem. Correct, and yes that's true. Feel free to ignore if you think it's cleaner without, totally up to you.
Attachment:
signature.asc
Description: PGP signature