3 # Exercise wc's --files0-from option.
4 # This file bears a striking resemblance to tests/du/files0-from.
9 . $srcdir/../envvar-check
11 $PERL -e 1 > /dev/null 2>&1 || {
12 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
13 "so can't run this test"
17 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
22 (my $program_name = $0) =~ s|.*/||;
27 # Turn off localization of executable's ouput.
28 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
32 # invalid extra command line argument
33 ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
34 {ERR => "$ME: extra operand `no-such'\n"
35 . "File operands cannot be combined with --files0-from.\n"
36 . "Try `$ME --help' for more information.\n"}
40 ['missing', '--files0-from=missing', {EXIT=>1},
41 {ERR => "$ME: cannot open `missing' for reading: "
42 . "No such file or directory\n"}],
45 ['empty', '--files0-from=-'],
47 # empty input, from non-regular file
48 ['empty-nonreg', '--files0-from=/dev/null'],
51 ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1},
52 {ERR => "$ME: : No such file or directory\n"}],
55 ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1},
56 {OUT=>"0 0 0 total\n"},
57 {ERR => "$ME: : No such file or directory\n"
58 . "$ME: : No such file or directory\n"}],
60 # one file name, no NUL
61 ['1', '--files0-from=-', '<',
62 {IN=>{f=>"g"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ],
64 # one file name, with NUL
65 ['1a', '--files0-from=-', '<',
66 {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ],
68 # two file names, no final NUL
69 ['2', '--files0-from=-', '<',
70 {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}},
71 {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ],
73 # two file names, with final NUL
74 ['2a', '--files0-from=-', '<',
75 {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}},
76 {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ],
78 # Ensure that wc processes FILEs following a zero-length name.
79 ['zero-len', '--files0-from=-', '<',
80 {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
81 {OUT=>"0 0 0 g\n0 0 0 total\n"},
82 {ERR => "$ME: : No such file or directory\n"}, {EXIT=>1} ],
85 my $save_temps = $ENV{DEBUG};
86 my $verbose = $ENV{VERBOSE};
88 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
89 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);