From: Bart Van Assche Date: Wed, 27 Aug 2008 17:41:06 +0000 (+0000) Subject: Added regression test for Linux' capget system call. X-Git-Tag: svn/VALGRIND_3_4_0~279 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1f63c5ebc4d4535eb77813fe39f5ac1befb33620;p=thirdparty%2Fvalgrind.git Added regression test for Linux' capget system call. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@8553 --- diff --git a/memcheck/tests/Makefile.am b/memcheck/tests/Makefile.am index 90229131ee..f5c5c0bf27 100644 --- a/memcheck/tests/Makefile.am +++ b/memcheck/tests/Makefile.am @@ -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 index 0000000000..31d8195672 --- /dev/null +++ b/memcheck/tests/linux-capget.c @@ -0,0 +1,50 @@ +#if defined(linux) + + +#include /* printf() */ +#include /* syscall() */ +#include /* __NR_capget */ +#include /* _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 + +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 index 0000000000..74c030f6ac --- /dev/null +++ b/memcheck/tests/linux-capget.stderr.exp @@ -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 index 0000000000..acce6abcf1 --- /dev/null +++ b/memcheck/tests/linux-capget.vgtest @@ -0,0 +1,2 @@ +prog: linux-capget +stderr_filter: filter_allocs