Skip to content

Commit ba0436b

Browse files
akretzromanstingler
authored andcommitted
dd: Add test to check for dropped writes
(cherry picked from commit 0f7c531)
1 parent c391af9 commit ba0436b

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

tests/by-util/test_dd.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5-
// 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 fifoname seekable fadvise FADV DONTNEED
5+
// 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 fifoname seekable
66

77
use uutests::at_and_ucmd;
88
use uutests::new_ucmd;
@@ -1781,6 +1781,41 @@ fn test_wrong_number_err_msg() {
17811781
.stderr_contains("dd: invalid number: '1kBb555'\n");
17821782
}
17831783

1784+
#[test]
1785+
#[cfg(all(
1786+
unix,
1787+
not(target_os = "macos"),
1788+
not(target_os = "freebsd"),
1789+
feature = "printf"
1790+
))]
1791+
fn test_no_dropped_writes() {
1792+
const BLK_SIZE: usize = 0x4000;
1793+
const COUNT: usize = 1000;
1794+
const NUM_BYTES: usize = BLK_SIZE * COUNT;
1795+
1796+
let mut reader_command = Command::new(get_tests_binary());
1797+
let child = reader_command
1798+
.args(&[
1799+
"dd",
1800+
"if=/dev/urandom",
1801+
&format!("bs={}", BLK_SIZE),
1802+
&format!("count={}", COUNT),
1803+
])
1804+
.stdout(Stdio::piped())
1805+
.stderr(Stdio::piped())
1806+
.env("LC_ALL", "C")
1807+
.spawn()
1808+
.unwrap();
1809+
1810+
let output = child.wait_with_output().unwrap();
1811+
assert_eq!(output.stdout.len(), NUM_BYTES);
1812+
assert!(
1813+
str::from_utf8(&output.stderr)
1814+
.unwrap()
1815+
.contains(&format!("{} bytes", NUM_BYTES))
1816+
);
1817+
}
1818+
17841819
#[test]
17851820
#[cfg(any(target_os = "linux", target_os = "android"))]
17861821
fn test_oflag_direct_partial_block() {

0 commit comments

Comments
 (0)