.
[coreutils.git] / tests / tsort / basic-1
blob7c914e2861f253e0b376678914642b87e81fbb0f
1 #!/bin/sh
2 # -*- perl -*-
4 : ${PERL=perl}
5 : ${srcdir=.}
7 $PERL -e 1 > /dev/null 2>&1 || {
8 echo 1>&2 "$0: configure didn't find a usable version of Perl," \
9 "so can't run this test"
10 exit 77
13 exec $PERL -w -I$srcdir/.. -MFetish -- - <<\EOF
15 require 5.003;
16 use strict;
18 (my $program_name = $0) =~ s|.*/||;
20 # Turn off localisation of executable's ouput.
21 @ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
23 my @Tests =
25 ['cycle-1', {IN => {f => "t b\nt s\ns t\n"}}, {OUT => "s\nt\nb\n"},
26 {EXIT => 1},
27 {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
28 ['cycle-2', {IN => {f => "t x\nt s\ns t\n"}}, {OUT => "s\nt\nx\n"},
29 {EXIT => 1},
30 {ERR => "tsort: f: input contains a loop:\ntsort: s\ntsort: t\n"} ],
32 ['posix-1', {IN => "a b c c d e\ng g\nf g e f\nh h\n"},
33 {OUT => "a\nc\nd\nh\nb\ne\nf\ng\n"}],
34 ['posix-2', {IN => "b a\nd c\nz h x h r h\n"},
35 {OUT => "b\nd\nr\nx\nz\na\nc\nh\n"}],
37 ['linear-1', {IN => "a b b c c d d e e f f g\n"},
38 {OUT => "a\nb\nc\nd\ne\nf\ng\n"}],
40 ['tree-1', {IN => "a b b c c d d e e f f g\nc x x y y z\n"},
41 {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\ng\n"}],
42 ['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"},
43 {OUT => "a\nb\nc\nx\nd\ny\ne\nz\nf\nr\ng\ns\nt\n"}],
45 # Before coreutils-5.0.1, given an odd number of input tokens,
46 # tsort would accept that and treat the input as if an additional
47 # copy of the final token were appended.
48 ['odd', {IN => "a\n"},
49 {EXIT => 1},
50 {ERR => "tsort: odd.1: input contains an odd number of tokens\n"}],
52 ['only-one', {IN => {f => ""}}, {IN => {g => ""}},
53 {EXIT => 1},
54 {ERR => "tsort: extra operand `g'\n"
55 . "Try `tsort --help' for more information.\n"}],
58 my $save_temps = $ENV{DEBUG};
59 my $verbose = $ENV{VERBOSE};
61 my $prog = $ENV{PROG} || die "$0: \$PROG not specified in environment\n";
62 my $fail = run_tests ($program_name, $prog, \@Tests, $save_temps, $verbose);
63 exit $fail;
64 EOF