summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2017-07-19 05:32:22 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2017-07-19 05:32:22 +0000
commit3d24ae9588ebad1e495bedc909a226c84662a4c2 (patch)
tree7bf90108d9ade894cdcfb250e2ea93df7ae6f9f5 /test
parent3acc24c1093bf38424c0f0348b71b08b337fbec6 (diff)
parentbba9e436393e3606bfe19a2a1d40c849a9242f4a (diff)
downloadnix-3d24ae9588ebad1e495bedc909a226c84662a4c2.zip
Merge #686
686: Fix special ptraces r=Susurrus In #614 we added specializations of `ptrace()` that added more type safety. As part of this, the `UnsupportedOperation` error was introduced for the requests that are covered by specialized versions so they couldn't be used with the general `ptrace()`. Unfortunately, no tests were added with this PR and so it slipped through that you could not do those operations at all anymore: `ptrace()` reported `UnsupportedOperation` for them and `ptrace_*` called `ptrace`, not `ffi::ptrace` and so also reported `UnsupportedOperation`! Whoops! This minimally-invasive surgery corrects this by adding tests that call all the specialized `ptrace_*` ignoring the return value save checking for `UnsupportedOperation`. It also changes the functions calls to use `ffi::ptrace()` directly to fix the bug. As this was never a bug in a released version of `nix`, there's no need for a changelog entry here.
Diffstat (limited to 'test')
-rw-r--r--test/sys/test_ptrace.rs36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/sys/test_ptrace.rs b/test/sys/test_ptrace.rs
index 6318495a..57b452cb 100644
--- a/test/sys/test_ptrace.rs
+++ b/test/sys/test_ptrace.rs
@@ -3,7 +3,8 @@ use nix::errno::*;
use nix::unistd::*;
use nix::sys::ptrace::*;
use nix::sys::ptrace::ptrace::*;
-use std::ptr;
+
+use std::{mem, ptr};
#[test]
fn test_ptrace() {
@@ -12,3 +13,36 @@ fn test_ptrace() {
let err = ptrace(PTRACE_ATTACH, getpid(), ptr::null_mut(), ptr::null_mut()).unwrap_err();
assert!(err == Error::Sys(Errno::EPERM) || err == Error::Sys(Errno::ENOSYS));
}
+
+// Just make sure ptrace_setoptions can be called at all, for now.
+#[test]
+fn test_ptrace_setoptions() {
+ let err = ptrace_setoptions(getpid(), PTRACE_O_TRACESYSGOOD).unwrap_err();
+ assert!(err != Error::UnsupportedOperation);
+}
+
+// Just make sure ptrace_getevent can be called at all, for now.
+#[test]
+fn test_ptrace_getevent() {
+ let err = ptrace_getevent(getpid()).unwrap_err();
+ assert!(err != Error::UnsupportedOperation);
+}
+
+// Just make sure ptrace_getsiginfo can be called at all, for now.
+#[test]
+fn test_ptrace_getsiginfo() {
+ match ptrace_getsiginfo(getpid()) {
+ Err(Error::UnsupportedOperation) => panic!("ptrace_getsiginfo returns Error::UnsupportedOperation!"),
+ _ => (),
+ }
+}
+
+// Just make sure ptrace_setsiginfo can be called at all, for now.
+#[test]
+fn test_ptrace_setsiginfo() {
+ let siginfo = unsafe { mem::uninitialized() };
+ match ptrace_setsiginfo(getpid(), &siginfo) {
+ Err(Error::UnsupportedOperation) => panic!("ptrace_setsiginfo returns Error::UnsupportedOperation!"),
+ _ => (),
+ }
+}