5 # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006 Free Software
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 $PERL -e 1 > /dev/null 2>&1 || {
27 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
28 "so can't run this test"
32 exec $PERL -w -I$srcdir/.. -MCoreutils -- - <<\EOF
37 (my $program_name = $0) =~ s|.*/||;
39 # Turn off localisation of executable's ouput.
40 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
44 ['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"},
46 {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
47 ['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"},
49 {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
51 ['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"},
52 {OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}],
53 ['posix-2', {IN => "b a\nd c\nz h x h r h\n"},
54 {OUT => "b\nd\nr\nx\nz\na\nc\nh\n"}],
56 ['linear-1', {IN => "a b b c c d d e e f f g\n"},
57 {OUT => "a\nb\nc\nd\ne\nf\ng\n"}],
59 ['tree-1', {IN => "a b b c c d d e e f f g\nc x x y y z\n"},
60 {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\ng\n"}],
61 ['tree-2', {IN => "a b b c c d d e e f f g\nc x x y y z\nf r r s s t\n"},
62 {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\nr\ng\ns\nt\n"}],
64 # Before coreutils-5.0.1, given an odd number of input tokens,
65 # tsort would accept that and treat the input as if an additional
66 # copy of the final token were appended.
67 ['odd', {IN => "a\n"},
69 {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}],
71 ['only-one', {IN => {f => ""}}, {IN => {g => ""}},
73 {ERR => "tsort: extra operand `g'\n"
74 . "Try `tsort --help' for more information.\n"}],
77 my $save_temps = $ENV{DEBUG};
78 my $verbose = $ENV{VERBOSE};
80 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
81 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);