#! /bin/sh
########################################################################
#
# /u/sonmi/bin/qa_stat - /u/svbld/bin/init/nss/qa_stat
#
#
this script is supposed to automatically run QA
for NSS on all required
# Unix platforms
#
# parameters
# ----------
# nssversion (supported: 30b, 31, tip)
# builddate (
default - today)
#
# options
# -------
# -y answer all questions with y - use at your own risk...ignores warnings
# -s silent (only usefull with -y)
# -h, -? - you guessed right - displays
this text
# -d debug
# -f <filename> - write the (error)output to filename
# -m <mailinglist> - send filename to mailinglist (csl) only useful
# with -f
# -cron equivalient to -y -s -d -f $RESULTDIR/$HOST.qa_stat
#
########################################################################
O_OPTIONS=ON
TBX_EXIT=49 # in
case we are running on a tinderbox build, any
# early exit needs to
return an error
if [ -z
"$O_TBX" -o
"$O_TBX" =
"OFF" ] ; then
if [ -z
"$O_LOCAL" -o
"$O_LOCAL" =
"OFF" ] ; then
. `dirname $0`/header
fi
fi
Debug
"Sourced header O_TBX=$O_TBX O_LOCAL=$O_LOCAL"
TBX_EXIT=48
EARLY_EXIT=
TRUE
URL=
"cindercone.red.iplanet.com"
DOCDIR=/u/sonmi/doc
HTML_ERRORCOLOR=\
"#FF0000\"
HTML_ERRORMSG=Failed
HTML_MISSINGCOLOR=\
"#FFFFCC\"
HTML_MISSINGMSG=Missing
HTML_INCOMPLETECOLOR=$HTML_MISSINGCOLOR
HTML_INCOMPLETEMSG=Incomplete
HTML_PASSEDCOLOR=\
"#66FF99\"
HTML_PASSEDMSG=Passed
#
this file is used to deal with hanging rsh - a
new shell is started
#
for each rsh, and a
function is called after it is finished - they
# communicate with
this file
RSH_FILE=$TMP/rsh.$$
echo >$RSH_FILE
TMPFILES=
"$TMPFILES $WARNINGLIST $RSH_FILE "
RSH_WAIT_TIME=80 #maximum time allowed
for the 2 rsh to finish...
#TOTAL_TESTS=106
TOTAL_TESTS=252 #tip
#TOTAL_TESTS=244 #3.4
#TOTAL_TESTS=123 #3.3.2
BCT_TOTAL_TESTS=122 #3.2.2
#TOTAL_TESTS=133 #tip
Debug
"NTDIST $NTDIST"
Debug
"UXDIST $UXDIST"
Debug
"TESTSCRIPTDIR $TESTSCRIPTDIR"
Debug
"RESULTDIR $RESULTDIR"
############################### watch_rsh ##############################
# local shell
function, deals with a hanging rsh (kills it...)
#
this function is started as a backgroundprocess before the rsh is started,
# and writes info to the RSH_FILE, after the rsh is finished it writes finish
# info to the same file (
this time called as a
function, forground).
# the backgroundprocess stays around
for RSH_WAIT_TIME,
if then the finish
# information is not there attempts to kill the rsh
#
# watch_rsh start qa_computername &
# watch_rsh stop qa_computername
#
########################################################################
watch_rsh()
{
case $1 in
start)
echo
"$2 started" >>$RSH_FILE
sleep $RSH_WAIT_TIME
O_ALWAYS_YES=ON # may modify global flags because
this is a
# forked off bg process - kill_by_name otherwise
# will ask the user
if it really should be killed
grep
"$2 finished" $RSH_FILE >/dev/
null || kill_by_name
"rsh $2"
exit
;;
stop)
echo
"$2 finished" >>$RSH_FILE
;;
esac
}
############################### find_qa_systems ########################
# local shell
function, tries to determine the QA operating system
# works remotely, and
for Windows machines
########################################################################
find_qa_systems()
{
for QA_SYS in `ls $RESULTDIR | grep
'\.1$' | sed -e
"s/\..*//" | sort -u`
do
NO_RSH=
"FALSE"
QA_OS=
""
QA_RHVER=
""
IS_64=
""
IS_WIN=
""
grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa >/dev/
null && NO_RSH=
TRUE
if [
"$NO_RSH" =
"TRUE" ]
then
QA_OS=`grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa | sort -u | sed \
-e
"s/.*-OS-LINE: /${QA_SYS}/"`
QA_OS_STRING=`echo $QA_OS | sed -e
"s/^[_ ]//" -e "s/ /_/g"`
echo $QA_OS_STRING >>$PLATFORMLIST
if [
"$O_SILENT" != ON ] ; then
echo $QA_OS
fi
#grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa | sort -u | sed \
#-e
"s/.*-OS-LINE: /${QA_SYS}_/" >>$PLATFORMLIST
#
if [
"$O_SILENT" != ON ] ; then
#grep OS-LINE ${RESULTDIR}/${QA_SYS}.nssqa | sort -u | sed \
#-e
"s/.*-OS-LINE:/${QA_SYS}/"
#fi
else
REM_SYSNAME=$QA_SYS
watch_rsh start $REM_SYSNAME &
qa_stat_get_sysinfo $QA_SYS
watch_rsh stop $REM_SYSNAME
echo $QA_OS_STRING >>$PLATFORMLIST
# use later
for missing list
fi
done
}
################################### qa_stat_init ##########################
# local shell
function, sets the name of the resultfile to:
# <filename>
if option -f <filename>
# $RESULTDIR/result
if write permission
# (mozilla/tests_results/security/result)
# $HOME/resultNSS${NSSVER}-${BUILDDATE}
if no write permission in $RESULTDIR
########################################################################
qa_stat_init()
{
if [ $O_FILE = ON -a $O_CRON = OFF ] #
if -f was specified write there
then
RFILE=$FILENAME
else
RFILE=${RESULTDIR}/result.$$
if [ ! -w $RESULTDIR ]
then
RFILE=$HOME/resultNSS${NSSVER}-${BUILDDATE}.$$
Debug
"Using alternate resultfile $RFILE"
#elif [ $O_CRON = ON ]
#then
##find ${RESULTDIR} -exec chmod a+rw {} \; #FIXME - umask
##doesn
't seem to work - this is a tmp workaround
fi
if [ ! -x $RESULTDIR -o ! -r $RESULTDIR -o ! -w $RESULTDIR ]
then
glob_usage
"$RESULTDIR does not have the right permissions `ls -l $RESULTDIR`"
fi
if [ -d $RESULTDIR ]
then
cd $RESULTDIR
else
glob_usage
"$RESULTDIR does not exist"
fi
fi
ERRORLIST=${RFILE}.E
PLATFORMLIST=${RFILE}.P
PERFLIST=${RFILE}.PE
TMP_HTML_FILE=${RFILE}.html
HTML_FILE=${RESULTDIR}/result.html
WARNINGLIST=${RFILE}.W
BCMISSINGLIST=${RFILE}.BCM
BCERRORLIST=${RFILE}.BCE
TMPFILE=${RFILE}.T
ML_FILE=${RFILE}.ML
TMPFILES=
"$TMPFILES $TMPFILE"
TMPFILES=
"$TMPFILES $ERRORLIST $PLATFORMLIST $PERFLIST $WARNINGLIST \
$BCMISSINGLIST $BCERRORLIST $ML_FILE
" #FIXME uncomment
FILENAME=$RFILE #we might want to mail it...later
switch to html file
O_FILE=
"ON"
rm $ERRORLIST $PLATFORMLIST $PERFLIST $WARNINGLIST \
$BCMISSINGLIST $BCERRORLIST $TMP_HTML_FILE 2>/dev/
null
touch $ERRORLIST $PLATFORMLIST $PERFLIST $WARNINGLIST \
$BCMISSINGLIST $BCERRORLIST $TMP_HTML_FILE 2>/dev/
null
if [ $O_WIN =
"ON" -a
"$O_TBX" =
"ON" ] ; then
HTML_PATH=
"http://${URL}${UX_D0}/nss${NSSVER}/tinderbox/tests_results/security/`basename $RESULTDIR`"
else
HTML_PATH=
"http://${URL}${RESULTDIR}"
fi
HREF_TMP_HTML_FILE=
"${HTML_PATH}/`basename $HTML_FILE`"
write_qa_header_html >$TMP_HTML_FILE
}
################################# html_footer #########################
# local shell
function, writes end of the html body
#######################################################################
write_qa_header_html()
{
echo
'Subject: QA Report ' $NSSVER $BUILDDATE
'
From: sonmi@iplanet.com
Reply-To: sonmi@iplanet.com
Content-Type: text/html; charset=us-ascii
<!doctype html
public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv=
"Content-Type" content=
"text/html; charset=iso-8859-1">
<meta name=
"GENERATOR" content=
"Mozilla/4.7 [en] (X11; U; SunOS 5.8 sun4u) [N
etscape]
">
</head>
<body>
<br>
<br>
<h2>
<a href=
"http://tinderbox.mozilla.org/showbuilds.cgi?tree=NSS">Tinderbox
><br>
<a href="http://cindercone.red.iplanet.com/share/builds/mccrel3/nss/nsstip/tinderbox/tests_results/security/">Tinderbox QA result
<a href="ftp://ftp.mozilla.org/pub/security/nss/daily_qa">Mozilla Daily NSS QA result
<br>
<center>
<h1>
<a NAME="Top"></a><b><font size=+2>QA Results</font></b></h1></center>
<table BORDER WIDTH="100%" NOSAVE >
<tr>
<td> <b><font size=+1>Build-OS and version</font></b></td>
<td><b><font size=+1>QA-OS</font></b></td>
<td><b><font size=+1>Systemname</font></b></td>
<td><b><font size=+1>P/F</font></b></td>
<td><b><font size=+1>result</font></b></td>
<td><b><font size=+1>output</font></b></td>
<td><b><font size=+1>errors</font></b></td>
<td><b><font size=+1>QA time / #</font></b></td>
</tr>
'
}
################################# html_footer #########################
# local shell function, writes end of the html body
#######################################################################
html_footer()
{
echo '