On Tue, Apr 12, 2016 at 02:57:45PM +0800, Fei Jie wrote:
> * tests/lchown.c: New file.
> * tests/lchown.test: New test.
> * tests/.gitignore: Add lchown.
> * tests/Makefile.am (check_PROGRAMS): Likewise.
> (DECODER_TESTS): Add lchown.test.
> ---
>  tests/.gitignore  |  1 +
>  tests/Makefile.am |  2 ++
>  tests/lchown.c    | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/lchown.test |  6 ++++++
>  4 files changed, 58 insertions(+)
>  create mode 100644 tests/lchown.c
>  create mode 100755 tests/lchown.test
> 
> diff --git a/tests/.gitignore b/tests/.gitignore
> index 6aae5de..35db0da 100644
> --- a/tests/.gitignore
> +++ b/tests/.gitignore
> @@ -67,6 +67,7 @@ ipc_sem
>  ipc_shm
>  ksysent
>  ksysent.h
> +lchown
>  libtests.a
>  linkat
>  llseek
> diff --git a/tests/Makefile.am b/tests/Makefile.am
> index 2a4feb0..c3138eb 100644
> --- a/tests/Makefile.am
> +++ b/tests/Makefile.am
> @@ -117,6 +117,7 @@ check_PROGRAMS = \
>       ipc_sem \
>       ipc_shm \
>       ksysent \
> +     lchown \
>       linkat \
>       llseek \
>       lseek \
> @@ -321,6 +322,7 @@ DECODER_TESTS = \
>       ipc_msgbuf.test \
>       ipc_sem.test \
>       ipc_shm.test \
> +     lchown.test \
>       linkat.test \
>       llseek.test \
>       lseek.test \
> diff --git a/tests/lchown.c b/tests/lchown.c
> new file mode 100644
> index 0000000..f39797c
> --- /dev/null
> +++ b/tests/lchown.c
> @@ -0,0 +1,49 @@
> +#include "tests.h"
> +#include <sys/syscall.h>
> +#include <fcntl.h>
> +
> +#ifdef __NR_lchown
> +
> +# include <errno.h>
> +# include <stdio.h>
> +# include <unistd.h>
> +
> +int
> +main(void)
> +{
> +     static const char sample[] = "lchown_sample";
> +     uid_t uid = geteuid();
> +     uid_t gid = getegid();
> +
> +     if (open(sample, O_RDONLY | O_CREAT, 0400) == -1)
> +             perror_msg_and_fail("open");
> +
> +     if (syscall(__NR_lchown, sample, uid, gid) == 0) {
> +             printf("lchown(\"%s\", %d, %d) = 0\n",
> +                    sample, uid, gid);

On 9 architectures supported by strace (including arm and x86),
__NR_lchown operates with 16-bit uids/gids, while geteuid/getegid
functions return 32-bit uids/gids.  This leads to test failure.

I've committed a different test for lchown and related syscalls.  It also
does some corner case testing that helped to find and fix a bug in 16-bit
uids/gids decoder.


-- 
ldv

Attachment: pgpSP9RKqsiMc.pgp
Description: PGP signature

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to