Skip to content

Create tests for ptrace #687

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

Open
xd009642 opened this issue Jul 18, 2017 · 2 comments
Open

Create tests for ptrace #687

xd009642 opened this issue Jul 18, 2017 · 2 comments

Comments

@xd009642
Copy link
Contributor

xd009642 commented Jul 18, 2017

Ptrace lacks proper tests, partially due to tests hanging due to calls to fork. Below I have some example test functionality I wrote to ensure that ptrace works, due to the fork this could cause a test to hang. (It also ignores the ptrace results which is less than optimal).

    #[test]
    fn ptrace_get_data_test() {
        match fork() {
            Ok(ForkResult::Parent{ child }) => {
                match waitpid(child, Some(__WALL))  {
                    Ok(WaitStatus::Stopped(child, _) )=> {
                        let r = ptrace_get_data::<user_regs_struct>(PTRACE_GETREGS, child);
                        println!("regs: {:#?}", r);
                        assert!(r.is_ok())
                        let _ = ptrace(PTRACE_CONT, child, ptr::null_mut(), ptr::null_mut());
                    },
                    _ => assert!(false),
	        }
            }
            Ok(ForkResult::Child) => {
	        let _ = ptrace(PTRACE_TRACEME, Pid::from_raw(0), ptr::null_mut(), ptr::null_mut());
                let _ = raise(Signal::SIGSTOP);
            }
            Err(err) => { 
                println!("Error {}", err);    
            }
        }
    }
@marmistrz
Copy link
Contributor

@xd009642 I think it would be a good idea to wait before merging it until #666 is merged. It's a big change and I'm adding safe, Rusty APIs for ptrace.

@xd009642
Copy link
Contributor Author

That's fine with me, I've only been planning what it may look like haven't yet put fingers to key 👍 Looking forward to #666

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants