xref: /openbsd-src/gnu/usr.bin/gcc/contrib/test_summary (revision 4e43c760ad4cd5f644ec700462679d05749498d8)
17e568061Sespie#! /bin/sh
27e568061Sespie
37e568061Sespie# (C) 1998, 1999, 2000, 2002 Free Software Foundation
47e568061Sespie# Originally by Alexandre Oliva <oliva@dcc.unicamp.br>
57e568061Sespie
67e568061Sespie# This script is Free Software, and it can be copied, distributed and
77e568061Sespie# modified as defined in the GNU General Public License.  A copy of
87e568061Sespie# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html
97e568061Sespie
107e568061Sespie# This script processes *.{sum,log} files, producing a shell-script
117e568061Sespie# that sends e-mail to the appropriate lists and renames files to
127e568061Sespie# *.sent.  It currently handles only gcc, but it should be quite easy
137e568061Sespie# to modify it to handle other packages and its mailing lists.
147e568061Sespie
157e568061Sespie# The scripts assumes it is run in the root directory of the build
167e568061Sespie# tree, and it will include all .sum files it finds in the mail
177e568061Sespie# report.
187e568061Sespie
197e568061Sespie# configure flags are extracted from ./config.status
207e568061Sespie
217e568061Sespie# if the BOOT_CFLAGS environment variable is set, it will be included
227e568061Sespie# in the mail report too.
237e568061Sespie
247e568061Sespie# The usage pattern of this script is as follows:
257e568061Sespie
267e568061Sespie# test_summary | more   # so as to observe what should be done
277e568061Sespie
287e568061Sespie# test_summary | sh     # so as to actually send e-mail and move log files
297e568061Sespie
307e568061Sespie# It accepts a few command line arguments.  For example:
317e568061Sespie# -o: re-reads logs that have been mailed already (.sum.sent)
327e568061Sespie# -t: prevents logs from being renamed
337e568061Sespie# -p: prepend specified file (or list of files: -p "a b") to the report
347e568061Sespie# -i: append specified file (or list of files: -i "a b") to the report
357e568061Sespie# -m: specify the e-mail address to send notes to.  An appropriate default
367e568061Sespie#     should be selected from the log files.
377e568061Sespie# -f: force reports to be mailed; if omitted, only reports that differ
387e568061Sespie#     from the sent.* version are sent.
397e568061Sespie
407e568061Sespie# Find a good awk.
417e568061Sespieif test -z "$AWK" ; then
427e568061Sespie  for AWK in gawk nawk awk ; do
437e568061Sespie    if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then
447e568061Sespie      :
457e568061Sespie    else
467e568061Sespie      break
477e568061Sespie    fi
487e568061Sespie  done
497e568061Sespiefi
507e568061Sespie
517e568061Sespie: ${filesuffix=}; export filesuffix
527e568061Sespie: ${move=true}; export move
537e568061Sespie: ${forcemail=false}; export forcemail
547e568061Sespiewhile true; do
557e568061Sespie    case "$1" in
567e568061Sespie      -o) filesuffix=.sent; move=false; : ${mailto=nobody}; shift;;
577e568061Sespie      -t) move=false; shift;;
587e568061Sespie      -p) prepend_logs=${prepend_logs+"$prepend_logs "}"$2"; shift 2;;
597e568061Sespie      -i) append_logs=${append_logs+"$append_logs "}"$2"; shift 2;;
607e568061Sespie      -m) mailto=$2; forcemail=true; shift 2;;
617e568061Sespie      -f) unset mailto; forcemail=true; shift;;
627e568061Sespie      *) break;;
637e568061Sespie    esac
647e568061Sespiedone
657e568061Sespie: ${mailto="\" address \""}; export mailto
667e568061Sespiefiles=`find . -name \*.sum$filesuffix -print | sort`
677e568061Sespieanyfile=false anychange=$forcemail &&
687e568061Sespiefor file in $files; do
697e568061Sespie    [ -f $file ] &&
707e568061Sespie    anyfile=true &&
717e568061Sespie    { $anychange ||
727e568061Sespie      anychange=`diff -u $file.sent $file 2>/dev/null |
737e568061Sespie	if test ! -f $file.sent ||
747e568061Sespie	   egrep '^[-+](XPASS|FAIL)' >/dev/null; then
757e568061Sespie	    echo true
767e568061Sespie	else
777e568061Sespie	    echo false
787e568061Sespie	fi
797e568061Sespie      `
807e568061Sespie    }
817e568061Sespie    true
827e568061Sespiedone &&
837e568061Sespie$anyfile &&
847e568061Sespieif $forcemail || $anychange; then :; else mailto=nobody; fi &&
857e568061Sespie# We use cat instead of listing the files as arguments to AWK because
867e568061Sespie# GNU awk 3.0.0 would break if any of the filenames contained `=' and
877e568061Sespie# was preceded by an invalid ``variable'' name.
887e568061Sespiecat ./config.status $files |
897e568061Sespie$AWK '
907e568061SespieBEGIN {
917e568061Sespie  lang="";
927e568061Sespie  address="gcc-testresults@gcc.gnu.org";
937e568061Sespie  version="gcc";
947e568061Sespie  print "cat <<'"'"'EOF'"'"' |";
957e568061Sespie'${prepend_logs+"  system(\"cat $prepend_logs\"); "}'
967e568061Sespie}
977e568061Sespie$1 ~ /\/configure$/ {
987e568061Sespie    srcdir = $1;
997e568061Sespie    gsub(/\/configure$/, "", srcdir);
1007e568061Sespie    printf "LAST_UPDATED: ";
1017e568061Sespie    system("tail -1 " srcdir "/LAST_UPDATED");
1027e568061Sespie    print "";
1037e568061Sespie
1047e568061Sespie    $1 = "configure flags:"; configflags = $0;
1057e568061Sespie    gsub(/--with-gcc-version-trigger=[^ ]* /, "", configflags);
1067e568061Sespie    gsub(/ --norecursion/, "", configflags)
1077e568061Sespie}
1087e568061Sespie/^Running target / { print ""; print; }
1097e568061Sespie/^Target / { if (host != "") next; else host = $3; }
1107e568061Sespie/^Host / && host ~ /^unix\{.*\}$/ { host = $3 " " substr(host, 5); }
1117e568061Sespie/^Native / { if (host != "") next; else host = $4; }
1127e568061Sespie/^[ 	]*=== [^ 	]+ tests ===/ {
1137e568061Sespie  if (lang == "") lang = " "$2" "; else lang = " ";
1147e568061Sespie}
1157e568061Sespie$2 == "version" { save = $0; $1 = ""; $2 = ""; version = $0; gsub(/^ */, "", version); gsub(/\r$/, "", version); $0 = save; }
1167e568061Sespie/\===.*Summary/ { print ""; print; blanks=1; }
1177e568061Sespie/tests ===/ || /^(Target|Host|Native)/ || $2 == "version" { print; blanks=1; }
1187e568061Sespie/^(XPASS|FAIL|UNRESOLVED|WARNING|ERROR|# of )/ { print; }
119*4e43c760Sespie/^using:/ { print ""; print; print ""; }
1207e568061Sespie# dumpall != 0 && /^X?(PASS|FAIL|UNTESTED)|^testcase/ { dumpall=0; }
1217e568061Sespie# dumpall != 0 { print; }
1227e568061Sespie# /^FAIL/ { dumpall=1; }
1237e568061Sespie/^$/ && blanks>0 { print; --blanks; }
1247e568061SespieEND { if (lang != "") {
1257e568061Sespie  print "";
1267e568061Sespie  print "Compiler version: " prefix version lang;
1277e568061Sespie  print "Platform: " host;
1287e568061Sespie  print configflags;
1297e568061Sespie  '${BOOT_CFLAGS+'print "BOOT_CFLAGS='"${BOOT_CFLAGS}"'";'}'
1307e568061Sespie  if (boot_cflags != 0) print boot_cflags;
1317e568061Sespie'${append_logs+"  system(\"cat $append_logs\"); "}'
1327e568061Sespie  print "EOF";
1337e568061Sespie  print "Mail -s \"Results for " prefix version lang "testsuite on " host "\" '"${mailto}"' &&";
1347e568061Sespie}}
1357e568061Sespie{ next; }
1367e568061Sespie' | sed "s/\([\`\$\\\\]\)/\\\\\\1/g" &&
1377e568061Sespieif $move; then
1387e568061Sespie    for file in $files `ls -1 $files | sed s/sum$/log/`; do
1397e568061Sespie      [ -f $file ] && echo "mv `${PWDCMD-pwd}`/$file `${PWDCMD-pwd}`/$file.sent &&"
1407e568061Sespie    done
1417e568061Sespiefi &&
1427e568061Sespieecho true
1437e568061Sespieexit 0
144