()
| 452 | |
| 453 | #[test] |
| 454 | fn test_command_with_timeout() { |
| 455 | let mut cmd = QoveryCommand::new("sleep", &["120"], &[]); |
| 456 | let ret = cmd.exec_with_abort(&mut |_| {}, &mut |_| {}, &CommandKiller::from_timeout(Duration::from_secs(2))); |
| 457 | |
| 458 | assert!(matches!(ret, Err(CommandError::TimeoutError(_)))); |
| 459 | |
| 460 | let mut cmd = QoveryCommand::new("sh", &["-c", "cat /dev/urandom | grep -a --null-data ."], &[]); |
| 461 | cmd.kill_grace_period = Duration::from_secs(2); |
| 462 | let ret = cmd.exec_with_abort(&mut |_| {}, &mut |_| {}, &CommandKiller::from_timeout(Duration::from_secs(2))); |
| 463 | |
| 464 | assert!(matches!(ret, Err(CommandError::TimeoutError(_)))); |
| 465 | |
| 466 | let mut cmd = QoveryCommand::new("sleep", &["1"], &[]); |
| 467 | let ret = cmd.exec_with_abort(&mut |_| {}, &mut |_| {}, &CommandKiller::from_timeout(Duration::from_secs(2))); |
| 468 | assert!(ret.is_ok()); |
| 469 | } |
| 470 | |
| 471 | #[test] |
| 472 | fn test_command_with_abort() { |
nothing calls this directly
no test coverage detected