OSDN Git Service

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