|
2 | 2 | // |
3 | 3 | // For the full copyright and license information, please view the LICENSE |
4 | 4 | // 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 |
| 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 |
6 | 6 |
|
7 | 7 | use uutests::at_and_ucmd; |
8 | 8 | use uutests::new_ucmd; |
@@ -1840,3 +1840,52 @@ fn test_skip_overflow() { |
1840 | 1840 | "dd: invalid number: ‘9223372036854775808’: Value too large for defined data type", |
1841 | 1841 | ); |
1842 | 1842 | } |
| 1843 | + |
| 1844 | +#[test] |
| 1845 | +#[cfg(target_os = "linux")] |
| 1846 | +fn test_nocache_eof() { |
| 1847 | + let (at, mut ucmd) = at_and_ucmd!(); |
| 1848 | + at.write_bytes("in.f", &vec![0u8; 1234567]); |
| 1849 | + ucmd.args(&[ |
| 1850 | + "if=in.f", |
| 1851 | + "of=out.f", |
| 1852 | + "bs=1M", |
| 1853 | + "oflag=nocache,sync", |
| 1854 | + "status=noxfer", |
| 1855 | + ]) |
| 1856 | + .succeeds(); |
| 1857 | + assert_eq!(at.read_bytes("out.f").len(), 1234567); |
| 1858 | +} |
| 1859 | + |
| 1860 | +#[test] |
| 1861 | +#[cfg(all(target_os = "linux", feature = "printf"))] |
| 1862 | +fn test_nocache_eof_fadvise_zero_length() { |
| 1863 | + use std::process::Command; |
| 1864 | + let (at, _ucmd) = at_and_ucmd!(); |
| 1865 | + at.write_bytes("in.f", &vec![0u8; 1234567]); |
| 1866 | + |
| 1867 | + let strace_file = at.plus_as_string("strace.out"); |
| 1868 | + let result = Command::new("strace") |
| 1869 | + .args(["-o", &strace_file, "-e", "fadvise64,fadvise64_64"]) |
| 1870 | + .arg(get_tests_binary()) |
| 1871 | + .args([ |
| 1872 | + "dd", |
| 1873 | + "if=in.f", |
| 1874 | + "of=out.f", |
| 1875 | + "bs=1M", |
| 1876 | + "oflag=nocache,sync", |
| 1877 | + "status=none", |
| 1878 | + ]) |
| 1879 | + .current_dir(at.as_string()) |
| 1880 | + .output(); |
| 1881 | + |
| 1882 | + if result.is_err() { |
| 1883 | + return; // strace not available |
| 1884 | + } |
| 1885 | + |
| 1886 | + let strace = at.read("strace.out"); |
| 1887 | + assert!( |
| 1888 | + strace.contains(", 0, POSIX_FADV_DONTNEED"), |
| 1889 | + "Expected len=0 at EOF: {strace}" |
| 1890 | + ); |
| 1891 | +} |
0 commit comments