1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 03:36:18 +00:00

Merge pull request #3498 from jhscheer/fix_stat_redirect

stat: improve handling of stdin/fifo (fix #3485)
This commit is contained in:
Sylvestre Ledru 2022-05-12 08:35:43 +02:00 committed by GitHub
commit 6a9a7d76fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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")