Verified Commit 0985142b authored by jD91mZM2's avatar jD91mZM2
Browse files

Add missing wait in ptrace test

parent 79ca7e88
......@@ -5,7 +5,7 @@ name = "acid"
version = "0.1.0"
dependencies = [
"redox_syscall 0.1.56 (git+https://gitlab.redox-os.org/redox-os/syscall.git)",
"strace 0.1.0 (git+https://gitlab.redox-os.org/redox-os/strace-redox)",
"strace 0.1.0",
"x86 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
......@@ -241,7 +241,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "strace"
version = "0.1.0"
source = "git+https://gitlab.redox-os.org/redox-os/strace-redox#d9ac25ad730fdb1c1810cd69b00df59dddb60f3f"
dependencies = [
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.56 (git+https://gitlab.redox-os.org/redox-os/syscall.git)",
......@@ -308,7 +307,6 @@ dependencies = [
"checksum serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c97b18e9e53de541f11e497357d6c5eaeb39f0cb9c8734e274abe4935f6991fa"
"checksum serde_json 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b5aaee47e038bf9552d30380d3973fff2593ee0a76d81ad4c581f267cdcadf36"
"checksum siphasher 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac"
"checksum strace 0.1.0 (git+https://gitlab.redox-os.org/redox-os/strace-redox)" = "<none>"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
......
......@@ -7,4 +7,5 @@ edition = "2018"
[dependencies]
x86 = "0.7"
redox_syscall = { git = "https://gitlab.redox-os.org/redox-os/syscall.git" }
strace = { git = "https://gitlab.redox-os.org/redox-os/strace-redox", default-features = false }
strace = { git = "https://gitlab.redox-os.org/redox-os/strace-redox", branch = "wip", default-features = false }
#strace = { path = "../../strace/source", default-features = false }
......@@ -56,7 +56,7 @@ fn page_fault_test() -> Result<(), String> {
pub fn ptrace() -> Result<(), String> {
use std::{
fs::{File, OpenOptions},
io,
io::{self, prelude::*},
mem,
os::unix::{
fs::OpenOptionsExt,
......@@ -329,7 +329,6 @@ pub fn ptrace() -> Result<(), String> {
ref e => return Err(format!("Wrong event type: {:?}", e))
};
e(handler.retry())?;
let event = e(e(handler.pop_one())?.ok_or("Expected event but none occured"))?;
assert_eq!(event.cause, Flags::STOP_POST_SYSCALL);
assert_eq!(e(tracer.regs.get_int())?.rax, clone_pid);
......@@ -356,7 +355,6 @@ pub fn ptrace() -> Result<(), String> {
},
ref e => return Err(format!("Wrong event type: {:?}", e))
}
e(handler.retry())?;
e(e(handler.pop_one())?.ok_or("Expected event but none occured"))?;
println!("Testing signals");
......@@ -411,11 +409,23 @@ pub fn ptrace() -> Result<(), String> {
println!("Testing behavior of obsolete breakpoints...");
e(tracer.next(Flags::STOP_PRE_SYSCALL | Flags::STOP_POST_SYSCALL))?;
e(tracer.next(Flags::empty()))?;
// also, we're nonblocking, can't wait for next event like that
assert_eq!(e(tracer.events())?.next().unwrap().unwrap_err().kind(), io::ErrorKind::WouldBlock);
println!("Tracee RAX: {}", e(tracer.regs.get_int())?.rax);
println!("Waiting for next signal from tracee that it's ready to be traced again...");
e(syscall::waitpid(pid, &mut status, syscall::WUNTRACED))?;
println!("Preparing event scheme");
let mut eventfd = e(File::open("event:"))?;
e(eventfd.write(&syscall::Event {
id: tracer.file.as_raw_fd() as usize,
flags: syscall::EVENT_READ,
data: 0,
}))?;
println!("Setting sysemu breakpoint...");
e(tracer.next(Flags::STOP_PRE_SYSCALL))?;
......@@ -427,11 +437,13 @@ pub fn ptrace() -> Result<(), String> {
println!("Tracee RAX: {}", e(tracer.regs.get_int())?.rax);
}
println!("Waiting... Five times... To make sure it doesn't get stuck forever...");
for _ in 0..5 {
e(tracer.next(Flags::FLAG_WAIT))?;
e(tracer.events())?.for_each(|_| ());
}
println!("Waiting using event scheme");
let mut event = syscall::Event::default();
e(eventfd.read(&mut event))?;
println!("Consuming events");
e(tracer.events())?.for_each(|_| ());
println!("Overriding GETPID call...");
let mut regs = e(tracer.regs.get_int())?;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment