2021-02-23 09:21:01 +00:00
|
|
|
use crate::common::util::*;
|
|
|
|
|
|
|
|
// FIXME: this depends on the system having true and false in PATH
|
|
|
|
// the best solution is probably to generate some test binaries that we can call for any
|
|
|
|
// utility that requires executing another program (kill, for instance)
|
|
|
|
#[test]
|
2021-05-30 05:10:54 +00:00
|
|
|
fn test_subcommand_return_code() {
|
2021-03-13 22:30:32 +00:00
|
|
|
new_ucmd!().arg("1").arg("true").succeeds();
|
2021-02-23 09:21:01 +00:00
|
|
|
|
2021-03-13 22:30:32 +00:00
|
|
|
new_ucmd!().arg("1").arg("false").run().status_code(1);
|
2021-02-23 09:21:01 +00:00
|
|
|
}
|
2021-06-10 14:59:06 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_command_with_args() {
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&["1700", "echo", "-n", "abcd"])
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only("abcd");
|
|
|
|
}
|
2021-06-10 16:34:05 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_verbose() {
|
|
|
|
for &verbose_flag in &["-v", "--verbose"] {
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&[verbose_flag, ".1", "sleep", "10"])
|
|
|
|
.fails()
|
|
|
|
.stderr_only("timeout: sending signal TERM to command 'sleep'");
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&[verbose_flag, "-s0", "-k.1", ".1", "sleep", "10"])
|
|
|
|
.fails()
|
|
|
|
.stderr_only("timeout: sending signal EXIT to command 'sleep'\ntimeout: sending signal KILL to command 'sleep'");
|
|
|
|
}
|
|
|
|
}
|
2021-06-10 16:51:41 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_zero_timeout() {
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-v", "0", "sleep", ".1"])
|
|
|
|
.succeeds()
|
|
|
|
.no_stderr()
|
|
|
|
.no_stdout();
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-v", "0", "-s0", "-k0", "sleep", ".1"])
|
|
|
|
.succeeds()
|
|
|
|
.no_stderr()
|
|
|
|
.no_stdout();
|
|
|
|
}
|