~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/dd/nocache

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Ensure dd handles the 'nocache' flag
3
 
 
4
 
# Copyright (C) 2011 Free Software Foundation, Inc.
5
 
 
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.
10
 
 
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.
15
 
 
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/>.
18
 
 
19
 
. "${srcdir=.}/init.sh"; path_prepend_ ../src
20
 
print_ver_ dd
21
 
 
22
 
# This should not call posix_fadvise
23
 
dd iflag=nocache oflag=nocache if=/dev/null of=/dev/null || fail=1
24
 
 
25
 
# We should get an error for trying to process a pipe
26
 
dd count=0 | dd iflag=nocache count=0 && fail=1
27
 
 
28
 
# O_DIRECT is orthogonal to drop cache so mutually exclusive
29
 
dd iflag=nocache,direct if=/dev/null && fail=1
30
 
 
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
36
 
 
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
45
 
fi
46
 
 
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
50
 
 
51
 
  # Drop cache for part of file
52
 
  dd if=ifile iflag=nocache skip=10 count=10 of=/dev/null || fail=1
53
 
 
54
 
  # Stream data just using readahead cache
55
 
  dd if=ifile of=ofile iflag=nocache oflag=nocache || fail=1
56
 
fi
57
 
 
58
 
Exit $fail