On Wed, May 7, 2025 at 2:14 AM Lorenz Bauer lmb@isovalent.com wrote:
On Tue, May 6, 2025 at 10:39 PM Andrii Nakryiko andrii.nakryiko@gmail.com wrote:
raw_data = mmap(NULL, end, PROT_READ, MAP_PRIVATE, fd, 0);
if (!ASSERT_NEQ(raw_data, MAP_FAILED, "mmap_btf"))
ASSERT_OK_PTR()?
Don't think that mmap follows libbpf_get_error conventions? I'd keep it as it is.
ASSERT_OK_PTR() isn't libbpf specific (and libbpf is actually returning a NULL or valid pointer for all public APIs, since libbpf 1.0). But if you look at the implementation, "an OK" pointer is a non-NULL pointer that is also not a small negative value. NULL is a bad pointer, -1 (MAP_FAILED) is a bad pointer, and so on. So it's a pretty universal check for anything pointer-related. Please do use OK_PTR, it's semantically better in tests
btf = btf__new_split(raw_data, btf_size, base);
if (!ASSERT_NEQ(btf, NULL, "parse_btf"))
ASSERT_OK_PTR()
Ack.
Do you intend to add more subtests? if not, why even using a subtest structure
The original intention was to add kmod support, but that didn't pan out, see my discussion with Alexei. I can drop the subtest if you want, but I'd probably keep the helper as it is.
yeah, let's drop the subtest, it's a bit easier to work with non-subtest tests, IMO