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

du: show error for nul names with --files0-from

This commit is contained in:
Daniel Hofstetter 2024-01-02 16:06:41 +01:00
parent 2a81c91f52
commit 239e5426e6
2 changed files with 38 additions and 4 deletions

View file

@ -1010,6 +1010,24 @@ fn test_du_files0_from() {
.stdout_contains("testdir");
}
#[test]
fn test_du_files0_from_with_invalid_zero_length_file_names() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
at.touch("testfile");
at.write("filelist", "\0testfile\0\0");
ts.ucmd()
.arg("--files0-from=filelist")
.fails()
.code_is(1)
.stdout_contains("testfile")
.stderr_contains("filelist:1: invalid zero-length file name")
.stderr_contains("filelist:3: invalid zero-length file name");
}
#[test]
fn test_du_files0_from_stdin() {
let ts = TestScenario::new(util_name!());
@ -1028,6 +1046,17 @@ fn test_du_files0_from_stdin() {
.stdout_contains("testfile2");
}
#[test]
fn test_du_files0_from_stdin_with_invalid_zero_length_file_names() {
new_ucmd!()
.arg("--files0-from=-")
.pipe_in("\0\0")
.fails()
.code_is(1)
.stderr_contains("-:1: invalid zero-length file name")
.stderr_contains("-:2: invalid zero-length file name");
}
#[test]
fn test_du_files0_from_dir() {
let ts = TestScenario::new(util_name!());