tests: correct reversed args to "compare"
[coreutils.git] / tests / dd / nocache
blob274bb8a0358b2db4d0a321f171b029a86eabc9ed
1 #!/bin/sh
2 # Ensure dd handles the 'nocache' flag
4 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../src
20 print_ver_ dd
22 # This should not call posix_fadvise
23 dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1
25 # We should get an error for trying to process a pipe
26 dd count=0 | dd iflag=nocache count=0 && fail=1
28 # O_DIRECT is orthogonal to drop cache so mutually exclusive
29 dd iflag=nocache,direct if=/dev/null && fail=1
31 # The rest ensure that the documented uses cases
32 # proceed without error
33 for f in ifile ofile; do
34 dd if=/dev/zero of=$f conv=fdatasync count=100 || framework_failure_
35 done
37 # Advise to drop cache for whole file
38 if ! dd if=ifile iflag=nocache count=0 2>err; then
39 # We could check for 'Operation not supported' in err here,
40 # but that was seen to be brittle. HPUX returns ENOTTY for example.
41 # So assume that if this basic operation fails, it's due to lack
42 # of support by the system.
43 warn_ 'skipping part; this file system lacks support for posix_fadvise()'
44 skip=1
47 if test "$skip" != 1; then
48 # Ensure drop cache for whole file
49 dd of=ofile oflag=nocache conv=notrunc,fdatasync count=0 || fail=1
51 # Drop cache for part of file
52 dd if=ifile iflag=nocache skip=10 count=10 of=/dev/null || fail=1
54 # Stream data just using readahead cache
55 dd if=ifile of=ofile iflag=nocache oflag=nocache || fail=1
58 Exit $fail