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

Merge branch 'main' into dd-skip-beyond-file

This commit is contained in:
Sylvestre Ledru 2022-02-08 20:46:07 +01:00 committed by GitHub
commit daaae90113
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 286 additions and 147 deletions

View file

@ -198,6 +198,39 @@ fn test_x_multiplier() {
.stdout_is("abcdef");
}
#[test]
fn test_zero_multiplier_warning() {
for arg in ["count", "seek", "skip"] {
new_ucmd!()
.args(&[format!("{}=00x1", arg).as_str(), "status=none"])
.pipe_in("")
.succeeds()
.no_stdout()
.no_stderr();
new_ucmd!()
.args(&[format!("{}=0x1", arg).as_str(), "status=none"])
.pipe_in("")
.succeeds()
.no_stdout()
.stderr_contains("warning: '0x' is a zero multiplier; use '00x' if that is intended");
new_ucmd!()
.args(&[format!("{}=0x0x1", arg).as_str(), "status=none"])
.pipe_in("")
.succeeds()
.no_stdout()
.stderr_is("dd: warning: '0x' is a zero multiplier; use '00x' if that is intended\ndd: warning: '0x' is a zero multiplier; use '00x' if that is intended\n");
new_ucmd!()
.args(&[format!("{}=1x0x1", arg).as_str(), "status=none"])
.pipe_in("")
.succeeds()
.no_stdout()
.stderr_contains("warning: '0x' is a zero multiplier; use '00x' if that is intended");
}
}
#[test]
fn test_final_stats_noxfer() {
new_ucmd!()
@ -637,5 +670,27 @@ fn test_skip_beyond_file() {
);
}
#[test]
fn test_seek_do_not_overwrite() {
let (at, mut ucmd) = at_and_ucmd!();
let mut outfile = at.make_file("outfile");
outfile.write_all(b"abc").unwrap();
// Skip the first byte of the input, seek past the first byte of
// the output, and write only one byte to the output.
ucmd.args(&[
"bs=1",
"skip=1",
"seek=1",
"count=1",
"status=noxfer",
"of=outfile",
])
.pipe_in("123")
.succeeds()
.stderr_is("1+0 records in\n1+0 records out\n")
.no_stdout();
assert_eq!(at.read("outfile"), "a2");
}
// conv=[ascii,ebcdic,ibm], conv=[ucase,lcase], conv=[block,unblock], conv=sync
// TODO: Move conv tests from unit test module