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

« back to all changes in this revision

Viewing changes to tests/misc/wc-files0-from.pl

  • 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
#!/usr/bin/perl
 
2
# Exercise wc's --files0-from option.
 
3
# FIXME: keep this file in sync with tests/du/files0-from.
 
4
 
 
5
# Copyright (C) 2006-2012 Free Software Foundation, Inc.
 
6
 
 
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.
 
11
 
 
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.
 
16
 
 
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/>.
 
19
 
 
20
use strict;
 
21
 
 
22
(my $program_name = $0) =~ s|.*/||;
 
23
 
 
24
my $prog = 'wc';
 
25
 
 
26
# Turn off localization of executable's output.
 
27
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
 
28
 
 
29
my @Tests =
 
30
  (
 
31
   # invalid extra command line argument
 
32
   ['f-extra-arg', '--files0-from=- no-such', {IN=>"a"}, {EXIT=>1},
 
33
    {ERR => "$prog: extra operand 'no-such'\n"
 
34
        . "file operands cannot be combined with --files0-from\n"
 
35
        . "Try '$prog --help' for more information.\n"}
 
36
    ],
 
37
 
 
38
   # missing input file
 
39
   ['missing', '--files0-from=missing', {EXIT=>1},
 
40
    {ERR => "$prog: cannot open 'missing' for reading: "
 
41
     . "No such file or directory\n"}],
 
42
 
 
43
   # input file name of '-'
 
44
   ['minus-in-stdin', '--files0-from=-', '<', {IN=>{f=>'-'}}, {EXIT=>1},
 
45
    {ERR => "$prog: when reading file names from stdin, no file name of"
 
46
     . " '-' allowed\n"}],
 
47
 
 
48
   # empty input, regular file
 
49
   ['empty', '--files0-from=@AUX@', {AUX=>''}],
 
50
 
 
51
   # empty input, from non-regular file
 
52
   ['empty-nonreg', '--files0-from=/dev/null'],
 
53
 
 
54
   # one NUL
 
55
   ['nul-1', '--files0-from=-', '<', {IN=>"\0"}, {EXIT=>1},
 
56
    {ERR => "$prog: -:1: invalid zero-length file name\n"}],
 
57
 
 
58
   # two NULs
 
59
   ['nul-2', '--files0-from=-', '<', {IN=>"\0\0"}, {EXIT=>1},
 
60
    {OUT=>"0 0 0 total\n"},
 
61
    {ERR => "$prog: -:1: invalid zero-length file name\n"
 
62
          . "$prog: -:2: invalid zero-length file name\n"}],
 
63
 
 
64
   # one file name, no NUL
 
65
   ['1', '--files0-from=-', '<',
 
66
    {IN=>{f=>"g"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ],
 
67
 
 
68
   # one file name, with NUL
 
69
   ['1a', '--files0-from=-', '<',
 
70
    {IN=>{f=>"g\0"}}, {AUX=>{g=>''}}, {OUT=>"0 0 0 g\n"} ],
 
71
 
 
72
   # two file names, no final NUL
 
73
   ['2', '--files0-from=-', '<',
 
74
    {IN=>{f=>"g\0g"}}, {AUX=>{g=>''}},
 
75
     {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ],
 
76
 
 
77
   # two file names, with final NUL
 
78
   ['2a', '--files0-from=-', '<',
 
79
    {IN=>{f=>"g\0g\0"}}, {AUX=>{g=>''}},
 
80
     {OUT=>"0 0 0 g\n0 0 0 g\n0 0 0 total\n"} ],
 
81
 
 
82
   # Ensure that $prog processes FILEs following a zero-length name.
 
83
   ['zero-len', '--files0-from=-', '<',
 
84
    {IN=>{f=>"\0g\0"}}, {AUX=>{g=>''}},
 
85
    {OUT=>"0 0 0 g\n0 0 0 total\n"},
 
86
    {ERR => "$prog: -:1: invalid zero-length file name\n"}, {EXIT=>1} ],
 
87
  );
 
88
 
 
89
my $save_temps = $ENV{DEBUG};
 
90
my $verbose = $ENV{VERBOSE};
 
91
 
 
92
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
 
93
exit $fail;