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