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

« back to all changes in this revision

Viewing changes to tests/rm/empty-name

  • 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
 
# Make sure that rm -r '' fails.
3
 
 
4
 
# Copyright (C) 1998, 2003, 2005, 2007-2011 Free Software Foundation, Inc.
5
 
 
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.
10
 
 
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.
15
 
 
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
 
19
 
# On SunOS 4.1.3, running rm -r '' in a nonempty directory may
20
 
# actually remove files with names of entries in the current directory
21
 
# but relative to `/' rather than relative to the current directory.
22
 
 
23
 
use strict;
24
 
 
25
 
(my $program_name = $0) =~ s|.*/||;
26
 
 
27
 
# Turn off localization of executable's output.
28
 
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
29
 
 
30
 
my $prog = 'rm';
31
 
 
32
 
# FIXME: copied from misc/ls-misc; factor into Coreutils.pm?
33
 
sub mk_file(@)
34
 
{
35
 
  foreach my $f (@_)
36
 
    {
37
 
      open (F, '>', $f) && close F
38
 
        or die "creating $f: $!\n";
39
 
    }
40
 
}
41
 
 
42
 
my @Tests =
43
 
    (
44
 
     # test-name options input expected-output
45
 
     #
46
 
     ['empty-name-1', "''", {EXIT => 1},
47
 
      {ERR => "$prog: cannot remove `': No such file or directory\n"}],
48
 
 
49
 
     ['empty-name-2', "a '' b", {EXIT => 1},
50
 
      {ERR => "$prog: cannot remove `': No such file or directory\n"},
51
 
      {PRE => sub { mk_file qw(a b) }},
52
 
      {POST => sub {-f 'a' || -f 'b' and die "a or b remain\n" }},
53
 
     ],
54
 
    );
55
 
 
56
 
my $save_temps = $ENV{SAVE_TEMPS};
57
 
my $verbose = $ENV{VERBOSE};
58
 
 
59
 
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
60
 
exit $fail;