[PATCH 1/3] tests: add uname.test

Dmitry V. Levin ldv at altlinux.org
Mon Feb 29 23:52:57 UTC 2016


On Fri, Feb 26, 2016 at 05:41:37PM +0800, Fei Jie wrote:
> * tests/uname.c: New file.
> * tests/uname.test: New test.
> * tests/.gitignore: Add uname.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add uname.test.
> ---
>  tests/.gitignore  |  1 +
>  tests/Makefile.am |  2 ++
>  tests/uname.c     | 38 ++++++++++++++++++++++++++++++++++++++
>  tests/uname.test  | 11 +++++++++++
>  4 files changed, 52 insertions(+)
>  create mode 100644 tests/uname.c
>  create mode 100755 tests/uname.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index bdce2db..e79d317 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -124,6 +124,7 @@ umount
>  umount2
>  umovestr
>  umovestr2
> +uname
>  unix-pair-send-recv
>  userfaultfd
>  utime
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 54f3d5b..d924b9a 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -172,6 +172,7 @@ check_PROGRAMS = \
>  	umount2 \
>  	umovestr \
>  	umovestr2 \
> +	uname \
>  	unix-pair-send-recv \
>  	userfaultfd \
>  	utime \
> @@ -326,6 +327,7 @@ TESTS = \
>  	umount2.test \
>  	umovestr.test \
>  	umovestr2.test \
> +	uname.test \
>  	userfaultfd.test \
>  	utime.test \
>  	utimensat.test \
> diff --git a/tests/uname.c b/tests/uname.c
> new file mode 100644
> index 0000000..ac1adce
> --- /dev/null
> +++ b/tests/uname.c
> @@ -0,0 +1,38 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_uname
> +
> +# include <stdio.h>
> +# include <sys/utsname.h>
> +# include <unistd.h>
> +
> +int main()
> +{
> +	struct utsname *const uname = tail_alloc(sizeof(struct utsname));
> +	int rc = syscall(__NR_uname, uname);
> +	printf("uname({sysname=\"%s\", nodename=\"%s\", release=\"%s\""
> +	       ", version=\"%s\", machine=\"%s\""
> +# ifdef _GNU_SOURCE
> +	       ", domainname=\"%s\""
> +# endif

Why _GNU_SOURCE?  Note that strace parser uses HAVE_STRUCT_UTSNAME_DOMAINNAME.


-- 
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/013838f0/attachment.bin>


More information about the Strace-devel mailing list