2 # Test dd's skip and seek options.
4 # Copyright (C) 2000-2023 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 <https://www.gnu.org/licenses/>.
21 (my $program_name = $0) =~ s
|.*/||;
23 # Turn off localization of executable's output.
24 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x
3;
31 qw
(bs
=1 skip
=1 seek=2 conv
=notrunc count
=3 status
=noxfer of
=@AUX@
< ),
32 {IN
=> '0123456789abcdef'},
33 {AUX
=> 'zyxwvutsrqponmlkji'},
35 {ERR
=> "3+0 records in\n3+0 records out\n"},
36 {CMP
=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
40 qw
(bs
=5 skip
=1 seek=1 conv
=notrunc count
=1 status
=noxfer of
=@AUX@
< ),
41 {IN
=> '0123456789abcdef'},
42 {AUX
=> 'zyxwvutsrqponmlkji'},
44 {ERR
=> "1+0 records in\n1+0 records out\n"},
45 {CMP
=> ['zyxwv56789ponmlkji', {'@AUX@'=> undef}]},
49 qw
(bs
=5 skip
=1 seek=1 count
=1 status
=noxfer of
=@AUX@
< ),
50 {IN
=> '0123456789abcdef'},
51 {AUX
=> 'zyxwvutsrqponmlkji'},
53 {ERR
=> "1+0 records in\n1+0 records out\n"},
54 {CMP
=> ['zyxwv56789', {'@AUX@'=> undef}]},
57 # Before fileutils-4.0.45, the last 10 bytes of output
58 # were these "\0\0\0\0\0\0\0\0 ".
59 'block-sync-1', qw(ibs=10 cbs=10 status=noxfer), 'conv=block,sync', '<',
60 {IN
=> "01234567\nabcdefghijkl\n"},
61 {OUT
=> "01234567 abcdefghij "},
62 {ERR
=> "2+1 records in\n0+1 records out\n1 truncated record\n"},
65 # Before coreutils-5.93, this would output just "c\n".
66 'sk-seek4', qw(bs=1 skip=1 status=noxfer),
69 {ERR
=> "3+0 records in\n3+0 records out\n"},
72 # Check that iseek and oseek aliases work too.
74 qw
(bs
=1 iseek
=1 oseek
=2 conv
=notrunc count
=3 status
=noxfer of
=@AUX@
< ),
75 {IN
=> '0123456789abcdef'},
76 {AUX
=> 'zyxwvutsrqponmlkji'},
78 {ERR
=> "3+0 records in\n3+0 records out\n"},
79 {CMP
=> ['zy123utsrqponmlkji', {'@AUX@'=> undef}]},
83 my $save_temps = $ENV{DEBUG
};
84 my $verbose = $ENV{VERBOSE
};
87 my $fail = run_tests
($program_name, $prog, \
@Tests, $save_temps, $verbose);