* tests/mlock.c: New file.
* tests/mlock.test: New test.
* tests/.gitignore: Add mlock.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add mlock.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/mlock.c     | 38 ++++++++++++++++++++++++++++++++++++++
 tests/mlock.test  |  6 ++++++
 4 files changed, 47 insertions(+)
 create mode 100644 tests/mlock.c
 create mode 100755 tests/mlock.test

diff --git a/tests/.gitignore b/tests/.gitignore
index 9195b5b..f2fa908 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -110,6 +110,7 @@ mkdir
 mkdirat
 mknod
 mknodat
+mlock
 mlock2
 mlockall
 mmap
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a418b03..3c01e6b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -162,6 +162,7 @@ check_PROGRAMS = \
        mkdirat \
        mknod \
        mknodat \
+       mlock \
        mlock2 \
        mlockall \
        mmap \
@@ -428,6 +429,7 @@ DECODER_TESTS = \
        mkdirat.test \
        mknod.test \
        mknodat.test \
+       mlock.test \
        mlock2.test \
        mlockall.test \
        mmap.test \
diff --git a/tests/mlock.c b/tests/mlock.c
new file mode 100644
index 0000000..b75aab9
--- /dev/null
+++ b/tests/mlock.c
@@ -0,0 +1,38 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#if defined __NR_mlock && defined __NR_munlock
+
+# include <stdio.h>
+# include <unistd.h>
+# include <sys/mman.h>
+
+const int size = 1024;
+
+int
+main(void)
+{
+       const char *addr = tail_alloc(size);
+       if (syscall(__NR_mlock, addr, size) == 0) {
+               printf("mlock(%p, %d) = 0\n", addr, size);
+       } else {
+               printf("mlock(%p, %d) = -1 %s (%m)\n",
+                      addr, size, errno2name());
+       }
+
+       if (syscall(__NR_munlock, addr, size) == 0) {
+               printf("munlock(%p, %d) = 0\n", addr, size);
+       } else {
+               printf("munlock(%p, %d) = -1 %s (%m)\n",
+                      addr, size, errno2name());
+       }
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
+
+#else
+
+SKIP_MAIN_DEFINED("__NR_mlock && __NR_munlock")
+
+#endif
diff --git a/tests/mlock.test b/tests/mlock.test
new file mode 100755
index 0000000..9a73a30
--- /dev/null
+++ b/tests/mlock.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check mlock and munlock syscalls decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -e trace=mlock,munlock -a20
-- 
1.8.3.1




------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to