tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / testsuite-summary-count-many.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Check test counts in the testsuite summary, with test drivers allowing
18 # multiple test results per test script, and for a huge number of tests.
19 # Incidentally, this test also checks that the testsuite summary doesn't
20 # give any bug-report address if it's not defined.
21
22 am_parallel_tests=yes
23 . ./defs || Exit 1
24
25 for s in trivial-test-driver extract-testsuite-summary.pl; do
26   cp "$am_testauxdir/$s" . || fatal_ "failed to fetch auxiliary script $s"
27 done
28
29 br='============================================================================'
30
31 header="\
32 ${br}
33 Testsuite summary for $me 1.0
34 ${br}"
35
36 footer="\
37 ${br}
38 See ./test-suite.log
39 ${br}"
40
41 echo AC_OUTPUT >> configure.ac
42
43 cat > Makefile.am << 'END'
44 TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
45 TESTS = all.test
46 # Without this, the test driver will be horrendously slow.
47 END
48
49 cat > all.test <<'END'
50 #!/bin/sh
51 cat results.txt || { echo ERROR: weird; exit 99; }
52 END
53 chmod a+x all.test
54
55 $PERL -w -e '
56   use warnings FATAL => "all";
57   use strict;
58
59   # FIXME: we would like this to be 1000 or even 10000, but the current
60   # implementation is too slow to handle that :-(
61   my $base = 5;
62   my %count = (
63     TOTAL => $base * 1000,
64     PASS  => $base * 700,
65     SKIP  => $base * 200,
66     XFAIL => $base * 80,
67     FAIL  => $base * 10,
68     XPASS => $base * 7,
69     ERROR => $base * 3,
70   );
71   my @results = qw/PASS SKIP XFAIL FAIL XPASS ERROR/;
72
73   open (RES, ">results.txt") or die "opening results.txt: $!\n";
74   open (CNT, ">count.txt") or die "opening count.txt: $!\n";
75
76   printf CNT "# %-6s %d\n", "TOTAL:", $count{TOTAL};
77   for my $res (@results)
78     {
79       my $uc_res = uc $res;
80       print STDERR "Generating list of $res ...\n";
81       for (1..$count{$res})
82         {
83           print RES "$uc_res: $_\n";
84         }
85       printf CNT "# %-6s %d\n", $res . ":", $count{$res};
86     }
87 '
88
89 (echo "$header" && cat count.txt && echo "$footer") > summary.exp
90
91 $ACLOCAL
92 $AUTOMAKE -a
93 $AUTOCONF
94
95 ./configure
96
97 ($MAKE check || : > make.fail) | tee stdout
98 test -f make.fail
99
100 $PERL extract-testsuite-summary.pl stdout > summary.got
101 cat summary.exp
102 cat summary.got
103 diff summary.exp summary.got || Exit 1
104
105 :