shred: enable direct I/O when possible
[coreutils.git] / tests / dd / bytes.sh
bloba2734536203ace6c5dd6dcc26cdbeb1cdeea1ae7
1 #!/bin/sh
3 # Copyright (C) 2012-2013 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
19 print_ver_ dd
21 # count_bytes
22 echo 0123456789abcdefghijklm > in || framework_failure_
23 dd count=14 conv=swab iflag=count_bytes < in > out 2> /dev/null || fail=1
24 case $(cat out) in
25 1032547698badc) ;;
26 *) fail=1 ;;
27 esac
29 # skip_bytes
30 echo 0123456789abcdefghijklm > in || framework_failure_
31 dd skip=10 iflag=skip_bytes < in > out 2> /dev/null || fail=1
32 case $(cat out) in
33 abcdefghijklm) ;;
34 *) fail=1 ;;
35 esac
37 # skip records and bytes from pipe
38 echo 0123456789abcdefghijklm |
39 dd skip=10 bs=2 iflag=skip_bytes > out 2> /dev/null || fail=1
40 case $(cat out) in
41 abcdefghijklm) ;;
42 *) fail=1 ;;
43 esac
45 # seek bytes
46 echo abcdefghijklm |
47 dd bs=5 seek=8 oflag=seek_bytes > out 2> /dev/null || fail=1
48 printf '\0\0\0\0\0\0\0\0abcdefghijklm\n' > expected
49 compare expected out || fail=1
51 # Just truncation, no I/O
52 dd bs=5 seek=8 oflag=seek_bytes of=out2 count=0 2> /dev/null || fail=1
53 truncate -s8 expected2
54 compare expected2 out2 || fail=1
56 Exit $fail