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

« back to all changes in this revision

Viewing changes to tests/misc/dirname

  • 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
 
# Test "dirname".
3
 
 
4
 
# Copyright (C) 2006-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
 
use strict;
20
 
use File::stat;
21
 
 
22
 
(my $program_name = $0) =~ s|.*/||;
23
 
 
24
 
# Turn off localization of executable's output.
25
 
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
26
 
 
27
 
my $stat_single = stat('/');
28
 
my $stat_double = stat('//');
29
 
my $double_slash = ($stat_single->dev == $stat_double->dev
30
 
                    && $stat_single->ino == $stat_double->ino) ? '/' : '//';
31
 
 
32
 
my $prog = 'dirname';
33
 
 
34
 
my @Tests =
35
 
    (
36
 
     ['fail-1', {ERR => "$prog: missing operand\n"
37
 
       . "Try `$prog --help' for more information.\n"}, {EXIT => '1'}],
38
 
     ['fail-2', qw(a b), {ERR => "$prog: extra operand `b'\n"
39
 
       . "Try `$prog --help' for more information.\n"}, {EXIT => '1'}],
40
 
 
41
 
     ['a', qw(d/f),        {OUT => 'd'}],
42
 
     ['b', qw(/d/f),       {OUT => '/d'}],
43
 
     ['c', qw(d/f/),       {OUT => 'd'}],
44
 
     ['d', qw(d/f//),      {OUT => 'd'}],
45
 
     ['e', qw(f),          {OUT => '.'}],
46
 
     ['f', qw(/),          {OUT => '/'}],
47
 
     ['g', qw(//),         {OUT => "$double_slash"}],
48
 
     ['h', qw(///),        {OUT => '/'}],
49
 
     ['i', qw(//a//),      {OUT => "$double_slash"}],
50
 
     ['j', qw(///a///),    {OUT => '/'}],
51
 
     ['k', qw(///a///b),   {OUT => '///a'}],
52
 
     ['l', qw(///a//b/),   {OUT => '///a'}],
53
 
     ['m', qw(''),         {OUT => '.'}],
54
 
    );
55
 
 
56
 
# Append a newline to end of each expected `OUT' string.
57
 
my $t;
58
 
foreach $t (@Tests)
59
 
  {
60
 
    my $arg1 = $t->[1];
61
 
    my $e;
62
 
    foreach $e (@$t)
63
 
      {
64
 
        $e->{OUT} = "$e->{OUT}\n"
65
 
          if ref $e eq 'HASH' and exists $e->{OUT};
66
 
      }
67
 
  }
68
 
 
69
 
my $save_temps = $ENV{SAVE_TEMPS};
70
 
my $verbose = $ENV{VERBOSE};
71
 
 
72
 
my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
73
 
exit $fail;