Imported Upstream version 3.16.3
[platform/upstream/nss.git] / tests / qa_stat
1 #! /bin/sh 
2 ########################################################################
3 #
4 # /u/sonmi/bin/qa_stat - /u/svbld/bin/init/nss/qa_stat
5 #
6 # this script is supposed to automatically run QA for NSS on all required
7 # Unix platforms
8 #
9 # parameters
10 # ----------
11 #    nssversion (supported: 30b, 31, tip)
12 #    builddate  (default - today)
13 #
14 # options
15 # -------
16 #    -y answer all questions with y - use at your own risk...ignores warnings
17 #    -s silent (only usefull with -y)
18 #    -h, -? - you guessed right - displays this text
19 #    -d debug
20 #    -f <filename> - write the (error)output to filename
21 #    -m <mailinglist> - send filename to mailinglist (csl) only useful
22 #        with -f
23 #    -cron equivalient to -y -s -d -f $RESULTDIR/$HOST.qa_stat
24 #
25 ########################################################################
26
27 O_OPTIONS=ON
28
29 TBX_EXIT=49          # in case we are running on a tinderbox build, any
30                           # early exit needs to return an error
31 if [ -z "$O_TBX" -o "$O_TBX" = "OFF" ] ; then
32     if [ -z "$O_LOCAL" -o "$O_LOCAL" = "OFF" ] ; then
33         . `dirname $0`/header
34     fi
35 fi
36 Debug "Sourced header O_TBX=$O_TBX O_LOCAL=$O_LOCAL"
37 TBX_EXIT=48
38 EARLY_EXIT=TRUE
39
40 URL="cindercone.red.iplanet.com"
41
42 DOCDIR=/u/sonmi/doc
43
44 HTML_ERRORCOLOR=\"#FF0000\"
45 HTML_ERRORMSG=Failed
46
47 HTML_MISSINGCOLOR=\"#FFFFCC\"
48 HTML_MISSINGMSG=Missing
49
50 HTML_INCOMPLETECOLOR=$HTML_MISSINGCOLOR
51 HTML_INCOMPLETEMSG=Incomplete
52
53 HTML_PASSEDCOLOR=\"#66FF99\"
54 HTML_PASSEDMSG=Passed
55
56 # this file is used to deal with hanging rsh - a new shell is started 
57 # for each rsh, and a function is called after it is finished - they
58 # communicate with this file
59
60 RSH_FILE=$TMP/rsh.$$
61 echo >$RSH_FILE
62 TMPFILES="$TMPFILES $WARNINGLIST $RSH_FILE "
63 RSH_WAIT_TIME=80 #maximum time allowed for the 2 rsh to finish...
64 #TOTAL_TESTS=106
65 TOTAL_TESTS=252 #tip
66 #TOTAL_TESTS=244 #3.4
67 #TOTAL_TESTS=123 #3.3.2
68 BCT_TOTAL_TESTS=122 #3.2.2
69 #TOTAL_TESTS=133 #tip
70
71 Debug "NTDIST $NTDIST"
72 Debug "UXDIST $UXDIST"
73 Debug "TESTSCRIPTDIR $TESTSCRIPTDIR"
74 Debug "RESULTDIR $RESULTDIR"
75
76 ############################### watch_rsh ##############################
77 # local shell function, deals with a hanging rsh (kills it...)
78 # this function is started as a backgroundprocess before the rsh is started,
79 # and writes info to the RSH_FILE, after the rsh is finished it writes finish
80 # info to the same file (this time called as a function, forground). 
81 # the backgroundprocess stays around for RSH_WAIT_TIME, if then the finish 
82 # information is not there attempts to kill the rsh
83 #
84 # watch_rsh start qa_computername &
85 # watch_rsh stop qa_computername 
86 #
87 ########################################################################
88 watch_rsh()
89 {
90     case $1 in
91         start)
92             echo "$2 started" >>$RSH_FILE
93             sleep $RSH_WAIT_TIME
94             O_ALWAYS_YES=ON # may modify global flags because this is a 
95                             # forked off bg process - kill_by_name otherwise
96                             # will ask the user if it really should be killed 
97             grep "$2 finished" $RSH_FILE >/dev/null || kill_by_name "rsh $2"
98             exit
99             ;;
100         stop)
101             echo "$2 finished" >>$RSH_FILE
102             ;;
103     esac
104 }
105
106 ############################### find_qa_systems ########################
107 # local shell function, tries to determine the QA operating system
108 # works remotely, and for Windows machines
109 ########################################################################
110 find_qa_systems()
111 {
112 for QA_SYS in `ls $RESULTDIR | grep '\.1$' | sed -e "s/\..*//" | sort -u`
113 do
114     NO_RSH="FALSE"
115     QA_OS=""
116     QA_RHVER=""
117     IS_64=""
118     IS_WIN=""
119
120     grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa >/dev/null && NO_RSH=TRUE
121
122     if [ "$NO_RSH" = "TRUE" ]
123     then
124
125         QA_OS=`grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa | sort -u | sed \
126             -e "s/.*-OS-LINE: /${QA_SYS}/"`
127         QA_OS_STRING=`echo $QA_OS | sed -e "s/^[_ ]//" -e "s/ /_/g"`
128         echo $QA_OS_STRING >>$PLATFORMLIST
129         if [ "$O_SILENT" != ON ] ; then
130             echo $QA_OS
131         fi
132
133         #grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa | sort -u | sed \
134              #-e "s/.*-OS-LINE: /${QA_SYS}_/" >>$PLATFORMLIST
135         #if [ "$O_SILENT" != ON ] ; then
136             #grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa | sort -u | sed \
137                  #-e "s/.*-OS-LINE:/${QA_SYS}/" 
138         #fi
139     else
140         REM_SYSNAME=$QA_SYS
141         watch_rsh start $REM_SYSNAME &
142         qa_stat_get_sysinfo $QA_SYS
143         watch_rsh stop $REM_SYSNAME 
144         echo $QA_OS_STRING >>$PLATFORMLIST
145                           # use later for missing list
146     fi
147 done
148
149 }
150
151 ################################### qa_stat_init ##########################
152 # local shell function, sets the name of the resultfile to:
153 #    <filename> if option -f <filename>
154 #    $RESULTDIR/result if write permission 
155 #        (mozilla/tests_results/security/result)
156 #    $HOME/resultNSS${NSSVER}-${BUILDDATE} if no write permission in $RESULTDIR
157 ########################################################################
158 qa_stat_init()
159 {
160     if [ $O_FILE = ON -a $O_CRON = OFF ]    # if -f was specified write there 
161     then
162         RFILE=$FILENAME    
163     else
164         RFILE=${RESULTDIR}/result.$$
165         if [ ! -w $RESULTDIR ]
166         then
167             RFILE=$HOME/resultNSS${NSSVER}-${BUILDDATE}.$$
168             Debug "Using alternate resultfile $RFILE"
169         #elif [ $O_CRON = ON ]
170         #then
171              ##find ${RESULTDIR} -exec chmod a+rw {} \;    #FIXME - umask 
172                             ##doesn't seem to work - this is a tmp workaround
173         fi
174     
175         if [ ! -x $RESULTDIR -o ! -r  $RESULTDIR -o ! -w $RESULTDIR ]
176         then
177             glob_usage "$RESULTDIR does not have the right permissions `ls -l $RESULTDIR`"
178         fi
179         if [ -d $RESULTDIR ]
180         then
181             cd $RESULTDIR
182         else
183             glob_usage "$RESULTDIR does not exist"
184         fi
185     fi
186
187     ERRORLIST=${RFILE}.E
188     PLATFORMLIST=${RFILE}.P
189     PERFLIST=${RFILE}.PE
190     TMP_HTML_FILE=${RFILE}.html
191     HTML_FILE=${RESULTDIR}/result.html
192     WARNINGLIST=${RFILE}.W
193     BCMISSINGLIST=${RFILE}.BCM
194     BCERRORLIST=${RFILE}.BCE
195     TMPFILE=${RFILE}.T
196     ML_FILE=${RFILE}.ML
197
198     TMPFILES="$TMPFILES $TMPFILE"
199     TMPFILES="$TMPFILES $ERRORLIST $PLATFORMLIST $PERFLIST $WARNINGLIST \
200        $BCMISSINGLIST $BCERRORLIST $ML_FILE" #FIXME uncomment
201
202     FILENAME=$RFILE        #we might want to mail it...later switch to html file
203     O_FILE="ON"
204
205     rm $ERRORLIST $PLATFORMLIST $PERFLIST $WARNINGLIST \
206        $BCMISSINGLIST $BCERRORLIST $TMP_HTML_FILE  2>/dev/null
207     touch $ERRORLIST $PLATFORMLIST $PERFLIST $WARNINGLIST \
208        $BCMISSINGLIST $BCERRORLIST $TMP_HTML_FILE  2>/dev/null
209
210     if [  $O_WIN = "ON" -a "$O_TBX" = "ON" ] ; then
211         HTML_PATH="http://${URL}${UX_D0}/nss${NSSVER}/tinderbox/tests_results/security/`basename $RESULTDIR`"
212     else
213         HTML_PATH="http://${URL}${RESULTDIR}"
214     fi
215     HREF_TMP_HTML_FILE="${HTML_PATH}/`basename $HTML_FILE`"
216
217     write_qa_header_html >$TMP_HTML_FILE
218 }
219
220 ################################# html_footer #########################
221 # local shell function, writes end of the html body
222 #######################################################################
223 write_qa_header_html()
224 {
225 echo 'Subject: QA Report ' $NSSVER $BUILDDATE '
226 From: sonmi@iplanet.com
227 Reply-To: sonmi@iplanet.com
228 Content-Type: text/html; charset=us-ascii
229 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
230 <html>
231 <head>
232    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
233    <meta name="GENERATOR" content="Mozilla/4.7 [en] (X11; U; SunOS 5.8 sun4u) [N
234 etscape]">
235 </head>
236 <body>
237 <br>
238 &nbsp;
239 <br>&nbsp;
240 <h2>
241 <a href="http://tinderbox.mozilla.org/showbuilds.cgi?tree=NSS">Tinderbox</a
242 ><br>
243 <a href="http://cindercone.red.iplanet.com/share/builds/mccrel3/nss/nsstip/tinderbox/tests_results/security/">Tinderbox QA&nbsp;result</a><br>
244 <a href="ftp://ftp.mozilla.org/pub/security/nss/daily_qa">Mozilla Daily NSS QA&nbsp;result</a></h2>
245 &nbsp;
246
247 &nbsp;
248 <br>&nbsp;
249 <center>
250 <h1>
251 <a NAME="Top"></a><b><font size=+2>QA&nbsp;Results</font></b></h1></center>
252
253
254 <table BORDER WIDTH="100%" NOSAVE >
255 <tr>
256 <td>&nbsp;<b><font size=+1>Build-OS and version</font></b></td>
257 <td><b><font size=+1>QA-OS</font></b></td>
258 <td><b><font size=+1>Systemname</font></b></td>
259 <td><b><font size=+1>P/F</font></b></td>
260 <td><b><font size=+1>result</font></b></td>
261 <td><b><font size=+1>output</font></b></td>
262 <td><b><font size=+1>errors</font></b></td>
263 <td><b><font size=+1>QA time / #</font></b></td>
264 </tr>
265 '
266 }
267
268 ################################# html_footer #########################
269 # local shell function, writes end of the html body
270 #######################################################################
271 html_footer()
272 {
273   echo '</body>'
274   echo '</html>'
275 }
276
277 ################################# setQAsysvars #########################
278 # local shell function, sets system specific variables
279 ########################################################################
280 setQAsysvars()
281 {
282     if [ "$MACHINE" != "0" ]
283     then
284         MACHINE=`echo $MACHINE | sed -e 's/^bct.//g'`
285         TESTDATE=`ls -ld $MACHINE | awk '{ print $6, $7, $8 }'`
286         TESTNUMBER=`echo $MACHINE | sed -e 's/.*\.//'`
287         SYSNAME=`echo $MACHINE | sed -e 's/\..*//'`
288         Debug "SYSNAME= $SYSNAME"
289
290         if [  "$O_TBX" = "ON" -o "$O_LOCAL" = "ON" ] ; then
291             QA_SYS_OS=$QA_OS
292         else
293             QA_SYS_OS=`grep $SYSNAME $PLATFORMLIST |
294                 sed -e 's/\r//' | \
295                 sort | uniq | sed  -e "s/$SYSNAME//" \
296                 -e "s/^_//" | sort | uniq`
297         fi
298         Debug "QA_SYS_OS= $QA_SYS_OS"
299     fi
300     BUILD_SYS=`echo $BUILDPLATFORM | sed -e 's/\.OBJ//' -e 's/_DBG/ Debug/' \
301             -e 's/_OPT/ Optimized/'  -e 's/_64/ 64bit/' -e 's/_glibc_PTH//' \
302             -e 's/_/ /'`
303     Debug "BUILD_SYS=$BUILD_SYS"
304     if [ -f "${RESULTDIR}/${MACHINE}/results.html" ] ; then
305         RESULT="${HTML_PATH}/${MACHINE}/results.html"
306     else
307         RESULT="0"
308     fi
309     if [ -f "${RESULTDIR}/bct/${MACHINE}/results.html" ] ; then
310         BCB_RESULT="${HTML_PATH}/bct/${MACHINE}/results.html"
311     else
312       BCB_RESULT="0"
313     fi
314
315     if [ -f "${RESULTDIR}/${MACHINE}/output.log" ] ; then
316         LOG="${HTML_PATH}/${MACHINE}/output.log"
317     else
318         LOG="0"
319     fi
320     if [ -f "${RESULTDIR}/bct/${MACHINE}/output.log" ] ; then
321         BCB_LOG="${HTML_PATH}/bct/${MACHINE}/output.log"
322     else
323         BCB_LOG="0"
324     fi
325 }
326
327 ################################# html_line() #########################
328 # local shell function, writes a line in the html table
329 ########################################################################
330 html_line()
331 {
332   echo '<tr NOSAVE>'
333   echo '<td NOSAVE>'$BUILD_SYS'</td>'
334   echo ''
335   if [ "$QA_SYS_OS" != "0" ] ; then
336       echo '<td NOSAVE>'$QA_SYS_OS'</td>'
337   else
338       echo '<td></td>'
339   fi
340   echo ''
341   if [ "$SYSNAME" != "0" ] ; then
342       echo '<td>'$SYSNAME'</td>'
343   else
344       echo '<td></td>'
345   fi
346   #echo '<td>'$SYSNAME $TESTNUMBER $TESTDATE'</td>'
347   echo ''
348   # hopefully we never run more different tests on a tinderbox build...
349   # on win some shells can not handle exit codes greater then 52 (64???)
350   # so for very early exits the codes are set 50-45, for failures later
351   # in the process the higher the number, the more failures
352   if [ "$O_TBX" = "ON" -a "$TBX_EXIT" -gt 45 ] ; then
353       TBX_EXIT=0
354   fi
355   if [ "$1" = "failed" ]
356   then
357       TBX_EXIT=`expr $TBX_EXIT + 1`
358       echo '<td BGCOLOR='$HTML_ERRORCOLOR' NOSAVE><b>'$HTML_ERRORMSG'</b></td>'
359   elif [ "$1" = "passed" ]
360   then
361       echo '<td BGCOLOR='$HTML_PASSEDCOLOR' NOSAVE>'$HTML_PASSEDMSG'</td>'
362   elif [ "$1" = "incomplete" ]
363   then
364       TBX_EXIT=`expr $TBX_EXIT + 1`
365       echo '<td BGCOLOR='$HTML_INCOMPLETECOLOR' NOSAVE>'$HTML_INCOMPLETEMSG'</td>'
366   else
367       TBX_EXIT=`expr $TBX_EXIT + 1`
368       echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'    
369   fi
370   if [ "$CURRENT_TABLE" != "BC" ] ; then
371       if [ "$RESULT" = "0" ] ; then
372           echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'
373       else
374           echo '<td>&nbsp;<a href="'$RESULT'">result</a>&nbsp;</td>'
375       fi
376       if [ "$LOG" = "0" ] ; then
377           echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'
378       else
379           echo '<td>&nbsp;<a href="'$LOG'">log</a>&nbsp;</td>'
380       fi
381       if [ "$1" = "failed" ] ; then
382           echo '<td>&nbsp;<a href="'${HREF_TMP_HTML_FILE}'#errorlist">error</a>&nbsp;</td>'
383       else
384           echo '<td></td>'
385       fi
386   else
387      #<td><b><font size=+1>errors</font></b></td>
388      #<td><b><font size=+1>P/F</font></b></td>
389      #<td><b><font size=+1>P/F</font></b></td>
390
391      #echo '<td><b><font size=+1>All Current</font></b></td>'
392      #echo '<td><b><font size=+1>old dlls</font></b></td>'
393      #echo '<td><b><font size=+1>old executables</font></b></td>'
394       #if [ "$RESULT" != "0" -a "$LOG" != "0" ] ; then
395           #echo '<td><a href="'$RESULT'">result</a>, <a href="'$LOG'">log</td>'
396       #elif [ "$RESULT" = "0" -a "$LOG" != "0" ] ; then
397           #echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE><a href="'$LOG'">log</a></td>'
398       #elif [ "$RESULT" != "0" -a "$LOG" = "0" ] ; then
399           #echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE><a href="'$RESULT'">result</a></td>'
400       #else
401           #echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'
402       #fi
403       #if [ "$BCB_RESULT" != "0" -a "$BCB_LOG" != "0" ] ; then
404           #echo '<td><a href="'$BCB_RESULT'">result</a>, <a href="'$BCB_LOG'"> log</td>'
405       #elif [ "$BCB_RESULT" = "0" -a "$BCB_LOG" != "0" ] ; then
406           #echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE><a href="'$BCB_LOG'">log</a></td>'
407       #elif [ "$BCB_RESULT" != "0" -a "$BCB_LOG" = "0" ] ; then
408           #echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE><a href="'$BCB_RESULT'">result</a></td>'
409       #else
410           #echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'
411       #fi
412       if [ "$BCB_RESULT" = "0" ] ; then
413           echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'
414       else
415           echo '<td>&nbsp;<a href="'$BCB_RESULT'">result</a>&nbsp;</td>'
416       fi
417       if [ "$BCB_LOG" = "0" ] ; then
418           echo '<td BGCOLOR='$HTML_MISSINGCOLOR' NOSAVE>'$HTML_MISSINGMSG'</td>'
419       else
420           echo '<td>&nbsp;<a href="'$BCB_LOG'">log</a>&nbsp;</td>'
421       fi
422   fi
423   echo '<td>'$TESTDATE $TESTNUMBER'</td>'
424   echo '</tr>'
425 }
426
427 ################################# qa_errorlist #########################
428 # local shell function, finds problems in the previously run QA
429 # linux:the gnu grep, on Linux can output 10 lines above and 3 lines below 
430 # the errormessage
431 ########################################################################
432 qa_errorlist()
433 {
434     grep "bgcolor=red" ${MACHINES_TO_CHECK}*/results.html | 
435         sed -e 's/.results.html:<TR><TD>/ /' -e 's/<[^>]*>/ /g'
436     grep 'cache hits; .* cache misses, .* cache not reusable' \
437         ${MACHINES_TO_CHECK}*/output.log | 
438         grep strsclnt |
439         grep -v '0 cache hits; 0 cache misses, 0 cache not reusable' | 
440         grep -v ' cache hits; 1 cache misses, 0 cache not reusable'
441     for logfile in ${MACHINES_TO_CHECK}*/output.log; do
442         grep -vi "write to SSL socket" $logfile |
443             grep -vi "HDX PR_Read returned error" |
444             grep -vi "no error" |
445             grep -vi "12285" |
446             grep -i  $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP error 
447             #grep -vi "5938" |  needed for -v option
448             #grep -vi "HDX PR_Read hit EOF" | 
449         grep  -vi "write to SSL socket" $logfile |
450             grep -vi "peer cannot verify" |
451             grep -vi "error" |
452             grep -vi "fatal" |
453             grep -vi "TCP Connection aborted" |
454             grep -vi "TCP connection reset" |
455             grep  $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP  -i failed
456     done
457     grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "segmentation violation" \
458         ${MACHINES_TO_CHECK}*/output.log
459     grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "memory fault" \
460         ${MACHINES_TO_CHECK}*/output.log
461     grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "bus error" \
462         ${MACHINES_TO_CHECK}*/output.log
463     grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "core dumped" \
464         ${MACHINES_TO_CHECK}*/output.log
465     grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP fatal \
466         ${MACHINES_TO_CHECK}*/output.log
467     grep -i  $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP -i\
468         "PKCS12 decode not verified"   ${MACHINES_TO_CHECK}*/output.log
469
470     if [ -n "${MACHINES_TO_CHECK}" ] ; then
471         find ${MACHINES_TO_CHECK}* -name core -print 2>/dev/null |
472             grep -v bct 
473     else
474         find . -name core -print 2>/dev/null |
475             grep -v bct 
476     fi
477 }
478
479 tbx_missing_platforms ()
480 {
481     QA_MISSING="QA report missing"
482     MACHINE="0"
483
484     if [ "$QA_OS_STRING" = "WINNT4.0" ] ; then
485         QA_OS_STRING="Windows-NT-4.0"
486     fi
487     for BUILDPLATFORM in `grep $QA_OS_STRING $TESTSCRIPTDIR/platformlist.tbx`
488     do
489         if [ "$BUILDPLATFORM" != "$QA_OS_STRING" ] ; then
490             Debug  "BUILDPLATFORM = $BUILDPLATFORM QA_OS_STRING = $QA_OS_STRING"
491             grep $BUILDPLATFORM ${MACHINES_TO_CHECK}*/results.html \
492                 >/dev/null || {
493                 setQAsysvars
494                 html_line missing >>$TMP_HTML_FILE
495             }
496         fi
497     done
498 }
499
500 ############################ platform _list ###########################
501 # local shell function, generate pass/fail information for each Platform
502 ########################################################################
503 platformlist()
504 {
505     grep Platform ${MACHINES_TO_CHECK}*/results.html | 
506         sed -e 's/.results.html:<H4>Platform: /---/' \
507             -e 's/<BR>//' >$TMPFILE
508     # this is done a little complicated to avoid starting a subshell in 
509     # a while read that gets the input from a pipeline, and variables set 
510     #in or underneath this function get unset after done...
511     for  MB in `cat $TMPFILE` ; do
512         MACHINE=`echo $MB | sed -e "s/---.*//"`
513         BUILDPLATFORM=`echo $MB | sed -e "s/.*---//"`
514         grep "${MACHINE}[^0-9]" $ERRORLIST >/dev/null
515         ret=$?
516         setQAsysvars
517         if [ $ret -eq 0 ]
518         then
519             echo "Failed $MACHINE $BUILDPLATFORM" >>$RFILE
520             html_line failed >>$TMP_HTML_FILE
521         else
522             echo "Passed $MACHINE $BUILDPLATFORM" >>$RFILE
523             html_line passed >>$TMP_HTML_FILE
524         fi
525     done 
526 }
527
528 ############################ missing_platforms ###########################
529 # local shell function, finds out if we ran on all required platforms
530 ########################################################################
531 missing_platforms()
532 {
533     QA_MISSING="QA report missing"
534     MACHINE="0"
535     SYSNAME="0"
536     QA_SYS_OS="0"
537
538     for BUILDPLATFORM in `cat $TESTSCRIPTDIR/platformlist`
539     do
540         grep $BUILDPLATFORM $PLATFORMLIST > /dev/null || {
541             setQAsysvars
542             html_line missing >>$TMP_HTML_FILE
543         }
544     done
545 }
546
547 ############################ incomplete_results ###########################
548 # local shell function, finds out if all qa runs were complete
549 ########################################################################
550 incomplete_results ()
551 {
552     
553     for w in `ls ${MACHINES_TO_CHECK}*/results.html`
554     do
555       grep bgcolor=red $w || {
556         PASSED_LINES=""
557         PASSED_LINES=`grep bgcolor=lightGreen $w | wc -l`
558         if [ -n "$PASSED_LINES" -a "$PASSED_LINES" -lt "$TOTAL_TESTS" ] ; then
559             BUILDPLATFORM=`grep Platform $w | sed -e 's/<H4>Platform:/    /'                   -e 's/<BR>//'` 
560             MACHINE=`echo $w | sed -e "s/.results.html//"`
561             #MACHINE=`echo $w | sed -e "s/\.[0-9]*.results.html//"`
562             setQAsysvars
563             html_line incomplete >>$TMP_HTML_FILE
564         elif [ "$PASSED_LINES" -gt "$TOTAL_TESTS" ] ; then
565             echo "WARNING - more tests than expected on $w ($PASSED_LINES)" >>$WARNINGLIST
566         fi
567       }
568     done
569 }
570
571 qa_stat_table()
572 {
573     echo '&nbsp;'
574     echo '<br>&nbsp;'
575     echo '<center>'
576     echo '<h1>'
577     echo '<a NAME="'$1'"></a>'$1'</h1></center>'
578     echo '&nbsp;'
579     echo '<table BORDER WIDTH="100%" NOSAVE >'
580     echo '<tr NOSAVE>'
581 }
582
583 ############################### psaperf ########################
584 # local shell function, copies results of the daily performance test
585 # into a table in the QA report
586 ########################################################################
587 rsaperf()
588 {
589     grep RSAPERF */output.log | grep -v "_DBG" > $PERFLIST
590     
591     qa_stat_table "Performance list"
592
593     echo '<td NOSAVE><b><font size=+1>Build-OS and version</font></b></td>'
594     echo '<td><b><font size=+1>Systemname</font></b></td>'
595     echo '<td><b><font size=+1># of iterations</font></b></td>'
596     echo '<td><b><font size=+1>average for one op</font></b></td>'
597     echo '<td><b><font size=+1>Total</font></b></td>'
598     echo '<td><b><font size=+1>QA time / #</font></b></td>'
599     echo '</tr>'
600     cat $PERFLIST | 
601     while read MACHINE BUILDPLATFORM no_iter t1 t2 total total_unit t3 \
602                t4 t5 average average_unit
603     do
604         #caution subshell, variables local to this loop
605         BUILD_SYS=`echo $BUILDPLATFORM | sed -e 's/\.OBJ//' \
606             -e 's/_DBG/ Debug/' \
607             -e 's/_OPT/ Optimized/'  -e 's/_64/ 64bit/' -e 's/_glibc_PTH//' \
608             -e 's/_/ /'`
609         TESTNUMBER=`echo $MACHINE | sed -e 's/[^\.]*\.//' -e 's/\/.*//'`
610         MACHINE=`echo $MACHINE | sed -e 's/\..*//'`
611         TESTDATE=`ls -ld ${MACHINE}.${TESTNUMBER} | awk '{ print $6, $7, $8 }'`
612         echo '<tr>'
613         echo '<td>'$BUILD_SYS'</td>'
614         echo ''
615         echo '<td>'$MACHINE'</td>'
616         echo ''
617         echo '<td>'$no_iter'</td>'
618         echo ''
619         echo '<td>'$average' '$average_unit'</td>'
620         echo ''
621         echo '<td>'$total' '$total_unit'</td>'
622         echo ''
623         echo '<td>'$TESTDATE $TESTNUMBER'</td>'
624         echo ''
625         echo '</tr>'
626     done
627     echo '</table>'
628 }
629
630 ############################### qa_stat_cleanup ########################
631 # local shell function, finishes html file, sets variables for global Exit
632 ########################################################################
633 qa_stat_cleanup()
634 {
635
636     html_footer >>$TMP_HTML_FILE
637
638     O_DEBUG=OFF
639
640     EARLY_EXIT=FALSE
641     cp $TMP_HTML_FILE $HTML_FILE
642     FILENAME=$HTML_FILE        #we might want to mail it...
643     Exit
644 }
645
646
647 ############################### bc_test ########################
648 # local shell function, evaluates the results of the backward u
649 # compatibility tests
650 ########################################################################
651 bc_header()
652 {
653 CURRENT_TABLE="BC"   #so html_line can determine which fields to write
654   
655   qa_stat_table "Backward Compatibility Test"
656   echo '<td NOSAVE><b><font size=+1>Build-OS and version</font></b></td>'
657   echo '<td><b><font size=+1>QA-OS</font></b></td>'
658   echo '<td><b><font size=+1>Systemname</font></b></td>'
659   echo '<td><b><font size=+1>P/F</font></b></td>'
660   #echo '<td><b><font size=+1>All Current</font></b></td>'
661   #echo '<td><b><font size=+1>backward comp. test</font></b></td>'
662   echo '<td><b><font size=+1>result</font></b></td>'
663   echo '<td><b><font size=+1>output</font></b></td>'
664   echo '<td><b><font size=+1>QA time / #</font></b></td>'
665   echo '</tr>'
666
667 }
668
669 old_bc_test()
670 {
671 CURRENT_TABLE="BC"   #so html_line can determine which fields to write
672   
673   qa_stat_table "Backward Compatibility Test"
674   echo '<td NOSAVE><b><font size=+1>Build-OS and version</font></b></td>'
675   echo '<td><b><font size=+1>QA-OS</font></b></td>'
676   echo '<td><b><font size=+1>Systemname</font></b></td>'
677   echo '<td><b><font size=+1>P/F</font></b></td>'
678   #echo '<td><b><font size=+1>All Current</font></b></td>'
679   #echo '<td><b><font size=+1>backward comp. test</font></b></td>'
680   echo '<td><b><font size=+1>result</font></b></td>'
681   echo '<td><b><font size=+1>output</font></b></td>'
682   echo '<td><b><font size=+1>QA time / #</font></b></td>'
683   echo '</tr>'
684
685   for w in `ls */results.html`
686   do
687       TMP_RESULT="`dirname $w`/results.tmp"
688       TMP_BC_RESULT="`dirname bct/$w`/results.tmp"
689       rm $TMP_RESULT $TMP_BC_RESULT 2>/dev/null
690       cat $w | sed -e 's/<[^>]*>//g'  -e 's/ /_/g' \
691                    -e 's/signtool_-[vw]/signtool_-vw/' |
692                grep '_[PF]a[si][sl]ed' >$TMP_RESULT
693       cat bct/$w   | sed -e 's/<[^>]*>//g'  -e 's/ /_/g' \
694                          -e 's/signtool_-[vw]/signtool_-vw/' |
695                      grep '_[PF]a[si][sl]ed' >$TMP_BC_RESULT
696       diff $TMP_RESULT $TMP_BC_RESULT    2>>$BCMISSINGLIST |
697            grep -v "Create_objsign_cert_.signtool_-G.*Passed" |
698            grep -v "porting_Alice.s_email_cert" |
699            grep -v "^[0-9,cad]*$" | grep -v "^---$" | grep -v "^---.$" |
700            grep -v "Can.t_run_pk12util_tests_for_NSS_3.2"  >/dev/null && (
701                 echo "$w differs" >> $BCMISSINGLIST
702                 echo "========================================="
703                 echo "diff $w bct/$w"
704                 echo "========================================="
705                 diff $TMP_RESULT $TMP_BC_RESULT 2>&1 |
706                      grep -v "Create_objsign_cert_.signtool_-G.*Passed" |
707                      grep -v "porting_Alice.s_email_cert" |
708                      grep -v "Can.t_run_pk12util_tests_for_NSS_3.2"  
709            )  2>&1 >>$BCERRORLIST
710
711       #diff -b $w bct/$w  2>>$BCMISSINGLIST | 
712            #grep -v "Create objsign cert .signtool -G.*Passed" |
713            #grep -v "Listing signed files in jar .signtool -v.*Passed" |
714            #grep -v "Listing signed files in jar .signtool -w.*Passed" |
715            #grep -v "backward compatibility" |
716            #grep -v "Can.t run pk12util tests for NSS 3.2" |
717            #grep -v "porting Alice.s email cert " |
718            #grep -v "^---$" | grep -v "^[<> ] $" | 
719            #grep -v "^---.$" | grep -v "^[<> ] .$" | 
720            #grep -v '< </BODY></HTML>' |
721            #grep -v "^[0-9,cad]*$" 2>>$BCMISSINGLIST >/dev/null &&  (
722                 #echo "$w differs" >> $BCMISSINGLIST
723                 #echo "========================================="
724                 #echo "diff $w bct/$w"
725                 #echo "========================================="
726                 #diff -b $w bct/$w 2>&1 | 
727                      #grep -v "Listing signed files in jar .signtool -v.*Passed" |
728                      #grep -v "Listing signed files in jar .signtool -w.*Passed" |
729                      #grep -v "backward compatibility" |
730                      #grep -v "Can.t run pk12util tests for NSS 3.2" |
731                      #grep -v "porting Alice.s email cert " |
732                      #grep -v "^---$" | grep -v "^[<> ] $" | 
733                      #grep -v "^---.$" | grep -v "^[<> ] .$" | 
734                      #grep -v '< </BODY></HTML>' |
735                      #grep -v "^[0-9,cad]*$" \
736            #)  2>&1 >>$BCERRORLIST
737       rm $TMP_RESULT $TMP_BC_RESULT 2>/dev/null
738   done
739   rm $ERRORLIST
740   cat $BCMISSINGLIST | sed -e "s/^diff: bc_...s.//" \
741                     -e "s/.results.html.*/\/results.html/" | 
742                 sort -u > $ERRORLIST
743
744   platformlist  
745   echo '</table>' >>$TMP_HTML_FILE
746
747   head -200 $BCERRORLIST | sed -e 's/<[^>]*>//g' -e "s/^/<br>/" 
748 }
749
750 bc_test()
751 {
752 CURRENT_TABLE="BC"   #so html_line can determine which fields to write
753   
754   qa_stat_table "Backward Compatibility Test"
755   echo '<td NOSAVE><b><font size=+1>Build-OS and version</font></b></td>'
756   echo '<td><b><font size=+1>QA-OS</font></b></td>'
757   echo '<td><b><font size=+1>Systemname</font></b></td>'
758   echo '<td><b><font size=+1>P/F</font></b></td>'
759   #echo '<td><b><font size=+1>All Current</font></b></td>'
760   #echo '<td><b><font size=+1>backward comp. test</font></b></td>'
761   echo '<td><b><font size=+1>result</font></b></td>'
762   echo '<td><b><font size=+1>output</font></b></td>'
763   echo '<td><b><font size=+1>QA time / #</font></b></td>'
764   echo '</tr>'
765
766 set -x
767   for w in `ls */results.html`
768   do
769       BCT_DIR=`dirname "bct/$w"`
770       BCT_RESULT="bct/$w"
771       BCT_LOG="$BCT_DIR/output.log"
772       grep "bgcolor=red" $BCT_RESULT | 
773            sed -e 's/.results.html:<TR><TD>/ /' -e 's/<[^>]*>/ /g'
774       grep 'cache hits; .* cache misses, .* cache not reusable' \
775         $BCT_LOG |
776         grep -v selfserv |
777         grep -v '0 cache hits; 1 cache misses, 0 cache not reusable' |
778         grep -v '0 cache hits; 0 cache misses, 0 cache not reusable' |
779         grep -v ' cache hits; 1 cache misses, 0 cache not reusable'
780       grep -vi "write to SSL socket" $BCT_LOG |
781         grep -vi "HDX PR_Read returned error" |
782         grep -vi "no error" |
783         grep -vi "12285" |
784         grep -i  $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP error
785       grep  -vi "write to SSL socket" $BCT_LOG |
786         grep -vi "peer cannot verify" |
787         grep -vi "TCP Connection aborted" |
788         grep -vi "error" |
789         grep -vi "fatal" |
790         grep -vi "TCP connection reset" |
791         grep  $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP  -i failed $BCT_LOG
792       grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "segmentation violation"  $BCT_LOG
793       grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "memory fault" $BCT_LOG
794       grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "bus error" $BCT_LOG
795       grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP "core dumped" $BCT_LOG
796       grep -i $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP fatal  $BCT_LOG
797       grep -i  $BEFORE_CONTEXT_GREP $AFTER_CONTEXT_GREP -i "PKCS12 decode not verified"   $BCT_LOG
798       find ${BTC_DIR} -name core -print
799
800   done 2>&1 >>$BCERRORLIST
801   rm $ERRORLIST
802   cat $BCMISSINGLIST | sed -e "s/^diff: bc_...s.//" \
803                     -e "s/.results.html.*/\/results.html/" | 
804                 sort -u > $ERRORLIST
805
806   platformlist  
807   echo '</table>' >>$TMP_HTML_FILE
808
809   head -200 $BCERRORLIST | sed -e 's/<[^>]*>//g' -e "s/^/<br>/" 
810 }
811
812
813 ############################### bc_test ########################
814 # local shell function, evaluates the results of the backward u
815 # compatibility tests
816 # move the whole function to old to tests a new solution
817 ########################################################################
818 bc_test_old()
819 {
820 CURRENT_TABLE="BC"   #so html_line can determine which fields to write
821   
822   qa_stat_table "Backward Compatibility Test"
823   echo '<td NOSAVE><b><font size=+1>Build-OS and version</font></b></td>'
824   echo '<td><b><font size=+1>QA-OS</font></b></td>'
825   echo '<td><b><font size=+1>Systemname</font></b></td>'
826   echo '<td><b><font size=+1>P/F</font></b></td>'
827   #echo '<td><b><font size=+1>All Current</font></b></td>'
828   #echo '<td><b><font size=+1>backward comp. test</font></b></td>'
829   echo '<td><b><font size=+1>result</font></b></td>'
830   echo '<td><b><font size=+1>output</font></b></td>'
831   echo '<td><b><font size=+1>QA time / #</font></b></td>'
832   echo '</tr>'
833
834   for w in `ls */results.html`
835   do
836       diff -b $w bct/$w  2>>$BCMISSINGLIST | 
837            grep -v "Create objsign cert .signtool -G.*Passed" |
838            grep -v "Listing signed files in jar .signtool -v.*Passed" |
839            grep -v "Listing signed files in jar .signtool -w.*Passed" |
840            grep -v "backward compatibility" |
841            grep -v "Can.t run pk12util tests for NSS 3.2" |
842            grep -v "porting Alice.s email cert " |
843            grep -v "^---$" | grep -v "^[<> ] $" | 
844            grep -v "^---.$" | grep -v "^[<> ] .$" | 
845            grep -v '< </BODY></HTML>' |
846            grep -v "^[0-9,cad]*$" 2>>$BCMISSINGLIST >/dev/null &&  (
847                 echo "$w differs" >> $BCMISSINGLIST
848                 echo "========================================="
849                 echo "diff $w bct/$w"
850                 echo "========================================="
851                 diff -b $w bct/$w 2>&1 | 
852                      grep -v "Listing signed files in jar .signtool -v.*Passed" |
853                      grep -v "Listing signed files in jar .signtool -w.*Passed" |
854                      grep -v "backward compatibility" |
855                      grep -v "Can.t run pk12util tests for NSS 3.2" |
856                      grep -v "porting Alice.s email cert " |
857                      grep -v "^---$" | grep -v "^[<> ] $" | 
858                      grep -v "^---.$" | grep -v "^[<> ] .$" | 
859                      grep -v '< </BODY></HTML>' |
860                      grep -v "^[0-9,cad]*$" \
861            )  2>&1 >>$BCERRORLIST
862   done
863   rm $ERRORLIST
864   cat $BCMISSINGLIST | sed -e "s/^diff: bc_...s.//" \
865                     -e "s/.results.html.*/\/results.html/" | 
866                 sort -u > $ERRORLIST
867
868   platformlist  
869   echo '</table>' >>$TMP_HTML_FILE
870
871   head -200 $BCERRORLIST | sed -e 's/<[^>]*>//g' -e "s/^/<br>/" 
872
873 }
874
875 ############################### tbx_main ########################
876 # local shell function, tinderbox variation of the qa status script
877 ########################################################################
878 tbx_main()
879 {
880     TBX_EXIT=47
881     qa_stat_get_sysinfo # find out the OS we are running and all required tests
882                         # on this OS
883     
884     MACHINES_TO_CHECK=$HOST  #`uname -n` only search the local tests for errors
885     qa_errorlist > $ERRORLIST        # 
886     platformlist 
887     #tbx_missing_platforms  #temp. taken out until we find a better way to
888     #determine if all necessary QA ran - right now we run different 
889     #tinderboxes on one machine
890     incomplete_results 
891     echo '</table>' >>$TMP_HTML_FILE
892     echo '<a NAME="errorlist"></a>' >> $TMP_HTML_FILE
893     cat $ERRORLIST  | sed -e "s/^/<br>/" >>$TMP_HTML_FILE
894
895 }
896
897 ############################### qa_stat_main ########################
898 # local shell function, main flow of the qa status script
899 ########################################################################
900 qa_stat_main()
901 {
902     find_qa_systems 2>/dev/null
903     MACHINES_TO_CHECK=""   # check all founf qa runs
904     qa_errorlist > $ERRORLIST
905     platformlist 
906     missing_platforms 
907     incomplete_results 
908     echo '</table>' >>$TMP_HTML_FILE
909     echo '<a NAME="errorlist"></a>' >> $TMP_HTML_FILE
910     cat $ERRORLIST  | sed -e "s/^/<br>/" >>$TMP_HTML_FILE
911     cat $WARNINGLIST 2>/dev/null | sed -e "s/^/<br>/" >>$TMP_HTML_FILE 2>/dev/null
912     rsaperf >>$TMP_HTML_FILE
913     bc_header >>$TMP_HTML_FILE
914     MACHINES_TO_CHECK="bct/"
915     TOTAL_TESTS=$BCT_TOTAL_TESTS
916     BEFORE_CONTEXT_GREP="" #WORKAROUND - errors in one outputlog within the first 
917     AFTER_CONTEXT_GREP=""  # or last lines will show up in the next/previos file
918     qa_errorlist > $ERRORLIST
919     platformlist 
920     missing_platforms 
921     incomplete_results 
922     echo '</table>' >>$TMP_HTML_FILE
923     echo '<a NAME="errorlist"></a>' >> $TMP_HTML_FILE
924     cat $ERRORLIST  | sed -e "s/^/<br>/" >>$TMP_HTML_FILE
925     cat $WARNINGLIST 2>/dev/null | sed -e "s/^/<br>/" >>$TMP_HTML_FILE 2>/dev/null
926     #bc_test >>$TMP_HTML_FILE
927 }
928
929 CURRENT_TABLE="Standard"
930 qa_stat_init
931
932 if [  "$O_TBX" = "ON" -o "$O_LOCAL" = "ON" ] ; then
933     tbx_main
934 else
935     qa_stat_main
936 fi
937
938 qa_stat_cleanup