| 299 | |
| 300 | #[test] |
| 301 | fn test_pid_is_exclusive() -> Result<()> { |
| 302 | let tempdir = TempDir::new()?; |
| 303 | let sdd = ServerDataDir(tempdir.path().to_path_buf()); |
| 304 | |
| 305 | let lock = sdd.pid_file()?; |
| 306 | |
| 307 | // Make sure we wrote the pid file. |
| 308 | let pidstring = fs::read_to_string(lock.path.clone())?; |
| 309 | let _pid = pidstring.trim().parse::<u32>()?; |
| 310 | |
| 311 | let attempt = sdd.pid_file(); |
| 312 | assert!(attempt.is_err()); |
| 313 | |
| 314 | drop(lock); |
| 315 | // Make sure it can be acquired now. |
| 316 | sdd.pid_file()?; |
| 317 | Ok(()) |
| 318 | } |
| 319 | |
| 320 | #[test] |
| 321 | fn test_snapshot_parsing() -> Result<()> { |