1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

stat: improve handling of stdin/fifo (fix #3485)

* fix https://github.com/uutils/coreutils/issues/3485
* improve the workaround from #3280
* add tests
This commit is contained in:
Jan Scheer 2022-05-06 14:01:23 +02:00 committed by Sylvestre Ledru
parent 0ebd9c9391
commit d906f09e6e
3 changed files with 78 additions and 42 deletions

View file

@ -346,9 +346,21 @@ fn test_printf() {
ts.ucmd().args(&args).succeeds().stdout_is(expected_stdout);
}
#[cfg(unix)]
#[test]
#[cfg(disable_until_fixed)]
#[cfg(unix)]
fn test_pipe_fifo() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkfifo("FIFO");
ucmd.arg("FIFO")
.run()
.no_stderr()
.stdout_contains("fifo")
.stdout_contains("File: FIFO")
.succeeded();
}
#[test]
#[cfg(target_os = "linux")]
fn test_stdin_pipe_fifo1() {
// $ echo | stat -
// File: -
@ -362,17 +374,26 @@ fn test_stdin_pipe_fifo1() {
.stdout_contains("fifo")
.stdout_contains("File: -")
.succeeded();
new_ucmd!()
.args(&["-L", "-"])
.set_stdin(std::process::Stdio::piped())
.run()
.no_stderr()
.stdout_contains("fifo")
.stdout_contains("File: -")
.succeeded();
}
#[cfg(unix)]
#[test]
#[cfg(disable_until_fixed)]
#[cfg(target_os = "linux")]
fn test_stdin_pipe_fifo2() {
// $ stat -
// File: -
// Size: 0 Blocks: 0 IO Block: 1024 character special file
new_ucmd!()
.arg("-")
.set_stdin(std::process::Stdio::null())
.run()
.no_stderr()
.stdout_contains("character special file")
@ -380,9 +401,8 @@ fn test_stdin_pipe_fifo2() {
.succeeded();
}
#[cfg(unix)]
#[test]
#[cfg(disable_until_fixed)]
#[cfg(target_os = "linux")]
fn test_stdin_redirect() {
// $ touch f && stat - < f
// File: -
@ -393,7 +413,7 @@ fn test_stdin_redirect() {
at.touch("f");
new_ucmd!()
.arg("-")
.set_stdin(std::fs::File::open("f").unwrap())
.set_stdin(std::fs::File::open(at.plus("f")).unwrap())
.run()
.no_stderr()
.stdout_contains("regular empty file")