Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions tests/by-util/test_tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,6 @@ fn test_readonly() {
assert_eq!(at.read(writable_file), content_tee);
}

#[test]
#[cfg(target_os = "linux")]
fn test_tee_no_more_writeable_2() {
// should be equals to 'tee out1 out2 >/dev/full <multi_read' call
// but currently there is no way to redirect stdout to /dev/full
// so this test is disabled
let (_at, mut ucmd) = at_and_ucmd!();
let _content = (1..=10).fold(String::new(), |mut output, x| {
let _ = writeln!(output, "{x}");
output
});
let file_out_a = "tee_file_out_a";
let file_out_b = "tee_file_out_b";

let _result = ucmd
.arg(file_out_a)
.arg(file_out_b)
.pipe_in("/dev/full")
.succeeds(); // TODO: expected to succeed currently; change to fails() when required

// TODO: comment in after https://github.com/uutils/coreutils/issues/1805 is fixed
// assert_eq!(at.read(file_out_a), content);
// assert_eq!(at.read(file_out_b), content);
// assert!(result.stderr.contains("No space left on device"));
}

#[cfg(target_os = "linux")]
mod linux_only {
use uutests::util::{AtPath, CmdResult, TestScenario, UCommand};
Expand Down Expand Up @@ -581,4 +555,28 @@ mod linux_only {
expect_success(&output);
expect_correct(file_out_a, &at, content.as_str());
}

#[test]
fn test_tee_no_more_writeable_2() {
use std::fs::File;
let (at, mut ucmd) = at_and_ucmd!();
let content = (1..=10).fold(String::new(), |mut output, x| {
let _ = writeln!(output, "{x}");
output
});
let file_out_a = "tee_file_out_a";
let file_out_b = "tee_file_out_b";
let dev_full = File::options().append(true).open("/dev/full").unwrap();

let result = ucmd
.arg(file_out_a)
.arg(file_out_b)
.set_stdout(dev_full)
.pipe_in(content.as_bytes())
.fails();

assert_eq!(at.read(file_out_a), content);
assert_eq!(at.read(file_out_b), content);
assert!(result.stderr_str().contains("No space left on device"));
}
}
Loading