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

Merge pull request #3156 from jfinkels/dd-cbs-blocks

dd: pad partial record with spaces in some cases
This commit is contained in:
Sylvestre Ledru 2022-03-03 22:35:58 +01:00 committed by GitHub
commit 66e9956595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 21 deletions

View file

@ -1,4 +1,4 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg
use crate::common::util::*;
@ -1116,3 +1116,26 @@ fn test_truncated_record() {
fn test_outfile_dev_null() {
new_ucmd!().arg("of=/dev/null").succeeds().no_stdout();
}
#[test]
fn test_block_sync() {
new_ucmd!()
.args(&["ibs=5", "cbs=5", "conv=block,sync", "status=noxfer"])
.pipe_in("012\nabcde\n")
.succeeds()
// blocks: 1 2
.stdout_is("012 abcde")
.stderr_is("2+0 records in\n0+1 records out\n");
// It seems that a partial record in is represented as an
// all-spaces block at the end of the output. The "1 truncated
// record" line is present in the status report due to the line
// "abcdefg\n" being truncated to "abcde".
new_ucmd!()
.args(&["ibs=5", "cbs=5", "conv=block,sync", "status=noxfer"])
.pipe_in("012\nabcdefg\n")
.succeeds()
// blocks: 1 2 3
.stdout_is("012 abcde ")
.stderr_is("2+1 records in\n0+1 records out\n1 truncated record\n");
}