[PATCH 1/4] tests: add linkat.test

Dmitry V. Levin ldv at altlinux.org
Thu Apr 7 01:53:55 UTC 2016


On Wed, Apr 06, 2016 at 02:18:48PM +0800, Fei Jie wrote:
> * tests/linkat.c: New file.
> * tests/linkat.test: New test.
> * tests/.gitignore: Add linkat.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add linkat.test.
> ---
>  tests/.gitignore  |  1 +
>  tests/Makefile.am |  2 ++
>  tests/linkat.c    | 30 ++++++++++++++++++++++++++++++
>  tests/linkat.test |  6 ++++++
>  4 files changed, 39 insertions(+)
>  create mode 100644 tests/linkat.c
>  create mode 100755 tests/linkat.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index c856bff..85a3491 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -65,6 +65,7 @@ ipc_shm
>  ksysent
>  ksysent.h
>  libtests.a
> +linkat
>  llseek
>  lseek
>  lstat
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 0ebdf71..e03b619 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -114,6 +114,7 @@ check_PROGRAMS = \
>  	ipc_sem \
>  	ipc_shm \
>  	ksysent \
> +	linkat \
>  	llseek \
>  	lseek \
>  	lstat \
> @@ -306,6 +307,7 @@ DECODER_TESTS = \
>  	ipc_msgbuf.test \
>  	ipc_sem.test \
>  	ipc_shm.test \
> +	linkat.test \
>  	llseek.test \
>  	lseek.test \
>  	lstat.test \
> diff --git a/tests/linkat.c b/tests/linkat.c
> new file mode 100644
> index 0000000..e709c22
> --- /dev/null
> +++ b/tests/linkat.c
> @@ -0,0 +1,30 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_linkat
> +
> +# include <errno.h>
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> +	static const char sample_1[] = "sample_old";
> +	static const char sample_2[] = "sample_new";

These names are too general.

> +	const long int fd_old = (long int) 0xdeadbeefffffffff;
> +	const long int fd_new = (long int) 0xdeadbeeffffffffe;
> +	int rc = syscall(__NR_linkat, fd_old, sample_1, fd_new, sample_2, 0);
> +	printf("linkat(%d, \"%s\", %d, \"%s\", 0) = %d %s (%m)\n",
> +	       (int) fd_old, sample_1, (int) fd_new, sample_2, rc,
> +	       errno == ENOSYS ? "ENOSYS" : "EBADF");
> +
> +	puts("+++ exited with 0 +++");
> +	return 0;
> +}
> +
> +#else
> +
> +SKIP_MAIN_UNDEFINED("__NR_linkat")
> +
> +#endif
> diff --git a/tests/linkat.test b/tests/linkat.test
> new file mode 100755
> index 0000000..5627de7
> --- /dev/null
> +++ b/tests/linkat.test
> @@ -0,0 +1,6 @@
> +#!/bin/sh
> +
> +# Check linkat syscall decoding.
> +
> +. "${srcdir=.}/init.sh"
> +run_strace_match_diff

Applied with names of sample files changed.
Also I've added a check for linkat AT_* decoding in a separate commit.


-- 
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/20160407/1dcf6561/attachment.bin>


More information about the Strace-devel mailing list