]> granicus.if.org Git - strace/commitdiff
tests: extend coverage of capget syscall
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 6 Feb 2016 01:40:09 +0000 (01:40 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 8 Feb 2016 18:21:10 +0000 (18:21 +0000)
* tests/caps.c (main): Check decoding of inaccessible cap_user_header_t
and/or cap_user_data_t.
* tests/caps.awk: Update match patterns.
* tests/caps.test: Update.

tests/caps.awk
tests/caps.c
tests/caps.test

index bad8b0f3a4cbaf56d107bd290c81d4865e5a55ce..ecf1a28227858b2893fab7f6f11fc26628da723f 100644 (file)
@@ -1,6 +1,8 @@
 #!/bin/gawk
 #
-# Copyright (c) 2014-2015 Dmitry V. Levin <ldv@altlinux.org>
+# This file is part of caps strace test.
+#
+# Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
 # All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 
 BEGIN {
        cap = "(0|CAP_[A-Z_]+(\\|CAP_[A-Z_]+)*|CAP_[A-Z_]+(\\|CAP_[A-Z_]+){37}\\|0xffffffc0)"
-       r[1] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$"
+       s_efault = "-1 EFAULT (Bad address)"
+       r_efault = "-1 EFAULT \\(Bad address\\)"
+       r_addr = "0x[[:xdigit:]]+"
+       s[1] = "capget(NULL, NULL) = " s_efault
+       r[2] = "^capget\\(" r_addr ", " r_addr "\\) = " r_efault
+       r[3] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, " r_addr "\\) = " r_efault
+       r[4] = "^capget\\(\\{_LINUX_CAPABILITY_VERSION_3, 0\\}, \\{" cap ", " cap ", " cap "\\}\\) = 0$"
        capset_data = "{CAP_DAC_OVERRIDE|CAP_WAKE_ALARM, CAP_DAC_READ_SEARCH|CAP_BLOCK_SUSPEND, 0}"
-       s[2] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)"
-       s[3] = "+++ exited with 0 +++"
+       s[5] = "capset({_LINUX_CAPABILITY_VERSION_3, 0}, " capset_data ") = -1 EPERM (Operation not permitted)"
+       s[6] = "+++ exited with 0 +++"
 
-       lines = 3
+       lines = 6
        fail = 0
 }
 
index 2aca86258a1170576d75fc3723fef60e943210d4..17e10777f2951028411fe1f4f1a312193b1f133e 100644 (file)
@@ -1,4 +1,6 @@
 /*
+ * This file is part of caps strace test.
+ *
  * Copyright (c) 2014-2016 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
@@ -27,6 +29,7 @@
 
 #include "tests.h"
 #include <errno.h>
+#include <string.h>
 
 extern int capget(int *, int *);
 extern int capset(int *, const int *);
@@ -34,15 +37,24 @@ extern int capset(int *, const int *);
 int
 main(void)
 {
-       int unused[6];
        const int data[] = { 2, 4, 0, 8, 16, 0 };
        const int v3 = 0x20080522;
-       int head[] = { v3, 0 };
 
-       if (capget(head, unused))
+       int * const head = tail_alloc(sizeof(int) * 2);
+       head[0] = v3;
+       head[1] = 0;
+       int * const tail_data = tail_alloc(sizeof(data));
+
+       capget(NULL, NULL);
+       capget(head + 2, tail_data);
+       capget(head, tail_data + ARRAY_SIZE(data));
+
+       if (capget(head, tail_data))
                perror_msg_and_skip("capget");
        if (head[0] != v3)
                error_msg_and_skip("capget: v3 expected");
+
+       memcpy(tail_data, data, sizeof(data));
        if (capset(head, data) == 0 || errno != EPERM)
                perror_msg_and_skip("capset");
 
index 9437a4ba3197569646b3a16ff1850d035a11d49e..607a75bbca5217e90cb51185e51da3ff270c8e6b 100755 (executable)
@@ -5,7 +5,7 @@
 . "${srcdir=.}/init.sh"
 
 run_prog
-run_strace -e trace=capget,capset $args
+run_strace -a 19 -e trace=capget,capset $args
 match_awk
 
 exit 0