]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added regression test for Linux' capget system call.
authorBart Van Assche <bvanassche@acm.org>
Wed, 27 Aug 2008 17:41:06 +0000 (17:41 +0000)
committerBart Van Assche <bvanassche@acm.org>
Wed, 27 Aug 2008 17:41:06 +0000 (17:41 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8553

memcheck/tests/Makefile.am
memcheck/tests/linux-capget.c [new file with mode: 0644]
memcheck/tests/linux-capget.stderr.exp [new file with mode: 0644]
memcheck/tests/linux-capget.vgtest [new file with mode: 0644]

index 90229131ee82d19279859bee03c5ab16244afbc7..f5c5c0bf277a3adf879f655d6c27faa5dd96e9de 100644 (file)
@@ -66,6 +66,7 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        leak-tree.stderr.exp2 leak-tree.stderr.exp64 \
        leak-regroot.vgtest leak-regroot.stderr.exp \
        leakotron.vgtest leakotron.stdout.exp leakotron.stderr.exp \
+       linux-capget linux-capget.stderr.exp \
        linux-syslog-syscall linux-syslog-syscall.stderr.exp \
        linux-syscalls-2007 linux-syscalls-2007.stderr.exp \
        linux-timerfd-syscall linux-timerfd-syscall.stderr.exp \
@@ -190,6 +191,7 @@ check_PROGRAMS = \
        file_locking \
        fprw fwrite hello inits inline \
        leak-0 leak-cycle leak-pool leak-tree leak-regroot leakotron \
+       linux-capget \
        linux-syslog-syscall \
        linux-syscalls-2007 \
        linux-timerfd-syscall \
diff --git a/memcheck/tests/linux-capget.c b/memcheck/tests/linux-capget.c
new file mode 100644 (file)
index 0000000..31d8195
--- /dev/null
@@ -0,0 +1,50 @@
+#if defined(linux)
+
+
+#include <stdio.h>            /* printf() */
+#include <unistd.h>           /* syscall() */
+#include <sys/syscall.h>      /* __NR_capget */
+#include <linux/capability.h> /* _LINUX_CAPABILITY_VERSION */
+
+
+int main()
+{
+  struct __user_cap_header_struct h;
+  struct __user_cap_data_struct d;
+  int syscall_result;
+
+  h.version = _LINUX_CAPABILITY_VERSION;
+  h.pid = 0;
+  syscall_result = syscall(__NR_capget, &h, &d);
+  if (syscall_result >= 0)
+  {
+    fprintf(stderr,
+            "capget result:\n"
+            "effective   %#x\n"
+            "permitted   %#x\n"
+            "inheritable %#x\n",
+            d.effective,
+            d.permitted,
+            d.inheritable);
+  }
+  else
+  {
+    perror("capget");
+  }
+  return 0;
+}
+
+
+#else
+
+
+#include <stdio.h>
+
+int main()
+{
+  fprintf(stderr, "This program is Linux-specific\n");
+  return 0;
+}
+
+
+#endif
diff --git a/memcheck/tests/linux-capget.stderr.exp b/memcheck/tests/linux-capget.stderr.exp
new file mode 100644 (file)
index 0000000..74c030f
--- /dev/null
@@ -0,0 +1,11 @@
+
+capget result:
+effective   0
+permitted   0
+inheritable 0
+
+ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
+malloc/free: in use at exit: ... bytes in ... blocks.
+malloc/free: ... allocs, ... frees, ... bytes allocated.
+For a detailed leak analysis,  rerun with: --leak-check=yes
+For counts of detected errors, rerun with: -v
diff --git a/memcheck/tests/linux-capget.vgtest b/memcheck/tests/linux-capget.vgtest
new file mode 100644 (file)
index 0000000..acce6ab
--- /dev/null
@@ -0,0 +1,2 @@
+prog: linux-capget
+stderr_filter: filter_allocs