libtraceevent: bail out of utest if mmap fails
Emil Thorsoe <[email protected]> Tue, 5 May 2026 23:22:44 +0300
| Newsgroups | org.kernel.vger.linux-trace-devel |
|---|---|
| Message-ID | <[email protected]> |
Just like, when failing to open the BTF file, failing to mmap the BTF is testing the test environment, not the code. This mmap fails with ENODEV on i686 nix build on nixos-unstable. Just bail out without failing the test, when mmap fails. Signed-off-by: Emil Thorsoe <[email protected]> --- utest/traceevent-utest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utest/traceevent-utest.c b/utest/traceevent-utest.c index b62411c..df98fa1 100644 --- a/utest/traceevent-utest.c +++ b/utest/traceevent-utest.c @@ -397,8 +397,11 @@ static void test_btf_read(void) CU_TEST(fstat(fd, &st) == 0); buf = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - CU_TEST(buf != MAP_FAILED); - + if (buf == MAP_FAILED) { + printf("[KERNEL DOES NOT ALLOW MMAP OF BTF FILE] ..."); + close(fd); + return; + } CU_TEST(tep_load_btf(test_tep, buf, st.st_size) == 0); munmap(buf, st.st_size);