* libtraceevent: bail out of utest if mmap fails
@ 2026-05-05 20:22 Emil Thorsoe
2026-05-06 13:27 ` Steven Rostedt
0 siblings, 1 reply; 2+ messages in thread
From: Emil Thorsoe @ 2026-05-05 20:22 UTC (permalink / raw)
To: linux-trace-devel
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 <ethorsoe@tuxera.com>
---
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);
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: libtraceevent: bail out of utest if mmap fails
2026-05-05 20:22 libtraceevent: bail out of utest if mmap fails Emil Thorsoe
@ 2026-05-06 13:27 ` Steven Rostedt
0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2026-05-06 13:27 UTC (permalink / raw)
To: Emil Thorsoe; +Cc: linux-trace-devel
On Tue, 5 May 2026 23:22:44 +0300
Emil Thorsoe <ethorsoe@tuxera.com> wrote:
> 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 <ethorsoe@tuxera.com>
> ---
> 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] ...");
Hmm. Instead of failing, let's instead allocate memory and read it, and
use that instead.
char *btf_buf = NULL;
[..]
if (buf == MAP_FAILED) {
btf_buf = malloc(st.size);
/* error check here */
CU_TEST(read(fd, btf_buf, st.st_size) == st.st_size);
}
[..]
if (btf_buf)
free(btf_buf);
else
munmap(btf, st.st_size);
or something like that.
Thanks,
-- Steve
> + close(fd);
> + return;
> + }
> CU_TEST(tep_load_btf(test_tep, buf, st.st_size) == 0);
>
> munmap(buf, st.st_size);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-06 13:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-05 20:22 libtraceevent: bail out of utest if mmap fails Emil Thorsoe
2026-05-06 13:27 ` Steven Rostedt
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.