agent: fix fd-double-close problem in ut test_do_write_stream

The fd will closed on struct Process's dropping, so don't
close it again manually.

Fixes: #4598

Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
Tim Zhang 2022-07-21 19:37:15 +08:00
parent ac91fb7a12
commit 912641509e

View File

@ -2262,6 +2262,7 @@ mod tests {
if d.has_fd { if d.has_fd {
Some(wfd) Some(wfd)
} else { } else {
unistd::close(wfd).unwrap();
None None
} }
}; };
@ -2296,13 +2297,14 @@ mod tests {
if !d.break_pipe { if !d.break_pipe {
unistd::close(rfd).unwrap(); unistd::close(rfd).unwrap();
} }
unistd::close(wfd).unwrap(); // XXX: Do not close wfd.
// the fd will be closed on Process's dropping.
// unistd::close(wfd).unwrap();
let msg = format!("{}, result: {:?}", msg, result); let msg = format!("{}, result: {:?}", msg, result);
assert_result!(d.result, result, msg); assert_result!(d.result, result, msg);
} }
} }
#[tokio::test] #[tokio::test]
async fn test_update_container_namespaces() { async fn test_update_container_namespaces() {
#[derive(Debug)] #[derive(Debug)]