2021-04-01 07:44:24 +00:00
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
2020-05-25 17:05:26 +00:00
|
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
2021-04-01 07:44:24 +00:00
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
2015-11-16 05:25:01 +00:00
|
|
|
|
#[test]
|
|
|
|
|
fn test_stdbuf_unbuffered_stdout() {
|
2021-04-01 07:44:24 +00:00
|
|
|
|
// This is a basic smoke test
|
|
|
|
|
new_ucmd!()
|
|
|
|
|
.args(&["-o0", "head"])
|
|
|
|
|
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
|
|
|
|
.run()
|
|
|
|
|
.stdout_is("The quick brown fox jumps over the lazy dog.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_stdbuf_line_buffered_stdout() {
|
|
|
|
|
new_ucmd!()
|
|
|
|
|
.args(&["-oL", "head"])
|
|
|
|
|
.pipe_in("The quick brown fox jumps over the lazy dog.")
|
|
|
|
|
.run()
|
|
|
|
|
.stdout_is("The quick brown fox jumps over the lazy dog.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_stdbuf_no_buffer_option_fails() {
|
2021-04-17 08:07:45 +00:00
|
|
|
|
new_ucmd!().args(&["head"]).fails().stderr_is(
|
2021-05-26 00:07:49 +00:00
|
|
|
|
"error: The following required arguments were not provided:\n \
|
2021-05-22 22:13:53 +00:00
|
|
|
|
--error <MODE>\n \
|
|
|
|
|
--input <MODE>\n \
|
|
|
|
|
--output <MODE>\n\n\
|
|
|
|
|
USAGE:\n \
|
|
|
|
|
stdbuf OPTION... COMMAND\n\n\
|
|
|
|
|
For more information try --help",
|
2021-04-17 08:07:45 +00:00
|
|
|
|
);
|
2021-04-01 07:44:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_stdbuf_trailing_var_arg() {
|
|
|
|
|
new_ucmd!()
|
|
|
|
|
.args(&["-i", "1024", "tail", "-1"])
|
|
|
|
|
.pipe_in("The quick brown fox\njumps over the lazy dog.")
|
|
|
|
|
.run()
|
|
|
|
|
.stdout_is("jumps over the lazy dog.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_stdbuf_line_buffering_stdin_fails() {
|
2021-05-25 23:45:53 +00:00
|
|
|
|
new_ucmd!().args(&["-i", "L", "head"]).fails().stderr_is(
|
|
|
|
|
"stdbuf: line buffering stdin is meaningless\nTry 'stdbuf --help' for more information.",
|
|
|
|
|
);
|
2021-04-01 07:44:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[cfg(not(target_os = "windows"))]
|
|
|
|
|
#[test]
|
|
|
|
|
fn test_stdbuf_invalid_mode_fails() {
|
2021-05-31 07:35:46 +00:00
|
|
|
|
// TODO: GNU's `stdbuf` (8.32) does not return "\nTry 'stdbuf --help' for more information."
|
|
|
|
|
// for invalid modes.
|
2021-04-01 07:44:24 +00:00
|
|
|
|
new_ucmd!()
|
|
|
|
|
.args(&["-i", "1024R", "head"])
|
|
|
|
|
.fails()
|
2021-05-31 07:35:46 +00:00
|
|
|
|
.stderr_contains("stdbuf: invalid mode ‘1024R’");
|
|
|
|
|
#[cfg(not(target_pointer_width = "128"))]
|
|
|
|
|
new_ucmd!()
|
|
|
|
|
.args(&["--error", "1Y", "head"])
|
|
|
|
|
.fails()
|
|
|
|
|
.stderr_contains("stdbuf: invalid mode ‘1Y’: Value too large to be stored in data type");
|
2015-11-16 05:25:01 +00:00
|
|
|
|
}
|