[PATCH 4/4] tests: add mlockall.test

Fei Jie feij.fnst at cn.fujitsu.com
Fri Apr 8 07:59:17 UTC 2016


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

diff --git a/tests/.gitignore b/tests/.gitignore
index 9ef0c03..d3ff1de 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -79,6 +79,7 @@ mincore
 mkdirat
 mknod
 mlock2
+mlockall
 mmap
 mmap64
 mmsg
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7cd3991..9f4371f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -128,6 +128,7 @@ check_PROGRAMS = \
 	mkdirat \
 	mknod \
 	mlock2 \
+	mlockall \
 	mmap \
 	mmap64 \
 	mmsg \
@@ -327,6 +328,7 @@ DECODER_TESTS = \
 	mkdirat.test \
 	mknod.test \
 	mlock2.test \
+	mlockall.test \
 	mmap.test \
 	mmap64.test \
 	mmsg.test \
diff --git a/tests/mlockall.c b/tests/mlockall.c
new file mode 100644
index 0000000..8d0c0a3
--- /dev/null
+++ b/tests/mlockall.c
@@ -0,0 +1,48 @@
+#include "tests.h"
+#include <sys/syscall.h>
+
+#ifdef __NR_mlockall
+
+# include <errno.h>
+# include <stdio.h>
+# include <sys/mman.h>
+# include <errno.h>
+# include <unistd.h>
+
+# define UNKNOWN_FLAG 0
+
+int
+main(void)
+{
+	int rc = syscall(__NR_mlockall, UNKNOWN_FLAG);
+	printf("mlockall(%d) = %d EINVAL (%m)\n",
+	       UNKNOWN_FLAG, rc);
+
+	const char *errno_text;
+	if((syscall(__NR_mlockall, MCL_CURRENT)) == -1) {
+		switch (errno) {
+			case ENOSYS:
+				errno_text = "ENOSYS";
+				break;
+			case ENOMEM:
+				errno_text = "ENOMEM";
+				break;
+			default:
+				errno_text = "EPERM";
+		}
+		printf("mlockall(MCL_CURRENT) = -1 %s (%m)\n",
+		       errno_text);
+	} else {
+		puts("mlockall(MCL_CURRENT) = 0");
+		munlockall();
+	}
+
+	puts("+++ exited with 0 +++");
+	return 0;
+}
+
+#else
+
+SKIP_MAIN_UNDEFINED("__NR_mlockall")
+
+#endif
diff --git a/tests/mlockall.test b/tests/mlockall.test
new file mode 100755
index 0000000..6ab5b9d
--- /dev/null
+++ b/tests/mlockall.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check mlockall syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a12
-- 
1.8.3.1







More information about the Strace-devel mailing list