[PATCH 4/4] tests: add getsid.test
Dmitry V. Levin
ldv at altlinux.org
Wed Apr 20 01:24:12 UTC 2016
On Tue, Apr 19, 2016 at 03:38:35PM +0800, Fei Jie wrote:
> * tests/getsid.c: New file.
> * tests/getsid.test: New test.
> * tests/.gitignore: Add getsid.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add getsid.test.
> ---
> tests/.gitignore | 1 +
> tests/Makefile.am | 2 ++
> tests/getsid.c | 23 +++++++++++++++++++++++
> tests/getsid.test | 6 ++++++
> 4 files changed, 32 insertions(+)
> create mode 100644 tests/getsid.c
> create mode 100755 tests/getsid.test
>
> diff --git a/tests/.gitignore b/tests/.gitignore
> index fd5909b..ffc7b1f 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -61,6 +61,7 @@ getdents
> getdents64
> getrandom
> getrusage
> +getsid
> getxxid
> inet-cmsg
> ioctl
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 7231818..d39df1f 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -113,6 +113,7 @@ check_PROGRAMS = \
> getdents64 \
> getrandom \
> getrusage \
> + getsid \
> getxxid \
> inet-cmsg \
> ioctl \
> @@ -327,6 +328,7 @@ DECODER_TESTS = \
> getdents64.test \
> getrandom.test \
> getrusage.test \
> + getsid.test \
> getxxid.test \
> inet-cmsg.test \
> ioctl.test \
> diff --git a/tests/getsid.c b/tests/getsid.c
> new file mode 100644
> index 0000000..2b67892
> --- /dev/null
> +++ b/tests/getsid.c
> @@ -0,0 +1,23 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_getsid
> +
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> + int rc = syscall(__NR_getsid, 0);
> + printf("getsid(0) = %d\n", rc);
Why don't you just use getsid()?
Printing 0 all the time is boring, let's print a pid instead:
pid_t pid = getpid();
printf("getsid(%d) = %d\n", pid, getsid(pid));
--
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/20160420/faa243f2/attachment.bin>
More information about the Strace-devel
mailing list