-
Notifications
You must be signed in to change notification settings - Fork 667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename the public ptrace_* functions. #692
Changes from 3 commits
b4f1749
3192df4
d5c4d0f
18b2bc1
8928a7d
1b9a779
a5b01c0
2fe5c2b
233a678
55a7d4b
caaffb8
82e0139
e4a1851
88dc19b
7b07847
3cf4cc6
571386b
d63c616
93b2929
085f47c
1c9e0ca
2a5b86d
b6ad298
845453b
903a52f
2288202
907bb98
a162ea2
745a4ab
4cefd53
536787e
283fb1c
f3167db
021e851
8beaea2
46191fd
a717003
ce60aa5
1844378
6583fd1
9cf8248
6ce39a6
bf93180
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
use nix::Error; | ||
use nix::errno::*; | ||
use nix::unistd::*; | ||
use nix::sys::ptrace::*; | ||
use nix::sys::ptrace::ptrace::*; | ||
use nix::sys::ptrace; | ||
|
||
use std::{mem, ptr}; | ||
|
||
#[test] | ||
fn test_ptrace() { | ||
use nix::sys::ptrace::ptrace::*; | ||
// Just make sure ptrace can be called at all, for now. | ||
// FIXME: qemu-user doesn't implement ptrace on all arches, so permit ENOSYS | ||
let err = ptrace(PTRACE_ATTACH, getpid(), ptr::null_mut(), ptr::null_mut()).unwrap_err(); | ||
let err = ptrace::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(); | ||
use nix::sys::ptrace::ptrace::*; // for PTRACE_O_TRACESYSGOOD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why aren't you just importing the single constant here then? No need to bulk import. Same for Man, we really need to get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I probably was too tired back then ;) Sorry, I'll fix that tomorrow. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And I totally agree about the enums |
||
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(); | ||
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()) { | ||
match ptrace::getsiginfo(getpid()) { | ||
Err(Error::UnsupportedOperation) => panic!("ptrace_getsiginfo returns Error::UnsupportedOperation!"), | ||
_ => (), | ||
} | ||
|
@@ -41,7 +42,7 @@ fn test_ptrace_getsiginfo() { | |
#[test] | ||
fn test_ptrace_setsiginfo() { | ||
let siginfo = unsafe { mem::uninitialized() }; | ||
match ptrace_setsiginfo(getpid(), &siginfo) { | ||
match ptrace::setsiginfo(getpid(), &siginfo) { | ||
Err(Error::UnsupportedOperation) => panic!("ptrace_setsiginfo returns Error::UnsupportedOperation!"), | ||
_ => (), | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no module-level documentation for the ptrace module, but it'd be good to add one showing an example usage that demonstrates the namespacing we recomment. We don't need it per-say, but it'd help users use this crate very easily. It'll also help us see where the imports aren't very ergonomic so we can improve them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add the documentation when I'm done with all the ptrace changes, ok?
Besides, I really think about splitting up #666 into a couple smaller PRs because I'm starting to lose control of the tests.