[prev in list] [next in list] [prev in thread] [next in thread] 

List:       strace
Subject:    Re: [PATCH 3/3] tests: add umask.test
From:       "Dmitry V. Levin" <ldv () altlinux ! org>
Date:       2016-02-29 23:50:47
Message-ID: 20160229235047.GC25777 () altlinux ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Fri, Feb 26, 2016 at 05:41:39PM +0800, Fei Jie wrote:
> * tests/umask.c: New file.
> * tests/umask.test: New test.
> * tests/.gitignore: Add umask.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (TESTS): Add umask.test.
> ---
>  tests/.gitignore  |  1 +
>  tests/Makefile.am |  2 ++
>  tests/umask.c     | 25 +++++++++++++++++++++++++
>  tests/umask.test  | 11 +++++++++++
>  4 files changed, 39 insertions(+)
>  create mode 100644 tests/umask.c
>  create mode 100755 tests/umask.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index a5d586d..31b643c 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -121,6 +121,7 @@ uid
>  uid16
>  uid32
>  uio
> +umask
>  umount
>  umount2
>  umovestr
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 4603c92..6ce2def 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -169,6 +169,7 @@ check_PROGRAMS = \
>  	uid16 \
>  	uid32 \
>  	uio \
> +	umask \
>  	umount \
>  	umount2 \
>  	umovestr \
> @@ -325,6 +326,7 @@ TESTS = \
>  	uid16.test \
>  	uid32.test \
>  	uio.test \
> +	umask.test \
>  	umount.test \
>  	umount2.test \
>  	umovestr.test \
> diff --git a/tests/umask.c b/tests/umask.c
> new file mode 100644
> index 0000000..badc6f5
> --- /dev/null
> +++ b/tests/umask.c
> @@ -0,0 +1,25 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +
> +#ifdef __NR_umask
> +
> +# include <stdio.h>
> +# include <sys/types.h>
> +# include <sys/stat.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> +	mode_t rc = syscall(__NR_umask, 044);

You can assume that umask function provided by libc works
and use it safely instead of syscall().

> +	printf("umask(0%o) = 0%o\n", 044, rc);

This would print zero umask as 00, which is probably not what you want.
Let's use %#o format like strace parser does.


-- 
ldv

[Attachment #5 (application/pgp-signature)]

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140

_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic