14fee23f9Smrg#! /bin/sh 24fee23f9Smrg 34fee23f9Smrg# (C) 1998, 1999, 2000, 2002, 2003, 2004, 2007, 2009, 2010 44fee23f9Smrg# Free Software Foundation 54fee23f9Smrg# Originally by Alexandre Oliva <oliva@dcc.unicamp.br> 64fee23f9Smrg 74fee23f9Smrg# This script is Free Software, and it can be copied, distributed and 84fee23f9Smrg# modified as defined in the GNU General Public License. A copy of 94fee23f9Smrg# its license can be downloaded from http://www.gnu.org/copyleft/gpl.html 104fee23f9Smrg 114fee23f9Smrg# This script processes *.{sum,log} files, producing a shell-script 124fee23f9Smrg# that sends e-mail to the appropriate lists and renames files to 134fee23f9Smrg# *.sent. It currently handles only gcc, but it should be quite easy 144fee23f9Smrg# to modify it to handle other packages and its mailing lists. 154fee23f9Smrg 164fee23f9Smrg# The scripts assumes it is run in the root directory of the build 174fee23f9Smrg# tree, and it will include all .sum files it finds in the mail 184fee23f9Smrg# report. 194fee23f9Smrg 204fee23f9Smrg# configure flags are extracted from ./config.status 214fee23f9Smrg 224fee23f9Smrg# if the BOOT_CFLAGS environment variable is set, it will be included 234fee23f9Smrg# in the mail report too. 244fee23f9Smrg 254fee23f9Smrg# The usage pattern of this script is as follows: 264fee23f9Smrg 274fee23f9Smrg# test_summary | more # so as to observe what should be done 284fee23f9Smrg 294fee23f9Smrg# test_summary | sh # so as to actually send e-mail and move log files 304fee23f9Smrg 314fee23f9Smrg# It accepts a few command line arguments. For example: 324fee23f9Smrgif test x"$1" = "x-h"; then 334fee23f9Smrg cat <<_EOF 344fee23f9Smrg -o: re-reads logs that have been mailed already (.sum.sent) 354fee23f9Smrg -t: prevents logs from being renamed 364fee23f9Smrg -p: prepend specified file (or list of files: -p "a b") to the report 374fee23f9Smrg -i: append specified file (or list of files: -i "a b") to the report 384fee23f9Smrg -m: specify the e-mail address to send notes to. An appropriate default 394fee23f9Smrg should be selected from the log files. 404fee23f9Smrg -f: force reports to be mailed; if omitted, only reports that differ 414fee23f9Smrg from the sent.* version are sent. 424fee23f9Smrg_EOF 434fee23f9Smrg exit 0 444fee23f9Smrgfi 454fee23f9Smrg 464fee23f9Smrg# Find a good awk. 474fee23f9Smrgif test -z "$AWK" ; then 484fee23f9Smrg for AWK in gawk nawk awk ; do 494fee23f9Smrg if type $AWK 2>&1 | grep 'not found' > /dev/null 2>&1 ; then 504fee23f9Smrg : 514fee23f9Smrg else 524fee23f9Smrg break 534fee23f9Smrg fi 544fee23f9Smrg done 554fee23f9Smrgfi 564fee23f9Smrg 574fee23f9Smrg: ${filesuffix=}; export filesuffix 584fee23f9Smrg: ${move=true}; export move 594fee23f9Smrg: ${forcemail=false}; export forcemail 604fee23f9Smrgwhile true; do 614fee23f9Smrg case "$1" in 624fee23f9Smrg -o) filesuffix=.sent; move=false; : ${mailto=nobody}; shift;; 634fee23f9Smrg -t) move=false; shift;; 644fee23f9Smrg -p) prepend_logs=${prepend_logs+"$prepend_logs "}"$2"; shift 2;; 654fee23f9Smrg -i) append_logs=${append_logs+"$append_logs "}"$2"; shift 2;; 664fee23f9Smrg -m) mailto=$2; forcemail=true; shift 2;; 674fee23f9Smrg -f) unset mailto; forcemail=true; shift;; 684fee23f9Smrg *) break;; 694fee23f9Smrg esac 704fee23f9Smrgdone 714fee23f9Smrg: ${mailto="\" address \""}; export mailto 724fee23f9Smrgfiles=`find . -name \*.sum$filesuffix -print | sort` 734fee23f9Smrganyfile=false anychange=$forcemail && 744fee23f9Smrgfor file in $files; do 754fee23f9Smrg [ -f $file ] && 764fee23f9Smrg anyfile=true && 774fee23f9Smrg { $anychange || 784fee23f9Smrg anychange=`diff $file.sent $file 2>/dev/null | 794fee23f9Smrg if test ! -f $file.sent || 804fee23f9Smrg egrep '^[<>] (XPASS|FAIL)' >/dev/null; then 814fee23f9Smrg echo true 824fee23f9Smrg else 834fee23f9Smrg echo false 844fee23f9Smrg fi 854fee23f9Smrg ` 864fee23f9Smrg } 874fee23f9Smrg true 884fee23f9Smrgdone && 894fee23f9Smrg$anyfile && 904fee23f9Smrgif $forcemail || $anychange; then :; else mailto=nobody; fi && 914fee23f9Smrg# We use cat instead of listing the files as arguments to AWK because 924fee23f9Smrg# GNU awk 3.0.0 would break if any of the filenames contained `=' and 934fee23f9Smrg# was preceded by an invalid ``variable'' name. 944fee23f9Smrg( echo @TOPLEVEL_CONFIGURE_ARGUMENTS@ | ./config.status --file=-; cat $files ) | 954fee23f9Smrg$AWK ' 964fee23f9SmrgBEGIN { 974fee23f9Smrg lang=""; configflags = ""; 984fee23f9Smrg address="gcc-testresults@gcc.gnu.org"; 994fee23f9Smrg version="gcc"; 1004fee23f9Smrg print "cat <<'"'"'EOF'"'"' |"; 1014fee23f9Smrg'${prepend_logs+" system(\"cat $prepend_logs\"); "}' 1024fee23f9Smrg} 1034fee23f9SmrgNR == 1 { 1044fee23f9Smrg configflags = $0 " "; 1054fee23f9Smrg srcdir = configflags; 106*a3e9eb18Smrg sub(/\/configure\047? .*/, "", srcdir); 107*a3e9eb18Smrg sub(/^\047/, "", srcdir); 1084fee23f9Smrg if ( system("test -f " srcdir "/LAST_UPDATED") == 0 ) { 1094fee23f9Smrg printf "LAST_UPDATED: "; 1104fee23f9Smrg system("tail -1 " srcdir "/LAST_UPDATED"); 1114fee23f9Smrg print ""; 1124fee23f9Smrg } 1134fee23f9Smrg 114*a3e9eb18Smrg sub(/^[^ ]*\/configure\047? */, " ", configflags); 1154fee23f9Smrg sub(/,;t t $/, " ", configflags); 1164fee23f9Smrg sub(/ --with-gcc-version-trigger=[^ ]* /, " ", configflags); 1174fee23f9Smrg sub(/ --norecursion /, " ", configflags); 1184fee23f9Smrg sub(/ $/, "", configflags); 1194fee23f9Smrg sub(/^ *$/, " none", configflags); 1204fee23f9Smrg configflags = "configure flags:" configflags; 1214fee23f9Smrg} 1224fee23f9Smrg/^Running target / { print ""; print; } 1234fee23f9Smrg/^Target / { if (host != "") next; else host = $3; } 1244fee23f9Smrg/^Host / && host ~ /^unix\{.*\}$/ { host = $3 " " substr(host, 5); } 1254fee23f9Smrg/^Native / { if (host != "") next; else host = $4; } 1264fee23f9Smrg/^[ ]*=== [^ ]+ tests ===/ { 1274fee23f9Smrg if (lang == "") lang = " "$2" "; else lang = " "; 1284fee23f9Smrg} 1294fee23f9Smrg$2 == "version" { save = $0; $1 = ""; $2 = ""; version = $0; gsub(/^ */, "", version); gsub(/\r$/, "", version); $0 = save; } 130003ba354Smrg/===.*Summary/ { print ""; print; blanks=1; } 1314fee23f9Smrg/tests ===/ || /^(Target|Host|Native)/ || $2 == "version" { print; blanks=1; } 1324fee23f9Smrg/^(XPASS|FAIL|UNRESOLVED|WARNING|ERROR|# of )/ { sub ("\r", ""); print; } 1334fee23f9Smrg/^using:/ { print ""; print; print ""; } 1344fee23f9Smrg# dumpall != 0 && /^X?(PASS|FAIL|UNTESTED)|^testcase/ { dumpall=0; } 1354fee23f9Smrg# dumpall != 0 { print; } 1364fee23f9Smrg# /^FAIL/ { dumpall=1; } 1374fee23f9Smrg/^$/ && blanks>0 { print; --blanks; } 1384fee23f9SmrgEND { if (lang != "") { 1394fee23f9Smrg print ""; 1404fee23f9Smrg print "Compiler version: " prefix version lang; 1414fee23f9Smrg print "Platform: " host; 1424fee23f9Smrg print configflags; 1434fee23f9Smrg '${BOOT_CFLAGS+'print "BOOT_CFLAGS='"${BOOT_CFLAGS}"'";'}' 1444fee23f9Smrg if (boot_cflags != 0) print boot_cflags; 1454fee23f9Smrg'${append_logs+" system(\"cat $append_logs\"); "}' 1464fee23f9Smrg print "EOF"; 1474fee23f9Smrg print "Mail -s \"Results for " prefix version lang "testsuite on " host "\" '"${mailto}"' &&"; 1484fee23f9Smrg}} 1494fee23f9Smrg{ next; } 1504fee23f9Smrg' | sed "s/\([\`\$\\\\]\)/\\\\\\1/g" && 1514fee23f9Smrgif $move; then 1524fee23f9Smrg for file in $files `ls -1 $files | sed s/sum$/log/`; do 1534fee23f9Smrg [ -f $file ] && echo "mv `${PWDCMD-pwd}`/$file `${PWDCMD-pwd}`/$file.sent &&" 1544fee23f9Smrg done 1554fee23f9Smrgfi && 1564fee23f9Smrgecho true 1574fee23f9Smrgexit 0 158