test_summary 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. #! /bin/sh
  2. # (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2009, 2010
  3. # Free Software Foundation
  4. # Originally by Alexandre Oliva <oliva@dcc.unicamp.br>
  5. # This script is Free Software, and it can be copied, distributed and
  6. # modified as defined in the GNU General Public License. A copy of
  7. # its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
  8. # This script processes *.{sum,log} files, producing a shell-script
  9. # that sends e-mail to the appropriate lists and renames files to
  10. # *.sent. It currently handles only gcc, but it should be quite easy
  11. # to modify it to handle other packages and its mailing lists.
  12. # The scripts assumes it is run in the root directory of the build
  13. # tree, and it will include all .sum files it finds in the mail
  14. # report.
  15. # configure flags are extracted from ./config.status
  16. # if the BOOT_CFLAGS environment variable is set, it will be included
  17. # in the mail report too.
  18. # The usage pattern of this script is as follows:
  19. # test_summary | more # so as to observe what should be done
  20. # test_summary | sh # so as to actually send e-mail and move log files
  21. # It accepts a few command line arguments. For example:
  22. if test x"$1" = "x-h"; then
  23. cat <<_EOF
  24. -o: re-reads logs that have been mailed already (.sum.sent)
  25. -t: prevents logs from being renamed
  26. -p: prepend specified file (or list of files: -p "a b") to the report
  27. -i: append specified file (or list of files: -i "a b") to the report
  28. -m: specify the e-mail address to send notes to. An appropriate default
  29. should be selected from the log files.
  30. -f: force reports to be mailed; if omitted, only reports that differ
  31. from the sent.* version are sent.
  32. _EOF
  33. exit 0
  34. fi
  35. # Find a good awk.
  36. if test -z "$AWK" ; then
  37. for AWK in gawk nawk awk ; do
  38. if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
  39. :
  40. else
  41. break
  42. fi
  43. done
  44. fi
  45. : ${filesuffix=}; export filesuffix
  46. : ${move=true}; export move
  47. : ${forcemail=false}; export forcemail
  48. while true; do
  49. case "$1" in
  50. -o) filesuffix=.sent; move=false; : ${mailto=nobody}; shift;;
  51. -t) move=false; shift;;
  52. -p) prepend_logs=${prepend_logs+"$prepend_logs "}"$2"; shift 2;;
  53. -i) append_logs=${append_logs+"$append_logs "}"$2"; shift 2;;
  54. -m) mailto=$2; forcemail=true; shift 2;;
  55. -f) unset mailto; forcemail=true; shift;;
  56. *) break;;
  57. esac
  58. done
  59. : ${mailto="\" address \""}; export mailto
  60. files=`find . -name \*.sum$filesuffix -print | sort`
  61. anyfile=false anychange=$forcemail &&
  62. for file in $files; do
  63. [ -f $file ] &&
  64. anyfile=true &&
  65. { $anychange ||
  66. anychange=`diff $file.sent $file 2>/dev/null |
  67. if test ! -f $file.sent ||
  68. egrep '^[<>] (XPASS|FAIL)' >/dev/null; then
  69. echo true
  70. else
  71. echo false
  72. fi
  73. `
  74. }
  75. true
  76. done &&
  77. $anyfile &&
  78. if $forcemail || $anychange; then :; else mailto=nobody; fi &&
  79. # We use cat instead of listing the files as arguments to AWK because
  80. # GNU awk 3.0.0 would break if any of the filenames contained `=' and
  81. # was preceded by an invalid ``variable'' name.
  82. ( echo @TOPLEVEL_CONFIGURE_ARGUMENTS@ | ./config.status --file=-; cat $files ) |
  83. $AWK '
  84. BEGIN {
  85. lang=""; configflags = "";
  86. address="gcc-testresults@gcc.gnu.org";
  87. version="gcc";
  88. print "cat <<'"'"'EOF'"'"' |";
  89. '${prepend_logs+" system(\"cat $prepend_logs\"); "}'
  90. }
  91. NR == 1 {
  92. configflags = $0 " ";
  93. srcdir = configflags;
  94. sub(/\/configure\047? .*/, "", srcdir);
  95. sub(/^\047/, "", srcdir);
  96. if ( system("test -f " srcdir "/LAST_UPDATED") == 0 ) {
  97. printf "LAST_UPDATED: ";
  98. system("tail -1 " srcdir "/LAST_UPDATED");
  99. print "";
  100. }
  101. sub(/^[^ ]*\/configure\047? */, " ", configflags);
  102. sub(/,;t t $/, " ", configflags);
  103. sub(/ --with-gcc-version-trigger=[^ ]* /, " ", configflags);
  104. sub(/ --norecursion /, " ", configflags);
  105. sub(/ $/, "", configflags);
  106. sub(/^ *$/, " none", configflags);
  107. configflags = "configure flags:" configflags;
  108. }
  109. /^Running target / { print ""; print; }
  110. /^Target / { if (host != "") next; else host = $3; }
  111. /^Host / && host ~ /^unix\{.*\}$/ { host = $3 " " substr(host, 5); }
  112. /^Native / { if (host != "") next; else host = $4; }
  113. /^[ ]*=== [^ ]+ tests ===/ {
  114. if (lang == "") lang = " "$2" "; else lang = " ";
  115. }
  116. $2 == "version" { save = $0; $1 = ""; $2 = ""; version = $0; gsub(/^ */, "", version); gsub(/\r$/, "", version); $0 = save; }
  117. /===.*Summary/ { print ""; print; blanks=1; }
  118. /tests ===/ || /^(Target|Host|Native)/ || $2 == "version" { print; blanks=1; }
  119. /^(XPASS|FAIL|UNRESOLVED|WARNING|ERROR|# of )/ { sub ("\r", ""); print; }
  120. /^using:/ { print ""; print; print ""; }
  121. # dumpall != 0 && /^X?(PASS|FAIL|UNTESTED)|^testcase/ { dumpall=0; }
  122. # dumpall != 0 { print; }
  123. # /^FAIL/ { dumpall=1; }
  124. /^$/ && blanks>0 { print; --blanks; }
  125. END { if (lang != "") {
  126. print "";
  127. print "Compiler version: " prefix version lang;
  128. print "Platform: " host;
  129. print configflags;
  130. '${BOOT_CFLAGS+'print "BOOT_CFLAGS='"${BOOT_CFLAGS}"'";'}'
  131. if (boot_cflags != 0) print boot_cflags;
  132. '${append_logs+" system(\"cat $append_logs\"); "}'
  133. print "EOF";
  134. print "Mail -s \"Results for " prefix version lang "testsuite on " host "\" '"${mailto}"' &&";
  135. }}
  136. { next; }
  137. ' | sed "s/\([\`\$\\\\]\)/\\\\\\1/g" &&
  138. if $move; then
  139. for file in $files `ls -1 $files | sed s/sum$/log/`; do
  140. [ -f $file ] && echo "mv `${PWDCMD-pwd}`/$file `${PWDCMD-pwd}`/$file.sent &&"
  141. done
  142. fi &&
  143. echo true
  144. exit 0