[PATCH 4/4] tests: add mlockall.test
Dmitry V. Levin
ldv at altlinux.org
Sun Apr 10 00:36:17 UTC 2016
On Fri, Apr 08, 2016 at 03:59:17PM +0800, Fei Jie wrote:
> * 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
No need to use syscall wrapper, mlockall wrapper from libc is OK.
mlockall is not expected to fail with ENOSYS.
I've committed a simpler test instead.
--
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20160410/645be7ac/attachment.bin>
More information about the Strace-devel
mailing list