Skip to contentSkip to conversation

Added test case to test mmap with MAP_FIXED_NOREPLACE flag

PATCH New Kushal Chand 2 participants 2 messages Jun 9, 2020 – Jun 11, 2020

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Added test case to test mmap with MAP_FIXED_NOREPLACE flag

This patch adds a new test case for the mmap syscall. It tests the MAP_FIXED_NOREPLACE flag of mmap. The code checks if MAP_FIXED_NOREPLACE returns with EEXIST when mapped with an already mapped address. It does so by allocating an available address by passing NULL to first argument of mmap and tries to mmap with MAP_FIXED_NOREPLACE flag at the same address returned by the first mmap call. This fails as expected. It also does the necessary changes required to run the syscall using the runltp command after building the LTP test suite.
Git Hub Issue link - https://github.com/linux-test-project/ltp/issues/299

---
 include/lapi/mmap.h                       | 10 +++
 runtest/syscalls                          |  1 +
 testcases/kernel/syscalls/mmap/.gitignore |  1 +
 testcases/kernel/syscalls/mmap/mmap17.c   | 85 +++++++++++++++++++++++
 4 files changed, 97 insertions(+)
 create mode 100644 testcases/kernel/syscalls/mmap/mmap17.c
include/lapi/mmap.h +10 -0
index b3db94128..12845b76e 100644
@@ -66,6 +66,16 @@
 # define MADV_KEEPONFORK 19
 #endif
 
+#ifndef MAP_FIXED_NOREPLACE
+
+#ifdef __alpha__
+# define MAP_FIXED_NOREPLACE 0x200000
+#else
+# define MAP_FIXED_NOREPLACE 0x100000
+#endif
+
+#endif /* MAP_FIXED_NOREPLACE */
+
 #ifdef HAVE_SYS_SHM_H
 # include <sys/shm.h>
 # define MMAP_GRANULARITY SHMLBA
runtest/syscalls +1 -0
index edd3e8de7..e685037c7 100644
@@ -745,6 +745,7 @@ mmap14 mmap14
 #mmap11 mmap11 -i 30000
 mmap15 mmap15
 mmap16 mmap16
+mmap17 mmap17
 
 modify_ldt01 modify_ldt01
 modify_ldt02 modify_ldt02
testcases/kernel/syscalls/mmap/.gitignore +1 -0
index 39ed2aab0..c5c083d4b 100644
@@ -15,3 +15,4 @@
 /mmap14
 /mmap15
 /mmap16
+/mmap17
testcases/kernel/syscalls/mmap/mmap17.c new file +85 -0

85 lines not on this page · raw message

--
2.20.1

#1 lore raw

PATCH v2 1/1 Added test case to test mmap with MAP_FIXED_NOREPLACE flag

----- Original Message -----

Quoted 11 lines

This patch adds a new test case for the mmap syscall. It tests the MAP_FIXED_NOREPLACE flag of mmap. The code checks if MAP_FIXED_NOREPLACE returns with EEXIST when mapped with an already mapped address. It does so by allocating an available address by passing NULL to first argument of mmap and tries to mmap with MAP_FIXED_NOREPLACE flag at the same address returned by the first mmap call. This fails as expected. It also does the necessary changes required to run the syscall using the runltp command after building the LTP test suite.
Git Hub Issue link - https://github.com/linux-test-project/ltp/issues/299

Quoted 2 lines

Added include to lapi/mmap.h, slightly modified commit message and pushed.

Thanks,
Jan