From c7b987e90a6d0b52b07e6b6f60f1f2295e12d7b6 Mon Sep 17 00:00:00 2001 From: utam0k Date: Thu, 21 Oct 2021 22:59:03 +0900 Subject: [PATCH] add a unit test for the failed case of fork. --- src/process/fork.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/process/fork.rs b/src/process/fork.rs index 14cec65cc..5ac1f32cc 100644 --- a/src/process/fork.rs +++ b/src/process/fork.rs @@ -41,4 +41,17 @@ mod test { _ => bail!("test failed"), } } + + #[test] + fn test_container_err_fork() -> Result<()> { + let pid = container_fork(|| bail!(""))?; + match waitpid(pid, None).expect("wait pid failed.") { + WaitStatus::Exited(p, status) => { + assert_eq!(pid, p); + assert_eq!(status, 255); + Ok(()) + } + _ => bail!("test failed"), + } + } }