From: Ian Jackson Date: Tue, 18 May 2021 00:34:13 +0000 (+0100) Subject: apitest: Break out stop_and_restart_gameserver X-Git-Tag: otter-0.6.0~166 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=f0b235383a23036b11fdd506ac0e03c19c345f33;p=otter.git apitest: Break out stop_and_restart_gameserver This will be for the bundle save/load test. Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index b8b306c2..46e6016a 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -192,15 +192,7 @@ impl Ctx { #[throws(Explode)] fn save_load(&mut self) { - { - let mut su = self.su_rc.borrow_mut(); - let old_pid = su.server_child.id() as nix::libc::pid_t; - nix::sys::signal::kill(nix::unistd::Pid::from_raw(old_pid), - nix::sys::signal::SIGTERM)?; - let st = dbgc!(su.server_child.wait()?); - assert_eq!(st.signal(), Some(nix::sys::signal::SIGTERM as i32)); - su.restart_gameserver()?; - } + self.stop_and_restart_server()?; let alice = self.connect_player(&self.alice)?; let pieces = alice.pieces::()?; dbgc!(pieces); diff --git a/apitest/main.rs b/apitest/main.rs index 97e43fad..7b726996 100644 --- a/apitest/main.rs +++ b/apitest/main.rs @@ -551,6 +551,17 @@ impl UsualCtx { dbgc!(&added); added } + + #[throws(Explode)] + fn stop_and_restart_server(&mut self) { + let mut su = self.su_rc.borrow_mut(); + let old_pid = su.server_child.id() as nix::libc::pid_t; + nix::sys::signal::kill(nix::unistd::Pid::from_raw(old_pid), + nix::sys::signal::SIGTERM)?; + let st = dbgc!(su.server_child.wait()?); + assert_eq!(st.signal(), Some(nix::sys::signal::SIGTERM as i32)); + su.restart_gameserver()?; + } } impl UsualCtx {