tests: extend test coverage of getresuid syscall
* tests/getresugid.c: New file. * tests/getresuid.c: New file. * tests/getresuid.test: New test. * tests/.gitignore: Add getresuid. * tests/Makefile.am (check_PROGRAMS): Likewise. (DECODER_TESTS): Add getresuid.test. (EXTRA_DIST): Add getresugid.c.
This commit is contained in:
1
tests/.gitignore
vendored
1
tests/.gitignore
vendored
@ -62,6 +62,7 @@ getdents64
|
||||
getgroups
|
||||
getgroups32
|
||||
getrandom
|
||||
getresuid
|
||||
getrusage
|
||||
getxxid
|
||||
inet-cmsg
|
||||
|
@ -114,6 +114,7 @@ check_PROGRAMS = \
|
||||
getgroups \
|
||||
getgroups32 \
|
||||
getrandom \
|
||||
getresuid \
|
||||
getrusage \
|
||||
getxxid \
|
||||
inet-cmsg \
|
||||
@ -350,6 +351,7 @@ DECODER_TESTS = \
|
||||
getgroups.test \
|
||||
getgroups32.test \
|
||||
getrandom.test \
|
||||
getresuid.test \
|
||||
getrusage.test \
|
||||
getxxid.test \
|
||||
inet-cmsg.test \
|
||||
@ -540,6 +542,7 @@ EXTRA_DIST = init.sh run.sh match.awk \
|
||||
filter-unavailable.expected \
|
||||
fstatat.c \
|
||||
fstatx.c \
|
||||
getresugid.c \
|
||||
ip_mreq.expected \
|
||||
ipc.sh \
|
||||
ipc_msgbuf.expected \
|
||||
|
60
tests/getresugid.c
Normal file
60
tests/getresugid.c
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Check decoding of getresuid/getresgid/getresuid32/getresgid32 syscalls.
|
||||
*
|
||||
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
unsigned UGID_TYPE *const r = tail_alloc(sizeof(*r));
|
||||
unsigned UGID_TYPE *const e = tail_alloc(sizeof(*e));
|
||||
unsigned UGID_TYPE *const s = tail_alloc(sizeof(*s));
|
||||
(void) tail_alloc(1);
|
||||
|
||||
if (syscall(SYSCALL_NR, r, e, s))
|
||||
perror_msg_and_fail(SYSCALL_NAME);
|
||||
|
||||
printf("%s([%u], [%u], [%u]) = 0\n", SYSCALL_NAME,
|
||||
(unsigned) *r, (unsigned) *e, (unsigned) *s);
|
||||
|
||||
assert(syscall(SYSCALL_NR, NULL, e, s) == -1);
|
||||
printf("%s(NULL, %p, %p) = -1 EFAULT (%m)\n", SYSCALL_NAME, e, s);
|
||||
|
||||
assert(syscall(SYSCALL_NR, r, NULL, s) == -1);
|
||||
printf("%s(%p, NULL, %p) = -1 EFAULT (%m)\n", SYSCALL_NAME, r, s);
|
||||
|
||||
assert(syscall(SYSCALL_NR, r, e, NULL) == -1);
|
||||
printf("%s(%p, %p, NULL) = -1 EFAULT (%m)\n", SYSCALL_NAME, r, e);
|
||||
|
||||
puts("+++ exited with 0 +++");
|
||||
return 0;
|
||||
}
|
21
tests/getresuid.c
Normal file
21
tests/getresuid.c
Normal file
@ -0,0 +1,21 @@
|
||||
#include "tests.h"
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#ifdef __NR_getresuid
|
||||
|
||||
# define SYSCALL_NR __NR_getresuid
|
||||
# define SYSCALL_NAME "getresuid"
|
||||
|
||||
# if defined __NR_getresuid32 && __NR_getresuid != __NR_getresuid32
|
||||
# define UGID_TYPE short
|
||||
# else
|
||||
# define UGID_TYPE int
|
||||
# endif
|
||||
|
||||
# include "getresugid.c"
|
||||
|
||||
#else
|
||||
|
||||
SKIP_MAIN_UNDEFINED("__NR_getresuid")
|
||||
|
||||
#endif
|
6
tests/getresuid.test
Executable file
6
tests/getresuid.test
Executable file
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Check getresuid syscall decoding.
|
||||
|
||||
. "${srcdir=.}/init.sh"
|
||||
run_strace_match_diff -a25
|
Reference in New Issue
Block a user