[PATCH 2/3] tests: add rename.test
Dmitry V. Levin
ldv at altlinux.org
Tue Mar 1 00:02:24 UTC 2016
On Fri, Feb 26, 2016 at 05:41:38PM +0800, Fei Jie wrote:
> * tests/rename.c: New file.
> * tests/rename.test: New test.
> * tests/.gitignore: Add rename.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add rename.test.
> ---
> tests/.gitignore | 1 +
> tests/Makefile.am | 2 ++
> tests/rename.c | 27 +++++++++++++++++++++++++++
> tests/rename.test | 11 +++++++++++
> 4 files changed, 41 insertions(+)
> create mode 100644 tests/rename.c
> create mode 100755 tests/rename.test
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index e79d317..a5d586d 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -81,6 +81,7 @@ readlink
> readlinkat
> readv
> recvmsg
> +rename
> restart_syscall
> rt_sigpending
> rt_sigprocmask
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index d924b9a..4603c92 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -129,6 +129,7 @@ check_PROGRAMS = \
> readlinkat \
> readv \
> recvmsg \
> + rename \
> restart_syscall \
> rt_sigpending \
> rt_sigprocmask \
> @@ -287,6 +288,7 @@ TESTS = \
> readlinkat.test \
> readv.test \
> recvmsg.test \
> + rename.test \
> rt_sigpending.test \
> rt_sigprocmask.test \
> rt_sigqueueinfo.test \
> diff --git a/tests/rename.c b/tests/rename.c
> new file mode 100644
> index 0000000..126d985
> --- /dev/null
> +++ b/tests/rename.c
> @@ -0,0 +1,27 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_rename
> +
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +# define OLD_FILE "rename_old"
> +# define NEW_FILE "rename_new"
> +
> +int
> +main(void)
> +{
> + int rc = syscall(__NR_rename, OLD_FILE, NEW_FILE);
> + printf("rename(\"%s\", \"%s\") = %d ENOENT (%m)\n",
> + OLD_FILE, NEW_FILE, rc);
There is a chance that __NR_rename is defined but the syscall
is not implemented. Let's print it like in tests/execveat.c:
errno == ENOSYS ? "ENOSYS" : "ENOENT"
--
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/20160301/f8516cee/attachment.bin>
More information about the Strace-devel
mailing list