]> granicus.if.org Git - strace/commitdiff
tests: extend test coverage of getresuid syscall
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 19 Apr 2016 17:30:23 +0000 (17:30 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 20 Apr 2016 01:08:13 +0000 (01:08 +0000)
* 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.

tests/.gitignore
tests/Makefile.am
tests/getresugid.c [new file with mode: 0644]
tests/getresuid.c [new file with mode: 0644]
tests/getresuid.test [new file with mode: 0755]

index 87ef8a925c2683cb5efb5944cd46cae9c46893fa..e1491a95c6e093be2762769ff7fc57af93c9f2b3 100644 (file)
@@ -62,6 +62,7 @@ getdents64
 getgroups
 getgroups32
 getrandom
+getresuid
 getrusage
 getxxid
 inet-cmsg
index 6f515dafe3feb65589ab2e893033f4d82a10400a..a29e71a33a1ae876a7488925b8db95c2a3f0186e 100644 (file)
@@ -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 \
diff --git a/tests/getresugid.c b/tests/getresugid.c
new file mode 100644 (file)
index 0000000..13501ba
--- /dev/null
@@ -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;
+}
diff --git a/tests/getresuid.c b/tests/getresuid.c
new file mode 100644 (file)
index 0000000..bf4ada1
--- /dev/null
@@ -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
diff --git a/tests/getresuid.test b/tests/getresuid.test
new file mode 100755 (executable)
index 0000000..eee1ac0
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check getresuid syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a25