testsuite-summary-count-many.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #! /bin/sh
  2. # Copyright (C) 2011-2017 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. # Check test counts in the testsuite summary, with test drivers allowing
  17. # multiple test results per test script, and for a huge number of tests.
  18. # Incidentally, this test also checks that the testsuite summary doesn't
  19. # give any bug-report address if it's not defined.
  20. . test-init.sh
  21. for s in trivial-test-driver extract-testsuite-summary.pl; do
  22. cp "$am_testaux_srcdir/$s" . || fatal_ "failed to fetch auxiliary script $s"
  23. done
  24. br='============================================================================'
  25. header="\
  26. ${br}
  27. Testsuite summary for $me 1.0
  28. ${br}"
  29. footer="\
  30. ${br}
  31. See ./test-suite.log
  32. ${br}"
  33. echo AC_OUTPUT >> configure.ac
  34. cat > Makefile.am << 'END'
  35. TEST_LOG_DRIVER = $(SHELL) $(srcdir)/trivial-test-driver
  36. TESTS = all.test
  37. # Without this, the test driver will be horrendously slow.
  38. END
  39. cat > all.test <<'END'
  40. #!/bin/sh
  41. cat results.txt || { echo ERROR: weird; exit 99; }
  42. END
  43. chmod a+x all.test
  44. $PERL -w -e '
  45. use warnings FATAL => "all";
  46. use strict;
  47. my $base = 1000;
  48. my %count = (
  49. TOTAL => $base * 1000,
  50. PASS => $base * 700,
  51. SKIP => $base * 200,
  52. XFAIL => $base * 80,
  53. FAIL => $base * 10,
  54. XPASS => $base * 7,
  55. ERROR => $base * 3,
  56. );
  57. my @results = qw/PASS SKIP XFAIL FAIL XPASS ERROR/;
  58. open (RES, ">results.txt") or die "opening results.txt: $!\n";
  59. open (CNT, ">count.txt") or die "opening count.txt: $!\n";
  60. printf CNT "# %-6s %d\n", "TOTAL:", $count{TOTAL};
  61. for my $res (@results)
  62. {
  63. my $uc_res = uc $res;
  64. print STDERR "Generating list of $res ...\n";
  65. for (1..$count{$res})
  66. {
  67. print RES "$uc_res: $_\n";
  68. }
  69. printf CNT "# %-6s %d\n", $res . ":", $count{$res};
  70. }
  71. '
  72. (echo "$header" && cat count.txt && echo "$footer") > summary.exp
  73. $ACLOCAL
  74. $AUTOMAKE -a
  75. $AUTOCONF
  76. ./configure
  77. ($MAKE check || touch make.fail) | tee stdout
  78. test -f make.fail
  79. $PERL extract-testsuite-summary.pl stdout > summary.got
  80. cat summary.exp
  81. cat summary.got
  82. diff summary.exp summary.got || exit 1
  83. :