doc: stat: clarify that %t and %T expand to the file system type
[coreutils/ericb.git] / tests / misc / tac
blob56021280bb1b9887723757b88e77c2bb52058a94
1 #!/usr/bin/perl
3 # Copyright (C) 2008-2011 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 use strict;
20 my $prog = 'tac';
22 # Turn off localization of executable's output.
23 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
25 my $bad_dir = 'no/such/dir';
27 # This must be longer than 16KiB to trigger the double free in coreutils-8.5.
28 my $long_line = 'o' x (16 * 1024 + 1);
30 my @Tests =
32 ['segfault', '-r', {IN=>"a\n"}, {IN=>"b\n"}, {OUT=>"a\nb\n"}],
33 ['segfault2','-r', {IN=>"a\nb\n"}, {IN=>"1\n2\n"}, {OUT=>"b\na\n2\n1\n"}],
35 ['basic-0', '', {IN=>""}, {OUT=>""}],
36 ['basic-a', '', {IN=>"a"}, {OUT=>"a"}],
37 ['basic-b', '', {IN=>"\n"}, {OUT=>"\n"}],
38 ['basic-c', '', {IN=>"a\n"}, {OUT=>"a\n"}],
39 ['basic-d', '', {IN=>"a\nb"}, {OUT=>"ba\n"}],
40 ['basic-e', '', {IN=>"a\nb\n"}, {OUT=>"b\na\n"}],
41 ['basic-f', '', {IN=>"1234567\n8\n"}, {OUT=>"8\n1234567\n"}],
42 ['basic-g', '', {IN=>"12345678\n9\n"}, {OUT=>"9\n12345678\n"}],
43 ['basic-h', '', {IN=>"123456\n8\n"}, {OUT=>"8\n123456\n"}],
44 ['basic-i', '', {IN=>"12345\n8\n"}, {OUT=>"8\n12345\n"}],
45 ['basic-j', '', {IN=>"1234\n8\n"}, {OUT=>"8\n1234\n"}],
46 ['basic-k', '', {IN=>"123\n8\n"}, {OUT=>"8\n123\n"}],
48 ['opt-b', '-b', {IN=>"\na\nb\nc"}, {OUT=>"\nc\nb\na"}],
49 ['opt-s', '-s:', {IN=>"a:b:c:"}, {OUT=>"c:b:a:"}],
50 ['opt-sb', qw(-s : -b), {IN=>":a:b:c"}, {OUT=>":c:b:a"}],
51 ['opt-r', qw(-r -s '\._+'),
52 {IN=>"1._2.__3.___4._"},
53 {OUT=>"4._3.___2.__1._"}],
55 ['opt-r2', qw(-r -s '\._+'),
56 {IN=>"a.___b.__1._2.__3.___4._"},
57 {OUT=>"4._3.___2.__1._b.__a.___"}],
59 # This gave incorrect output (.___4._2.__3._1) with tac-1.22.
60 ['opt-br', qw(-b -r -s '\._+'),
61 {IN=>"._1._2.__3.___4"}, {OUT=>".___4.__3._2._1"}],
63 ['opt-br2', qw(-b -r -s '\._+'),
64 {IN=>".__x.___y.____z._1._2.__3.___4"},
65 {OUT=>".___4.__3._2._1.____z.___y.__x"}],
67 ['pipe-bad-tmpdir',
68 {ENV => "TMPDIR=$bad_dir"},
69 {IN_PIPE => "a\n"},
70 {ERR_SUBST => "s,`$bad_dir': .*,...,"},
71 {ERR => "$prog: failed to create temporary file in ...\n"},
72 {EXIT => 1}],
74 # coreutils-8.5's tac would double-free its primary buffer.
75 ['double-free', {IN=>$long_line}, {OUT=>$long_line}],
78 @Tests = triple_test \@Tests;
80 my $save_temps = $ENV{DEBUG};
81 my $verbose = $ENV{VERBOSE};
83 my $fail = run_tests ($prog, $prog, \@Tests, $save_temps, $verbose);
84 exit $fail;