OSDN Git Service

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