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

dd: implement iseek + oseek flags

These are the first half of changes needed to pass the dd/bytes.sh tests:
- Add iseek and oseek options (additive with skip and seek options)
- Implement tests for the new flags, matching those from dd/bytes.sh
This commit is contained in:
chordtoll 2022-03-13 14:39:10 -07:00 committed by Sylvestre Ledru
parent 8c36558871
commit b77b3cba55
7 changed files with 170 additions and 9 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 nabcde nabcdefg abcdefg
// 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, iseek, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, oseek, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm abcdefghi nabcde nabcdefg abcdefg
use crate::common::util::*;
@ -1139,3 +1139,48 @@ fn test_block_sync() {
.stdout_is("012 abcde ")
.stderr_is("2+1 records in\n0+1 records out\n1 truncated record\n");
}
#[test]
fn test_bytes_count_bytes_iflag() {
new_ucmd!()
.args(&["conv=swab", "count=14", "iflag=count_bytes"])
.pipe_in("0123456789abcdefghijklm")
.succeeds()
.stdout_is("1032547698badc");
}
#[test]
fn test_bytes_skip_bytes_iflag() {
new_ucmd!()
.args(&["skip=10", "iflag=skip_bytes"])
.pipe_in("0123456789abcdefghijklm")
.succeeds()
.stdout_is("abcdefghijklm");
}
#[test]
fn test_bytes_skip_bytes_pipe_iflag() {
new_ucmd!()
.args(&["skip=10", "iflag=skip_bytes", "bs=2"])
.pipe_in("0123456789abcdefghijklm")
.succeeds()
.stdout_is("abcdefghijklm");
}
#[test]
fn test_bytes_oseek_bytes_oflag() {
new_ucmd!()
.args(&["seek=8", "oflag=seek_bytes", "bs=2"])
.pipe_in("abcdefghijklm")
.succeeds()
.stdout_is_fixture_bytes("dd-bytes-alphabet-null.spec");
}
#[test]
fn test_bytes_oseek_bytes_trunc_oflag() {
new_ucmd!()
.args(&["seek=8", "oflag=seek_bytes", "bs=2", "count=0"])
.pipe_in("abcdefghijklm")
.succeeds()
.stdout_is_fixture_bytes("dd-bytes-null-trunc.spec");
}