pub struct SetupCore {
pub ds: DirSubst,
pub mgmt_conn: RefCell<MgmtChannelForGame>,
- server_child: Child,
+ pub server_child: Child,
pub wanted_tests: TrackWantedTests,
pub cln: cleanup_notify::Handle,
}
(mgmt_conn, child)
}
+impl SetupCore {
+ #[throws(AE)]
+ pub fn restart_gameserver(&mut self) {
+ let (mgmt_conn, child) = start_gameserver(&self.cln, &self.ds)?;
+ self.mgmt_conn = RefCell::new(mgmt_conn);
+ self.server_child = child;
+ }
+}
+
// ---------- game spec ----------
#[derive(Copy,Clone,Error,Debug)]
let st = Command::new("cmp").args(&[&bundle_file, "00000.zip"]).status()?;
if ! st.success() { panic!("cmp failed {}", st) }
}
+
+ #[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()?;
+ }
+ let alice = self.connect_player(&self.alice)?;
+ let pieces = alice.pieces::<PIA>()?;
+ dbgc!(pieces);
+ }
}
#[throws(Explode)]
test!(c, "specs", c.chdir_root(|c| c.specs() ));
test!(c, "put-back", c.put_back() ?);
test!(c, "bundles", c.bundles() ?);
+ test!(c, "save-load", c.save_load() ?);
}
#[throws(Explode)]
pub use std::os::unix::ffi::OsStrExt;
pub use std::os::unix::io::IntoRawFd;
pub use std::os::unix::net::UnixStream;
-pub use std::os::unix::process::CommandExt;
+pub use std::os::unix::process::{CommandExt, ExitStatusExt};
pub use std::path::PathBuf;
pub use std::process::{exit, Child, Command, Stdio};
pub use std::str;