@@ -12,6 +12,7 @@ use std::mem;
12
12
fn test_ptrace ( ) {
13
13
// Just make sure ptrace can be called at all, for now.
14
14
// FIXME: qemu-user doesn't implement ptrace on all arches, so permit ENOSYS
15
+ require_capability ! ( CAP_SYS_PTRACE ) ;
15
16
let err = ptrace:: attach ( getpid ( ) ) . unwrap_err ( ) ;
16
17
assert ! ( err == Error :: Sys ( Errno :: EPERM ) || err == Error :: Sys ( Errno :: EINVAL ) ||
17
18
err == Error :: Sys ( Errno :: ENOSYS ) ) ;
@@ -21,6 +22,7 @@ fn test_ptrace() {
21
22
#[ test]
22
23
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
23
24
fn test_ptrace_setoptions ( ) {
25
+ require_capability ! ( CAP_SYS_PTRACE ) ;
24
26
let err = ptrace:: setoptions ( getpid ( ) , Options :: PTRACE_O_TRACESYSGOOD ) . unwrap_err ( ) ;
25
27
assert ! ( err != Error :: UnsupportedOperation ) ;
26
28
}
@@ -29,6 +31,7 @@ fn test_ptrace_setoptions() {
29
31
#[ test]
30
32
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
31
33
fn test_ptrace_getevent ( ) {
34
+ require_capability ! ( CAP_SYS_PTRACE ) ;
32
35
let err = ptrace:: getevent ( getpid ( ) ) . unwrap_err ( ) ;
33
36
assert ! ( err != Error :: UnsupportedOperation ) ;
34
37
}
@@ -37,6 +40,7 @@ fn test_ptrace_getevent() {
37
40
#[ test]
38
41
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
39
42
fn test_ptrace_getsiginfo ( ) {
43
+ require_capability ! ( CAP_SYS_PTRACE ) ;
40
44
if let Err ( Error :: UnsupportedOperation ) = ptrace:: getsiginfo ( getpid ( ) ) {
41
45
panic ! ( "ptrace_getsiginfo returns Error::UnsupportedOperation!" ) ;
42
46
}
@@ -46,6 +50,7 @@ fn test_ptrace_getsiginfo() {
46
50
#[ test]
47
51
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
48
52
fn test_ptrace_setsiginfo ( ) {
53
+ require_capability ! ( CAP_SYS_PTRACE ) ;
49
54
let siginfo = unsafe { mem:: zeroed ( ) } ;
50
55
if let Err ( Error :: UnsupportedOperation ) = ptrace:: setsiginfo ( getpid ( ) , & siginfo) {
51
56
panic ! ( "ptrace_setsiginfo returns Error::UnsupportedOperation!" ) ;
@@ -61,6 +66,8 @@ fn test_ptrace_cont() {
61
66
use nix:: unistd:: fork;
62
67
use nix:: unistd:: ForkResult :: * ;
63
68
69
+ require_capability ! ( CAP_SYS_PTRACE ) ;
70
+
64
71
let _m = :: FORK_MTX . lock ( ) . expect ( "Mutex got poisoned by another test" ) ;
65
72
66
73
// FIXME: qemu-user doesn't implement ptrace on all architectures
0 commit comments