3 # Exercise du's --files0-from option.
5 # Copyright (C) 2004, 2005 Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 $PERL -e 'use warnings;' > /dev
/null
2>&1 ||
{
25 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
26 "so can't run this test"
30 me
=`echo $0|sed 's,.*/,,'`
31 exec $PERL -w -I$srcdir/..
-MCoreutils -M"CuTmpdir qw($me)" -- - <<\EOF
36 (my
$program_name = $0) =~ s|.
*/||
;
40 # Turn off localization of executable's ouput.
41 @ENV
{qw
(LANGUAGE LANG LC_ALL
)} = ('C') x
3;
45 # invalid extra command line argument
46 ['f-extra-arg', '--files0-from=- no-such', {IN
=>"a"}, {EXIT
=>1},
47 {ERR
=> "du: extra operand `no-such'\n"
48 .
"File operands cannot be combined with --files0-from.\n"
49 .
"Try `du --help' for more information.\n"}
53 ['missing', '--files0-from=missing', {EXIT
=>1},
54 {ERR
=> "du: cannot open `missing' for reading: "
55 .
"No such file or directory\n"}],
58 ['empty', '--files0-from=-'],
60 # empty input, from non-regular file
61 ['empty-nonreg', '--files0-from=/dev/null'],
64 ['nul-1', '--files0-from=-', '<', {IN
=>"\0"}, {EXIT
=>1},
65 {ERR
=> "du: -:1: invalid zero-length file name\n"}],
68 ['nul-2', '--files0-from=-', '<', {IN
=>"\0\0"}, {EXIT
=>1},
69 {ERR
=> "du: -:1: invalid zero-length file name\n"
70 .
"du: -:2: invalid zero-length file name\n"}],
72 # one file name, no NUL
73 ['1', '--files0-from=-', '<',
74 {IN
=>{f
=>"g"}}, {AUX
=>{g
=>''}},
75 {OUT
=>"0\tg\n"}, {OUT_SUBST
=>'s/^\d+/0/'} ],
77 # one file name, with NUL
78 ['1a', '--files0-from=-', '<',
79 {IN
=>{f
=>"g\0"}}, {AUX
=>{g
=>''}},
80 {OUT
=>"0\tg\n"}, {OUT_SUBST
=>'s/^\d+/0/'} ],
82 # two file names, no final NUL
83 ['2', '--files0-from=-', '<',
84 {IN
=>{f
=>"g\0g"}}, {AUX
=>{g
=>''}},
85 {OUT
=>"0\tg\n0\tg\n"}, {OUT_SUBST
=>'s/^\d+/0/'} ],
87 # two file names, with final NUL
88 ['2a', '--files0-from=-', '<',
89 {IN
=>{f
=>"g\0g\0"}}, {AUX
=>{g
=>''}},
90 {OUT
=>"0\tg\n0\tg\n"}, {OUT_SUBST
=>'s/^\d+/0/'} ],
92 # Ensure that du processes FILEs following a zero-length name.
93 ['zero-len', '--files0-from=-', '<',
94 {IN
=>{f
=>"\0g\0"}}, {AUX
=>{g
=>''}},
95 {OUT
=>"0\tg\n"}, {OUT_SUBST
=>'s/^\d+/0/'},
96 {ERR
=> "du: -:1: invalid zero-length file name\n"}, {EXIT
=>1} ],
99 my
$save_temps = $ENV{DEBUG
};
100 my
$verbose = $ENV{VERBOSE
};
102 my
$prog = $ENV{PROG
} || die
"$0: \$PROG not specified in environment\n";
103 my
$fail = run_tests
($program_name, $prog, \@Tests
, $save_temps, $verbose);