[LTP] [PATCH v4] mmap22.c: Test for new MAP_DROPPABLE flag for mmap

Cyril Hrubis chrubis@suse.cz
Wed May 7 17:25:38 CEST 2025


Hi!
Pushed with a minor change, thanks.

We should check if the addr is valid before we attemp to unmap it in the
setup() so I've added:

diff --git a/testcases/kernel/syscalls/mmap/mmap22.c b/testcases/kernel/syscalls/mmap/mmap22.c
index bfef559e4..0e589dfab 100644
--- a/testcases/kernel/syscalls/mmap/mmap22.c
+++ b/testcases/kernel/syscalls/mmap/mmap22.c
@@ -72,8 +72,13 @@ static void setup(void)
 {
        void *addr = mmap(0, 1, PROT_READ | PROT_WRITE,
                        MAP_ANONYMOUS | MAP_DROPPABLE, -1, 0);
+
        if (addr == MAP_FAILED && errno == EINVAL)
-               tst_brk(TCONF, "MAP_DROPPABLE not support");
+               tst_brk(TCONF, "MAP_DROPPABLE not supported");
+
+       if (addr == MAP_FAILED)
+               tst_brk(TBROK | TERRNO, "mmap() MAP_DROPPABLE failed");
+
        SAFE_MUNMAP(addr, 1);
 }


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list