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

dd: Error message of invalid args is matched with GNU (#3831)

This commit is contained in:
Przemysław Fuchs 2022-08-17 11:40:42 +02:00 committed by GitHub
parent 9fad6fde35
commit 3acbd1c048
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 3 deletions

View file

@ -1187,3 +1187,62 @@ fn test_final_stats_si_iec() {
let s = result.stderr_str();
assert!(s.starts_with("2+0 records in\n2+0 records out\n1024 bytes (1 KB, 1024 B) copied,"));
}
#[test]
fn test_invalid_number_arg_gnu_compatibility() {
let commands = vec!["bs", "cbs", "count", "ibs", "obs", "seek", "skip"];
for command in commands {
new_ucmd!()
.args(&[format!("{}=", command)])
.fails()
.stderr_is("dd: invalid number: ");
new_ucmd!()
.args(&[format!("{}=29d", command)])
.fails()
.stderr_is("dd: invalid number: 29d");
}
}
#[test]
fn test_invalid_flag_arg_gnu_compatibility() {
let commands = vec!["iflag", "oflag"];
for command in commands {
new_ucmd!()
.args(&[format!("{}=", command)])
.fails()
.stderr_is("dd: invalid input flag: \nTry 'dd --help' for more information.");
new_ucmd!()
.args(&[format!("{}=29d", command)])
.fails()
.stderr_is("dd: invalid input flag: 29d\nTry 'dd --help' for more information.");
}
}
#[test]
fn test_invalid_file_arg_gnu_compatibility() {
new_ucmd!()
.args(&["if="])
.fails()
.stderr_is("dd: failed to open '': No such file or directory");
new_ucmd!()
.args(&["if=81as9bn8as9g302az8ns9.pdf.zip.pl.com"])
.fails()
.stderr_is(
"dd: failed to open '81as9bn8as9g302az8ns9.pdf.zip.pl.com': No such file or directory",
);
new_ucmd!()
.args(&["of="])
.fails()
.stderr_is("dd: failed to open '': No such file or directory");
new_ucmd!()
.args(&["of=81as9bn8as9g302az8ns9.pdf.zip.pl.com"])
.pipe_in("")
.succeeds();
}