On Wed, 2024-02-28 at 15:40 -0800, Andrii Nakryiko 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; > > +} > > + > > +static void test_bad_struct_ops(void) > > +{ > > + struct bad_struct_ops *skel; > > + int err; > > + > > + old_print_cb = libbpf_set_print(print_cb); > > + skel = bad_struct_ops__open_and_load(); > > we want to check that the load step failed specifically, right? So > please split open from load, make sure that open succeeds, but load > fails Ok > > > + err = errno; > > + libbpf_set_print(old_print_cb); > > + if (!ASSERT_NULL(skel, "bad_struct_ops__open_and_load")) > > + return; > > + > > + ASSERT_EQ(err, EINVAL, "errno should be EINVAL"); > > + ASSERT_TRUE(msg_found, "expected message"); > > + > > + bad_struct_ops__destroy(skel); > > +} > > + > > +void serial_test_bad_struct_ops(void) > > why does it have to be a serial test? Because it hijacks libbpf print callback. [...]