michael@0: #! /bin/sh michael@0: michael@0: ######################################################################## michael@0: # michael@0: # /u/sonmi/bin/header - /u/svbld/bin/init/nss/header michael@0: # michael@0: # variables, utilities and shellfunctions global to NSS QA michael@0: # needs to work on all Unix platforms michael@0: # michael@0: # included from (don't expect this to be up to date) michael@0: # -------------------------------------------------- michael@0: # qa_stat michael@0: # mksymlinks michael@0: # nssqa michael@0: # michael@0: # parameters michael@0: # ---------- michael@0: # nssversion (supported: 30b, 31, 332, tip 32) michael@0: # builddate (default - today) michael@0: # michael@0: # options michael@0: # ------- michael@0: # -y answer all questions with y - use at your own risk... ignores warnings michael@0: # -s silent (only usefull with -y) michael@0: # -h, -? - you guessed right - displays this text michael@0: # -d debug michael@0: # -f - write the (error)output to filename michael@0: # -fcronfile produces the resultfiles in the same locations michael@0: # as would have been produced with -cron michael@0: # -m - send filename to mailinglist (csl) only useful michael@0: # with -f michael@0: # -ml - send link to filename to mailinglist (csl) michael@0: # only useful with -f michael@0: # -cron equivalient to -y -s -d -f $RESULTDIR/$HOST. michael@0: # -t run on a tinderbox build that means: local, from the startlocation michael@0: # -l run on a local build mozroot michael@0: # -ln copy a networkbuild to a local directory mozroot, michael@0: # used for networkindipendend QA michael@0: # -lt try to copy a networkbuild to a local directory, if not possible michael@0: # run on the network michael@0: # used for networkindipendend QA michael@0: # michael@0: # special strings michael@0: # --------------- michael@0: # FIXME ... known problems, search for this string michael@0: # NOTE .... unexpected behavior michael@0: # michael@0: # moduls (not yet) michael@0: # ---------------- michael@0: # --# INIT michael@0: # --# USERCOM michael@0: # --# UTILS michael@0: # michael@0: # FIXME - split in init / usercom / utils michael@0: # michael@0: ######################################################################## michael@0: michael@0: #------------------------------# INIT #------------------------------ michael@0: michael@0: # below the option flags get initialized michael@0: michael@0: if [ -z "$QASCRIPT_DIR" ] michael@0: then michael@0: QASCRIPT_DIR=`dirname $0` michael@0: if [ "$QASCRIPT_DIR" = '.' ] michael@0: then michael@0: QASCRIPT_DIR=`pwd` michael@0: fi michael@0: fi michael@0: export QASCRIPT_DIR michael@0: michael@0: O_HWACC=OFF michael@0: if [ -z "$O_ALWAYS_YES" ] ; then michael@0: O_ALWAYS_YES=OFF # turned on by -y answer all questions with y michael@0: fi michael@0: michael@0: if [ -z "$O_INIT" ] # header is global, some including scripts may not michael@0: then # want the init to run, the others don't need to bother michael@0: O_INIT=ON michael@0: fi michael@0: if [ -z "$O_PARAM" ] # header is global, some including scripts may not michael@0: then # require parameters, the others don't need to bother michael@0: O_PARAM=ON michael@0: fi michael@0: if [ -z "$O_OPTIONS" ] # header is global, some including scripts may not michael@0: then # permit options, they don't need to bother michael@0: O_OPTIONS=OFF michael@0: fi michael@0: O_SILENT=OFF # turned on by -s silent (only usefull with -y) michael@0: if [ -z "$O_DEBUG" ] ; then michael@0: O_DEBUG=OFF # turned on by -d - calls to Debug produce output when ON michael@0: fi michael@0: O_FILE=OFF # turned on by -f echo all output to a file $FILENAME michael@0: O_CRON=OFF # turned on by -cron cron use only michael@0: O_CRONFILE=OFF # turned on by -cron cron and -fcron michael@0: O_LOCAL=OFF # turned on by -l* run on a local build in $LOCAL_MOZROOT michael@0: O_LN=OFF # turned on by -ln and -lt, test a networkbuild locally michael@0: O_MAIL=OFF # turned on by -m - sends email michael@0: O_MAIL_LINK=OFF # turned on by -ml - sends email michael@0: O_TBX=OFF # turned on by -t run on a tinderbox build michael@0: # that means: local, from the startlocation michael@0: michael@0: if [ -z "$DOMSUF" ] michael@0: then michael@0: michael@0: DOMSUF=red.iplanet.com michael@0: DS_WAS_SET=FALSE michael@0: else michael@0: DS_WAS_SET=TRUE michael@0: fi michael@0: michael@0: TMPFILES="" michael@0: michael@0: WAIT_FOR=600 # if waiting for an event sleep n seconds before rechecking michael@0: # recomended value 10 minutes 600 michael@0: WAIT_TIMES=30 # recheck n times before giving up - recomended 30 - total of 5h michael@0: michael@0: if [ -z "$QAYEAR" ] # may I introduce - the y2k+1 bug? QA for last year michael@0: then # might not work michael@0: QAYEAR=`date +%Y` michael@0: fi michael@0: michael@0: if [ -z "$TMP" ] michael@0: then michael@0: if [ -z "$TEMP" ] michael@0: then michael@0: TMP="/tmp" michael@0: else michael@0: TMP=$TEMP michael@0: fi michael@0: fi michael@0: if [ ! -w "$TMP" ] michael@0: then michael@0: echo "Can't write to tmp directory $TMP - exiting" michael@0: echo "Can't write to tmp directory $TMP - exiting" >&2 michael@0: exit 1 michael@0: fi michael@0: michael@0: KILLPIDS="$TMP/killpids.$$" michael@0: export KILLERPIDS michael@0: TMPFILES="$TMPFILES $KILLPIDS" michael@0: michael@0: KILL_SELFSERV=OFF # if sourcing script sets this to on cleanup will also michael@0: # kill the running selfserv processes michael@0: michael@0: # Set the masterbuilds michael@0: if [ -z "$UX_MASTERBUILD" ] michael@0: then michael@0: UX_MASTERBUILD=booboo_Solaris8 michael@0: #if [ ! -d $UX_MASTERBUILD ] ; then michael@0: #UX_MASTERBUILD=booboo_Solaris8_forte6 michael@0: #fi michael@0: UX_MB_WAS_SET=FALSE michael@0: else michael@0: UX_MB_WAS_SET=TRUE michael@0: fi michael@0: if [ -z "$NT_MASTERBUILD" ] michael@0: then michael@0: NT_MASTERBUILD=blowfish_NT4.0_Win95 michael@0: NT_MB_WAS_SET=FALSE # in this case later functions can override if michael@0: # they find a different build that looks like NT michael@0: else michael@0: NT_MB_WAS_SET=TRUE michael@0: fi michael@0: if [ -z "$MASTERBUILD" ] michael@0: then michael@0: MASTERBUILD=$UX_MASTERBUILD michael@0: fi michael@0: michael@0: # Set the default build michael@0: if [ -z "$BUILDNUMBER" ] michael@0: then michael@0: BUILDNUMBER=1 michael@0: fi michael@0: export BUILDNUMBER michael@0: O_LDIR=OFF #local QA dir for NT, temporary michael@0: michael@0: if [ -z "$WIN_WAIT_FOREVER" ] # header is global, some including scripts michael@0: then # want the init to wait forever for directories to michael@0: # appear (windows only) if OFF exit, if ON wait forever michael@0: WIN_WAIT_FOREVER=OFF michael@0: fi michael@0: michael@0: # NOTE: following variables have to change michael@0: # from release to release michael@0: if [ -z "$BC_MASTER" ] # master directory for backwardscompatibility testing michael@0: then michael@0: RH="NO" michael@0: grep 7.1 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES" michael@0: grep 7.2 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES" michael@0: michael@0: if [ "$RH" = "YES" ] michael@0: then # NSS-3-3-1RTM michael@0: BC_UX_MASTER=nss331/builds/20010928.2.331-RTM/booboo_Solaris8 michael@0: BC_NT_MASTER=nss331/builds/20010928.2.331-RTM/blowfish_NT4.0_Win95 michael@0: else # NSS-3-2-2RTM michael@0: BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8 michael@0: BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95 michael@0: fi michael@0: BC_MASTER=$BC_UX_MASTER michael@0: BC_MASTER_WAS_SET=FALSE michael@0: else michael@0: BC_MASTER_WAS_SET=TRUE michael@0: fi michael@0: BC_RELEASE=3.2 michael@0: export BC_RELEASE michael@0: michael@0: EARLY_EXIT=TRUE #before the report file has been created, causes Exit to michael@0: #create it michael@0: michael@0: UX_D0=/share/builds/mccrel3/nss michael@0: michael@0: ################################### glob_init ########################## michael@0: # global shell function, main initialisation function michael@0: ######################################################################## michael@0: glob_init() michael@0: { michael@0: if [ $O_PARAM = "ON" ] ; then michael@0: eval_opts $* # parse parameters and options - set flags michael@0: fi michael@0: # if running from cron HOST needs to be known early, michael@0: init_host # so the output file name can be constructed. michael@0: Debug "Setting up environment...( $QASCRIPT_DIR/set_environment) " michael@0: . $QASCRIPT_DIR/set_environment #finds out if we are running on Windows michael@0: Debug "OPerating system: $os_name $os_full" michael@0: umask 0 michael@0: init_dirs michael@0: init_files michael@0: init_vars michael@0: } michael@0: michael@0: ################################### init_vars ########################### michael@0: # global shell function, sets the environment variables, part of init michael@0: ######################################################################## michael@0: init_vars() michael@0: { michael@0: if [ -z "$LOGNAME" ] michael@0: then michael@0: if [ $O_WIN = "ON" ] michael@0: then michael@0: LOGNAME=$USERNAME michael@0: else michael@0: LOGNAME=$USER michael@0: fi michael@0: if [ -z "$LOGNAME" ] michael@0: then michael@0: LOGNAME=$UNAME michael@0: if [ -z "$LOGNAME" ] michael@0: then michael@0: LOGNAME=`basename $HOME` michael@0: fi michael@0: fi michael@0: fi michael@0: if [ -z "$LOGNAME" ] michael@0: then michael@0: Exit "Can't determine current user" michael@0: fi michael@0: case $HOST in michael@0: iws-perf) michael@0: O_HWACC=ON michael@0: HWACC_LIST="rainbow ncipher" michael@0: #MODUTIL="-add rainbow -libfile /usr/lib/libcryptoki22.so" michael@0: export HWACC_LIST michael@0: ;; michael@0: *) michael@0: O_HWACC=OFF michael@0: ;; michael@0: esac michael@0: export O_HWACC michael@0: } michael@0: michael@0: ######################################################################## michael@0: # functions below deal with setting up the directories and PATHs for michael@0: # all different flavors of OS (Unix, Linux, NT MKS, NT Cygnus) and QA michael@0: # (Standard, local tinderbox) michael@0: ######################################################################## michael@0: michael@0: ########################## find_nt_masterbuild ######################### michael@0: # global shell function, sets the nt masterbuild directories, part of init michael@0: ######################################################################## michael@0: find_nt_masterbuild() michael@0: { michael@0: NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD} michael@0: if [ "${NT_MB_WAS_SET}" = "FALSE" -a ! -d $NT_MASTERDIR ] ; then michael@0: if [ -d ${DAILY_BUILD}/*NT4* ] ; then michael@0: NT_MASTERBUILD=` cd ${DAILY_BUILD}; ls -d *NT4* ` michael@0: Debug "NT_MASTERBUILD $NT_MASTERBUILD" michael@0: NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD} michael@0: fi michael@0: fi michael@0: Debug "NT_MASTERDIR $NT_MASTERDIR" michael@0: } michael@0: michael@0: ################################### set_daily_build_dirs ########################### michael@0: # global shell function, sets directories michael@0: ######################################################################## michael@0: set_daily_build_dirs() michael@0: { michael@0: if [ "$O_LOCAL" = "ON" -a "$O_LN" = "OFF" ] ; then michael@0: DAILY_BUILD=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are michael@0: # set to the LOCAL_MOZROOT, since it is not sure michael@0: # if ../.. (DAILY_BUILD) even exists michael@0: LOCALDIST=${LOCAL_MOZROOT}/dist michael@0: elif [ "$O_TBX" = "ON" ] ; then michael@0: DAILY_BUILD="$TBX_DAILY_BUILD" michael@0: LOCALDIST=${UXDIST} michael@0: else michael@0: DAILY_BUILD=${NSS_VER_DIR}/builds/${QAYEAR}${BUILDDATE}.${BUILDNUMBER} michael@0: LOCALDIST=${DAILY_BUILD}/${MASTERBUILD}/mozilla/dist michael@0: fi michael@0: } michael@0: michael@0: map_os64() michael@0: { michael@0: IS_64="" michael@0: case `uname -s` in michael@0: #OSF1) has been done already - always 64 bit michael@0: SunOS) michael@0: MAPPED_OS=Solaris*8 michael@0: IS_64=`(isainfo -v | grep 64)>/dev/null 2>/dev/null && echo 64 bit` michael@0: if [ "$O_TBX" = "OFF" ] ; then michael@0: set_osdir michael@0: if [ -n "$IS_64" ] michael@0: then #Wait for the 64 bit build to finish... michael@0: Debug Testing build for $MAPPED_OS in $OSDIR michael@0: Wait ${OSDIR}/SVbuild.InProgress.1 0 michael@0: fi michael@0: fi michael@0: ;; michael@0: AIX) michael@0: IS_64=`lslpp -l | grep "bos.64bit"> /dev/null && echo 64 bit` michael@0: ;; michael@0: HP-UX) michael@0: IS_64=`getconf KERNEL_BITS | grep 64 >/dev/null && echo 64 bit` michael@0: ;; michael@0: esac michael@0: Debug "Mapped OS to $MAPPED_OS" michael@0: } michael@0: michael@0: michael@0: michael@0: ################################### copy_to_local ######################## michael@0: # global shell function, copies the necessary directories from the michael@0: # daily build aerea to the local disk michael@0: ######################################################################## michael@0: copy_to_local() michael@0: { michael@0: Debug "Copy network directories to local directories" michael@0: C2L_ERROR=0 michael@0: if [ ! -d ${LOCAL_MOZROOT}/dist ] ; then michael@0: mkdir -p ${LOCAL_MOZROOT}/dist || C2L_ERROR=1 michael@0: fi michael@0: if [ ! -d ${LOCAL_MOZROOT}/security/nss ] ; then michael@0: mkdir -p ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=2 michael@0: fi michael@0: if [ $C2L_ERROR != 0 ] ; then michael@0: Exit "copy_to_local: Can t make necesssary directories ($C2L_ERROR ) " michael@0: fi michael@0: if [ ! -d ${LOCAL_MOZROOT}/security/nss/tests ] ; then michael@0: cp -r ${TESTSCRIPTDIR} ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=1 michael@0: fi michael@0: if [ ! -d ${LOCAL_MOZROOT}/security/coreconf ] ; then michael@0: cp -r ${MOZILLA_ROOT}/security/coreconf ${LOCAL_MOZROOT}/security || C2L_ERROR=2 michael@0: fi michael@0: michael@0: NO_DIRS=0; michael@0: if [ "$O_WIN" = "ON" ] ; then michael@0: OS_TARGET=WINNT;export OS_TARGET michael@0: fi michael@0: unset BUILD_OPT;export BUILD_OPT; michael@0: unset USE_64;export USE_64; michael@0: #FIXME only tested on 64 bit Solaris and only got 32 bit builds michael@0: while [ $NO_DIRS -lt 4 ] ; do michael@0: # first time thru: Debug 32 bit NT michael@0: set_objdir michael@0: Debug "Copying ${OBJDIR}..." michael@0: if [ ! -d ${LOCAL_MOZROOT}/dist/${OBJDIR} ] ; then michael@0: cp -r ${LOCALDIST}/${OBJDIR} ${LOCAL_MOZROOT}/dist || C2L_ERROR=3 michael@0: fi michael@0: NO_DIRS=`expr $NO_DIRS + 1` michael@0: if [ $NO_DIRS = 1 ] ; then # 2nd time: OPT 32 bit NT michael@0: BUILD_OPT=1; export BUILD_OPT; michael@0: elif [ $NO_DIRS = 2 ] ; then # 3rd time: OPT, either 64 bit or Win95 or force exit michael@0: if [ "$O_WIN" = "ON" ] ; then michael@0: OS_TARGET=WIN95;export OS_TARGET michael@0: else michael@0: map_os64 michael@0: if [ -z "$IS_64" ] ; then #32 bit platform michael@0: NO_DIRS=4 michael@0: else michael@0: USE_64=1; export USE_64 michael@0: fi michael@0: fi michael@0: elif [ $NO_DIRS = 3 ] ; then # 4th time: Debug either 64 bit or Win95 michael@0: unset BUILD_OPT;export BUILD_OPT; michael@0: fi michael@0: michael@0: michael@0: done michael@0: if [ $C2L_ERROR != 0 ] ; then michael@0: Exit "copy_to_local: Can t copy necesssary directories ($C2L_ERROR ) " michael@0: fi michael@0: unset TESTSCRIPTDIR michael@0: unset TESTDIR michael@0: unset RESULTDIR michael@0: O_LN=OFF #from here on pretend it is regular -l local QA FIXME, might cause michael@0: #problems with the backwardcompatibility tests michael@0: Debug "Successfully copied network directories to local directories" michael@0: } michael@0: michael@0: ################################### local_dirs ########################### michael@0: # global shell function, sets the directories for local QA michael@0: ######################################################################## michael@0: local_dirs() michael@0: { michael@0: Debug "Set directories for local QA" michael@0: #if [ "$O_WIN" = "ON" ] ; then michael@0: #win_set_tmp michael@0: #fi michael@0: NSS_VER_DIR=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are michael@0: # set to the LOCAL_MOZROOT, since it is not sure michael@0: # if ../../../.. (NSS_VER_DIR) even exists michael@0: if [ -z "${RESULTDIR}" ] ; then # needs to be local as well michael@0: Debug "Setting RESULTDIR for local QA" michael@0: RESULTDIR="${LOCAL_MOZROOT}/tests_results/security/${HOST}-`date +%Y%m%d-%H.%M`" michael@0: fi michael@0: set_daily_build_dirs michael@0: UX_MASTERDIR=`dirname ${LOCAL_MOZROOT}` michael@0: NT_MASTERDIR=$UX_MASTERDIR michael@0: MOZILLA_ROOT=${LOCAL_MOZROOT} michael@0: michael@0: UXDIST=${MOZILLA_ROOT}/dist michael@0: NTDIST=${UXDIST} michael@0: michael@0: if [ -z "${TESTDIR}" ] ; then michael@0: Debug "Setting TESTDIR for local QA" michael@0: TESTDIR=${RESULTDIR} michael@0: fi michael@0: if [ -n "$TESTDIR" ] ; then michael@0: if [ ! -d $TESTDIR ] ; then michael@0: Debug "Making TESTDIR for local QA" michael@0: mkdir -p $TESTDIR michael@0: fi michael@0: fi michael@0: export TESTDIR michael@0: Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR" michael@0: michael@0: TESTSCRIPTDIR=${LOCAL_MOZROOT}/security/nss/tests michael@0: COMMON=${TESTSCRIPTDIR}/common michael@0: michael@0: set_objdir michael@0: debug_dirs michael@0: export_dirs michael@0: } michael@0: michael@0: michael@0: ################################### tbx_dirs ########################### michael@0: # global shell function, sets the directories for tinderbox QA michael@0: ######################################################################## michael@0: tbx_dirs() michael@0: { michael@0: Debug "Set directories for tinderbox" michael@0: if [ "$O_WIN" = "ON" ] ; then michael@0: win_set_d1 # we need the NSS_VER_DIR later michael@0: else michael@0: NSS_VER_DIR="$UX_D0"/nss$NSSVER michael@0: fi michael@0: if [ -z "${RESULTDIR}" ] ; then # needs to be different for tinderbox michael@0: Debug "Setting RESULTDIR for tinderbox" michael@0: TBX_NOBITS="" michael@0: echo $QASCRIPT_DIR | grep 64 >/dev/null && TBX_NOBITS=64 michael@0: TRD="${HOST}${TBX_NOBITS}-`date +%Y%m%d-%H.%M`" michael@0: RESULTDIR="${NSS_VER_DIR}/tinderbox/tests_results/security/${TRD}" michael@0: if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then michael@0: URL="sbs-rel.nscp.aoltw.net" michael@0: else michael@0: URL="cindercone.red.iplanet.com" michael@0: fi michael@0: if [ "$O_WIN" = "ON" ] ; then michael@0: RESULTDIRURL="QA" michael@0: else michael@0: RESULTDIRURL="QA" michael@0: fi michael@0: Debug "RESULTDIRURL TinderboxPrint:$RESULTDIRURL" michael@0: fi michael@0: TBX_DAILY_BUILD=`cd ../../../../..;pwd` michael@0: NSS_VER_DIR="${TBX_DAILY_BUILD}/../.." michael@0: TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tinderbox | sed -e 's/ .*//g'` michael@0: if [ -z "$TBX_LOGFILE_DIR" ] ; then michael@0: TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tbx | sed -e 's/ .*//g'` michael@0: TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tbx/${TBX_LOGFILE_DIR}" michael@0: else michael@0: TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tinderbox/${TBX_LOGFILE_DIR}" michael@0: fi michael@0: Debug "Set TBX_LOGFILE_DIR ${TBX_LOGFILE_DIR}" michael@0: michael@0: set_daily_build_dirs michael@0: UX_MASTERDIR=`cd ../../../..;pwd` michael@0: NT_MASTERDIR=$UX_MASTERDIR michael@0: MOZILLA_ROOT=$UX_MASTERDIR/mozilla michael@0: michael@0: UXDIST=${MOZILLA_ROOT}/dist michael@0: NTDIST=${UXDIST} michael@0: michael@0: if [ -z "${TESTDIR}" ] ; then michael@0: Debug "Setting TESTDIR for tinderbox" michael@0: TESTDIR=${RESULTDIR} michael@0: fi michael@0: if [ -n "$TESTDIR" ] ; then michael@0: if [ ! -d $TESTDIR ] ; then michael@0: Debug "Making TESTDIR for tinderbox" michael@0: mkdir -p $TESTDIR michael@0: fi michael@0: fi michael@0: Debug "Making QAstatus file" michael@0: echo "QA running" >${TESTDIR}/QAstatus michael@0: export TESTDIR michael@0: Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR" michael@0: michael@0: TESTSCRIPTDIR=`pwd` michael@0: COMMON=${TESTSCRIPTDIR}/common michael@0: michael@0: set_objdir michael@0: debug_dirs michael@0: export_dirs michael@0: } michael@0: michael@0: ################################### init_mcom ########################### michael@0: # global shell function, sets domain specific variables for AOL's michael@0: # domains according to Bishakha's instructions michael@0: ######################################################################## michael@0: init_mcom() michael@0: { michael@0: Debug "Running in mcom or netscape domain - changing directories..." michael@0: if [ "${UX_MB_WAS_SET}" = "FALSE" ] ; then #in case it was set michael@0: # before script was called use these values michael@0: UX_MASTERBUILD=spd04_Solaris8 michael@0: fi michael@0: if [ "${NT_MB_WAS_SET}" = "FALSE" ] ; then michael@0: NT_MASTERBUILD=spd06_NT4 michael@0: fi michael@0: michael@0: MASTERBUILD=$UX_MASTERBUILD michael@0: if [ "${BC_MASTER_WAS_SET}" = "FALSE" ] ; then michael@0: BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8 michael@0: BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95 michael@0: BC_MASTER=$BC_UX_MASTER michael@0: fi michael@0: UX_D0=/share/builds/sbsrel2/nss michael@0: URL="sbs-rel.nscp.aoltw.net" michael@0: } michael@0: ################################### init_dirs ########################### michael@0: # global shell function, sets the directories for standard QA michael@0: # calls special functions for tinderbox, windows or local QA, part of init michael@0: ######################################################################## michael@0: init_dirs() michael@0: { michael@0: if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then michael@0: init_mcom michael@0: fi michael@0: if [ $O_WIN = "ON" ] ; then michael@0: win_set_tmp michael@0: write_to_tmpfile michael@0: MASTERBUILD=$NT_MASTERBUILD michael@0: BC_MASTER=$BC_NT_MASTER michael@0: fi michael@0: if [ "$O_LOCAL" = "ON" -a $O_LN = "OFF" ] ; then # if it is a LN we need to know michael@0: # all the directories off the network first to copy them michael@0: local_dirs # O_LOCAL alone assumes that all the directories are already there michael@0: return michael@0: elif [ "$O_TBX" = "ON" ] ; then michael@0: tbx_dirs michael@0: return michael@0: elif [ "$O_WIN" = "ON" ] ; then michael@0: win_set_d1 michael@0: else michael@0: NSS_VER_DIR="$UX_D0"/nss$NSSVER michael@0: fi michael@0: #set -x michael@0: michael@0: set_daily_build_dirs michael@0: michael@0: if [ -z "${BCDIST}" ] ; then michael@0: #BCDIST=/share/builds/mccrel3/nss/${BC_MASTER}/mozilla/dist michael@0: BCDIST=${NSS_VER_DIR}/../${BC_MASTER}/mozilla/dist michael@0: if [ ! -d $BCDIST -a `basename $0` != jssqa ] ; then michael@0: ask "Backward compatibility directory $BCDIST does not exist, continue" "y" "n" || Exit michael@0: fi michael@0: fi michael@0: michael@0: UX_MASTERDIR=${DAILY_BUILD}/${UX_MASTERBUILD} michael@0: find_nt_masterbuild michael@0: michael@0: if [ "$O_WIN" = "ON" ] michael@0: then michael@0: MOZILLA_ROOT=${NT_MASTERDIR}/mozilla michael@0: else michael@0: MOZILLA_ROOT=${UX_MASTERDIR}/mozilla michael@0: fi michael@0: michael@0: UXDIST=${UX_MASTERDIR}/mozilla/dist michael@0: NTDIST=${NT_MASTERDIR}/mozilla/dist michael@0: michael@0: if [ -z "${RESULTDIR}" ] ; then michael@0: RESULTDIR=${UX_MASTERDIR}/mozilla/tests_results/security michael@0: fi michael@0: michael@0: if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then michael@0: michael@0: if [ "$O_WIN" = "ON" ] ; then michael@0: JSS_NSS_SRC_DIR=$JSS_NSS_NT_SRC_DIR michael@0: fi michael@0: TESTSCRIPTDIR=${NSS_VER_DIR}/../${JSS_NSS_SRC_DIR}/mozilla/security/nss/tests michael@0: else michael@0: TESTSCRIPTDIR=${MOZILLA_ROOT}/security/nss/tests michael@0: fi michael@0: michael@0: if [ ! -d $TESTSCRIPTDIR -a `basename $0` != jssqa ] ; then michael@0: if [ "$O_WIN" = "ON" -a "$WIN_WAIT_FOREVER" = "ON" ] michael@0: then michael@0: WaitForever $TESTSCRIPTDIR/all.sh 1 michael@0: else michael@0: Exit "Test directory $TESTSCRIPTDIR does not exist" michael@0: fi michael@0: fi michael@0: michael@0: COMMON=${TESTSCRIPTDIR}/common michael@0: if [ "$O_LOCAL" = "ON" -a $O_LN = "ON" ] ; then # if it is a LN we need to know michael@0: # all the directories off the network first to copy them michael@0: copy_to_local michael@0: local_dirs michael@0: fi michael@0: #set +x michael@0: michael@0: michael@0: set_objdir michael@0: debug_dirs michael@0: export_dirs michael@0: } michael@0: michael@0: debug_dirs() michael@0: { michael@0: Debug "NTDIST $NTDIST" michael@0: Debug "UXDIST $UXDIST" michael@0: Debug "TESTSCRIPTDIR $TESTSCRIPTDIR" michael@0: Debug "RESULTDIR $RESULTDIR" michael@0: Debug "TMP $TMP" michael@0: Debug "LOCALDIST_BIN $LOCALDIST_BIN" michael@0: Debug "COMMON $COMMON" michael@0: Debug "MOZILLA_ROOT $MOZILLA_ROOT" michael@0: Debug "BCDIST $BCDIST" michael@0: } michael@0: michael@0: export_dirs() michael@0: { michael@0: export NSS_VER_DIR DAILY_BUILD NTDIST UXDIST RESULTDIR TESTSCRIPTDIR BCDIST michael@0: export UX_MASTERDIR NT_MASTERDIR COMMON MOZILLA_ROOT michael@0: } michael@0: michael@0: set_osdir() michael@0: { michael@0: OSDIR=${DAILY_BUILD}/*${MAPPED_OS}* michael@0: } michael@0: michael@0: ################################### init_files ########################### michael@0: # global shell function, sets filenames, initializes files, part of init michael@0: ######################################################################## michael@0: init_files() michael@0: { michael@0: if [ $O_CRONFILE = "ON" ] michael@0: then michael@0: Debug "attempting to create resultfiles" michael@0: if [ "$O_TBX" = "ON" ] ; then michael@0: NEWFILENAME=${TBX_LOGFILE_DIR}/qa.log michael@0: if [ ! -w ${TBX_LOGFILE_DIR} ] ; then michael@0: Exit "can't touch $NEWFILENAME" michael@0: fi michael@0: else michael@0: NEWFILENAME=$RESULTDIR/$HOST.`basename $0` michael@0: fi michael@0: if [ ! -d $RESULTDIR ] michael@0: then michael@0: mkdir -p $RESULTDIR || Exit "Error: can't make $RESULTDIR" michael@0: fi michael@0: if [ ! -w $RESULTDIR ] ; then michael@0: Exit "can't touch $NEWFILENAME" michael@0: fi michael@0: Debug "About to touch $NEWFILENAME " michael@0: touch $NEWFILENAME || Exit "Error: can't touch $NEWFILENAME" michael@0: if [ "$O_TBX" = "ON" ] ; then michael@0: echo "QA results in $RESULTDIR" >>$NEWFILENAME || Exit "Error: can't write to $NEWFILENAME" michael@0: fi michael@0: Debug "About to cat $FILENAME >>$NEWFILENAME " michael@0: cat $FILENAME >>$NEWFILENAME || Exit "Error: can't append $FILENAME to $NEWFILENAME" michael@0: TMPFILES="$TMPFILES $FILENAME" michael@0: FILENAME=$NEWFILENAME michael@0: Debug "Writing output to $FILENAME" michael@0: fi michael@0: michael@0: } michael@0: michael@0: ################################### write_to_tmpfile ########################## michael@0: # global shell function, for NT and cron operation, first a tmpfile michael@0: # needs to be created michael@0: ######################################################################## michael@0: write_to_tmpfile() michael@0: { michael@0: O_CRONFILE=ON michael@0: O_FILE=ON michael@0: FILENAME=${TMP}/nsstmp.$$ # for now write to the temporary file michael@0: # since we don't know the hostname yet michael@0: # will be inserted to the real file later michael@0: TMPFILES="$TMPFILES nsstmp.$$" michael@0: touch $FILENAME || Exit "Error: can't touch $FILENAME" michael@0: Debug "Writing output to $FILENAME" michael@0: } michael@0: michael@0: ############################# turn_on_cronoptions ###################### michael@0: # global shell function, turns on options needed for cron and tinderbox michael@0: ######################################################################## michael@0: turn_on_cronoptions() michael@0: { michael@0: O_CRON=ON michael@0: O_SILENT=ON michael@0: O_DEBUG=ON # FIXME take out! michael@0: O_ALWAYS_YES=ON michael@0: write_to_tmpfile michael@0: } michael@0: michael@0: ########################## test_mozroot ########################## michael@0: # global shell function, determines if the variable LOCAL_MOZROOT is set, michael@0: # and is usable as mozilla root diretory for a local QA michael@0: ################################################################### michael@0: test_mozroot() michael@0: { michael@0: PWD=`pwd` michael@0: Debug "LOCAL_MOZROOT = $LOCAL_MOZROOT" michael@0: case "$LOCAL_MOZROOT" in michael@0: [0-9-]*|tip) michael@0: glob_usage "Error: -"$1" requires a directoryname to follow (start with a letter) " michael@0: ;; michael@0: \.\.) michael@0: LOCAL_MOZROOT=`dirname $PWD` michael@0: ;; michael@0: \.) michael@0: LOCAL_MOZROOT=$PWD michael@0: ;; michael@0: \.\/*) michael@0: LOCAL_MOZROOT=`echo $LOCAL_MOZROOT | sed -e "s/^\.//"` michael@0: LOCAL_MOZROOT="${PWD}${LOCAL_MOZROOT}" michael@0: ;; michael@0: \.\.\/*) michael@0: LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}" michael@0: ;; michael@0: \/*|[a-zA-Z]:\/*) michael@0: ;; michael@0: ?*) michael@0: LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}" michael@0: ;; michael@0: *) michael@0: glob_usage "Error: -"$1" requires a directoryname to follow" michael@0: ;; michael@0: esac michael@0: Debug "Reformated MOZROOT to $LOCAL_MOZROOT" michael@0: if [ "$1" = "ln" ] ; then michael@0: LOCAL_MOZROOT_PARENT=`dirname $LOCAL_MOZROOT` michael@0: if [ ! -d $LOCAL_MOZROOT_PARENT -o ! -w $LOCAL_MOZROOT_PARENT -o \ michael@0: ! -x $LOCAL_MOZROOT_PARENT ] ; then michael@0: Exit "Error: Can't create $LOCAL_MOZROOT (permissions)" michael@0: fi michael@0: if [ ! -d "$LOCAL_MOZROOT" ] ; then michael@0: mkdir $LOCAL_MOZROOT || michael@0: Exit "Error: Can't create mozroot $LOCAL_MOZROOT (mkdir failed)" michael@0: else michael@0: ask "mozroot $LOCAL_MOZROOT exists - continue (y will remove dir) ?" \ michael@0: "y" "n" || Exit michael@0: rm -rf $LOCAL_MOZROOT/dist $LOCAL_MOZROOT/security $LOCAL_MOZROOT/tests_results || michael@0: Exit "Error: Can't clean mozroot $LOCAL_MOZROOT" michael@0: fi michael@0: fi michael@0: if [ ! -d "$LOCAL_MOZROOT" ] ; then michael@0: glob_usage "Error: mozilla root $LOCAL_MOZROOT not a valid directory" michael@0: fi michael@0: } michael@0: michael@0: ################################### eval_opts ########################## michael@0: # global shell function, evapuates options and parameters, sets flags michael@0: # variables and defaults michael@0: ######################################################################## michael@0: eval_opts() michael@0: { michael@0: while [ -n "$1" ] michael@0: do michael@0: case $1 in michael@0: -cron) michael@0: turn_on_cronoptions michael@0: ;; michael@0: -T*|-t*) michael@0: O_TBX=ON michael@0: turn_on_cronoptions michael@0: O_SILENT=OFF #FIXME debug only michael@0: ;; michael@0: -S*|-s*) michael@0: O_SILENT=ON michael@0: ;; michael@0: -Y*|-y) michael@0: Debug "Option -y dedectet" michael@0: O_ALWAYS_YES=ON michael@0: ;; michael@0: -d*|-D) michael@0: O_DEBUG=ON michael@0: #set -x michael@0: ;; michael@0: -ml|-ML) michael@0: O_MAIL_LINK=ON michael@0: shift michael@0: MAILINGLIST=$1 michael@0: if [ -z "$MAILINGLIST" ] michael@0: then michael@0: glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb " michael@0: fi michael@0: Debug "Sending link to result to $MAILINGLIST" michael@0: ;; michael@0: -m|-M) michael@0: O_MAIL=ON michael@0: shift michael@0: MAILINGLIST=$1 michael@0: if [ -z "$MAILINGLIST" ] michael@0: then michael@0: glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb " michael@0: fi michael@0: Debug "Sending result to $MAILINGLIST" michael@0: ;; michael@0: -fcron*|-F[Cc][Rr][Oo][Nn]*) michael@0: write_to_tmpfile michael@0: ;; michael@0: -f|-F) michael@0: O_FILE=ON michael@0: shift michael@0: FILENAME=$1 michael@0: if [ -z "$FILENAME" ] michael@0: then michael@0: glob_usage "Error: -f requires a filename to follow" michael@0: fi michael@0: #rm -f $FILENAME 2>/dev/null michael@0: touch $FILENAME || Exit "Error: can't touch $FILENAME" michael@0: #NOTE we append rather that creating michael@0: Debug "Writing output to $FILENAME" michael@0: ;; michael@0: -h|-help|"-?") michael@0: glob_usage michael@0: ;; michael@0: -ln) michael@0: if [ `basename $0` != nssqa ] ; then michael@0: glob_usage "Error: Can't handle option $1" michael@0: fi michael@0: O_LOCAL=ON michael@0: O_LN=ON michael@0: shift michael@0: LOCAL_MOZROOT=$1 michael@0: test_mozroot ln michael@0: ;; michael@0: -lt) michael@0: if [ `basename $0` != nssqa ] ; then michael@0: glob_usage "Error: Can't handle option $1" michael@0: fi michael@0: O_LN=ON michael@0: O_LOCAL=ON michael@0: ;; michael@0: -l) michael@0: if [ `basename $0` != nssqa ] ; then michael@0: glob_usage "Error: Can't handle option $1" michael@0: fi michael@0: O_LOCAL=ON michael@0: shift michael@0: LOCAL_MOZROOT=$1 michael@0: test_mozroot l michael@0: ;; michael@0: -p) michael@0: shift michael@0: PORT=$1 michael@0: export PORT michael@0: ;; michael@0: -*) michael@0: glob_usage "Error: Can't handle option $1" michael@0: ;; michael@0: tip|3.|3..) michael@0: NSSVER=$1 michael@0: if [ -z "$NSSVER" ] ; then michael@0: glob_usage "Error: illegal parameter" michael@0: fi michael@0: ;; michael@0: [01][0-9][0123][0-9]) michael@0: BUILDDATE=$1 michael@0: if [ -z "$BUILDDATE" ] ; then michael@0: glob_usage "Error: illegal parameter" michael@0: fi michael@0: ;; michael@0: ?*) michael@0: glob_usage "Error: Can't handle parameter $1" michael@0: ;; michael@0: esac michael@0: shift michael@0: done michael@0: michael@0: if [ -z "$PORT" -a "$O_TBX" = "ON" ] ; then michael@0: PORT=8444 michael@0: export PORT michael@0: if [ -z "$NSSVER" ] ; then michael@0: NSSVER="tip" michael@0: Debug "NSS Version: Parameters missing - defaulting to tip!" michael@0: fi michael@0: elif [ -z "$NSSVER" ] ; then michael@0: NSSVER="tip" michael@0: Debug "NSS Version: Parameters missing - defaulting to tip!" michael@0: fi michael@0: if [ -z "$BUILDDATE" ] ; then michael@0: BUILDDATE=`date +%m%d` michael@0: Debug "Builddate: Parameters missing - defaulting to today!" michael@0: fi michael@0: michael@0: Debug "Builddate $BUILDDATE NssVersion $NSSVER" michael@0: export BUILDDATE NSSVER michael@0: export O_CRON O_SILENT O_DEBUG O_ALWAYS_YES O_TBX michael@0: } michael@0: michael@0: win_set_tmp() michael@0: { michael@0: TMP=`echo "$TMP" | sed -e 's/ /\/t/g' -e 's//\/b/' -e 's/\\\/\//g'` michael@0: Debug "TMP reformated to $TMP" michael@0: } michael@0: michael@0: ######################### win_set_d1 ################################ michael@0: # global shell function, interactively finds the directories in case michael@0: # windows can't get to the default michael@0: ######################################################################## michael@0: win_set_d1() michael@0: { michael@0: Debug "set Windows Directories..." michael@0: #win_set_tmp michael@0: if [ "$O_CYGNUS" = ON ] michael@0: then michael@0: NSS_VER_DIR=/cygdrive/w/nss/nss$NSSVER michael@0: else michael@0: NSS_VER_DIR=w:/nss/nss$NSSVER michael@0: fi michael@0: if [ ! -w $NSS_VER_DIR ] michael@0: then michael@0: Echo "Windows special... can't write in $NSS_VER_DIR" michael@0: if [ "$O_CYGNUS" = ON ] michael@0: then michael@0: NSS_VER_DIR=/cygdrive/u/nss/nss$NSSVER michael@0: else michael@0: NSS_VER_DIR="u:/nss/nss$NSSVER" michael@0: fi michael@0: else michael@0: Debug "NSS_VER_DIR set to $NSS_VER_DIR" michael@0: return michael@0: fi michael@0: michael@0: while [ ! -w $NSS_VER_DIR ] michael@0: do michael@0: if [ "$O_CRONFILE" = "ON" ] michael@0: then michael@0: Exit "cant write in $NSS_VER_DIR" michael@0: fi michael@0: Warning "cant write in $NSS_VER_DIR" michael@0: Echo "input start directory (u:/nss, d:/src/nss, f:/shared/nss) " michael@0: read D michael@0: if [ -n "$D" ] michael@0: then michael@0: NSS_VER_DIR=$D/nss$NSSVER michael@0: fi michael@0: done michael@0: Debug "NSS_VER_DIR set to $NSS_VER_DIR" michael@0: } michael@0: michael@0: ########################### init_host ################################## michael@0: # global shell function, sets required variables HOST and DOMSUF, and asks michael@0: # the user if it has been set right michael@0: ######################################################################## michael@0: set_host() michael@0: { michael@0: init_host michael@0: } michael@0: init_host() michael@0: { michael@0: if [ `basename $0` != nssqa ] ; then michael@0: return michael@0: fi michael@0: michael@0: init_host_done=0 michael@0: michael@0: if [ $DS_WAS_SET = FALSE ] #give chance to overwrite, espec. for NT michael@0: then michael@0: Debug "Domainname was not set..." michael@0: DOMSUF=`domainname 2>/dev/null` michael@0: if [ -z "$DOMSUF" ] michael@0: then michael@0: Debug "domainname command did not work ..." michael@0: DOMSUF=`echo $HOST | grep '\.' | sed -e "s/[^\.]*\.//"` michael@0: michael@0: if [ -z "$DOMSUF" ] michael@0: then michael@0: Debug "Domainname not part of the hostname" michael@0: DOMSUF=`cat /etc/defaultdomain 2>/dev/null` michael@0: if [ -z "$DOMSUF" ] michael@0: then michael@0: Debug "Domainname needs to be hardcoded to red.iplanet.com" michael@0: DOMSUF="red.iplanet.com" michael@0: fi michael@0: fi michael@0: fi michael@0: fi michael@0: case $HOST in michael@0: *\.*) michael@0: Debug "HOSTNAME $HOST contains Dot" michael@0: HOST=`echo $HOST | sed -e "s/\..*//"` michael@0: ;; michael@0: esac michael@0: if [ -z "$HOST" ] michael@0: then michael@0: HOST=`uname -n` michael@0: case $HOST in michael@0: *\.*) michael@0: Debug "HOSTNAME $HOST contains Dot" michael@0: HOST=`echo $HOST | sed -e "s/\..*//"` michael@0: ;; michael@0: esac michael@0: fi michael@0: if [ $O_DEBUG = "ON" ] michael@0: then michael@0: while [ $init_host_done -eq 0 ] michael@0: do michael@0: Echo michael@0: ask "DOMSUF=$DOMSUF, HOST=$HOST - OK", "y" "n" && michael@0: init_host_done=1 michael@0: if [ $init_host_done -eq 0 ] michael@0: then michael@0: Echo "input DOMSUF: " michael@0: read D michael@0: if [ -n "$D" ] michael@0: then michael@0: DOMSUF=$D michael@0: fi michael@0: Echo "input HOST: " michael@0: read H michael@0: if [ -n "$H" ] michael@0: then michael@0: HOST=$H michael@0: fi michael@0: fi michael@0: done michael@0: fi michael@0: export HOST DOMSUF michael@0: Debug "HOST: $HOST, DOMSUF: $DOMSUF" michael@0: } michael@0: michael@0: #-----------------------------# UTILS #---------------------------------- michael@0: michael@0: ########################### qa_stat_get_sysinfo ######################## michael@0: # local shell function, tries to determine the QA operating system michael@0: ######################################################################## michael@0: qa_stat_get_sysinfo() michael@0: { michael@0: case $1 in michael@0: ?*) REM_SYS=$1 michael@0: GET_SYSINFO="rsh $1" michael@0: ;; michael@0: *) REM_SYS="" michael@0: GET_SYSINFO="" michael@0: ;; michael@0: esac michael@0: QA_SYS=`$GET_SYSINFO uname -sr` michael@0: echo $QA_SYS | grep Linux >/dev/null && michael@0: QA_RHVER=`$GET_SYSINFO cat /etc/redhat-release` michael@0: if [ -n "$QA_RHVER" ] michael@0: then michael@0: QA_OS=`echo $REM_SYS $QA_RHVER | sed -e "s/Red Hat /RH /" \ michael@0: -e "s/ release//"` michael@0: else michael@0: case $QA_SYS in michael@0: *SunOS*5.[89]*) michael@0: ISAINFO=`$GET_SYSINFO isainfo -v` michael@0: IS_64=`echo $ISAINFO | grep 64 >/dev/null && \ michael@0: echo 64 bit` michael@0: IS_I386=`echo $ISAINFO | grep i386 >/dev/null && \ michael@0: echo i86pc` michael@0: if [ -n "$IS_I386" ] ; then IS_64="$IS_I386"; fi; michael@0: if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi; michael@0: ;; michael@0: *HP*) michael@0: IS_64=`$GET_SYSINFO getconf KERNEL_BITS | michael@0: grep 64 >/dev/null && echo 64 bit` michael@0: if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi; michael@0: ;; michael@0: *AIX*) michael@0: IS_64=`$GET_SYSINFO lslpp -l | michael@0: grep "bos.64bit"> /dev/null && echo 64 bit` michael@0: if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi; michael@0: ;; michael@0: esac michael@0: QA_OS=`echo "$REM_SYS $QA_SYS $IS_64"` michael@0: fi michael@0: if [ "$O_SILENT" != ON ] ; then michael@0: echo $QA_OS michael@0: fi michael@0: QA_OS_STRING=`echo $QA_OS | sed -e "s/^[_ ]//" -e "s/ /_/g"` michael@0: } michael@0: michael@0: ################################### set_objdir ######################### michael@0: # global shell function, sets the object directories and DIST michael@0: ######################################################################## michael@0: set_objdir() michael@0: { michael@0: Debug "set object dir" michael@0: OBJDIR=`cd ${TESTSCRIPTDIR}/common; gmake objdir_name` michael@0: OS_ARCH=`cd ${TESTSCRIPTDIR}/common; gmake os_arch` michael@0: michael@0: #at this point $MASTERBUILD needs to be either NT or unix michael@0: michael@0: set_daily_build_dirs michael@0: LOCALDIST_BIN=${LOCALDIST}/${OBJDIR}/bin michael@0: DIST=$LOCALDIST michael@0: michael@0: if [ -z "${TEST_LEVEL}" ] ; then michael@0: TEST_LEVEL=0 michael@0: fi michael@0: bc ${TEST_LEVEL} #set the path for the backward compatibility test michael@0: michael@0: PATH_CONTAINS_BIN="TRUE" michael@0: export PATH_CONTAINS_BIN michael@0: michael@0: export OBJDIR OS_ARCH LOCALDIST LOCALDIST_BIN DIST PATH michael@0: } michael@0: michael@0: ########################### bc ######################################### michael@0: # global shell function , sets paths for the backward compatibility test michael@0: ######################################################################## michael@0: bc() michael@0: { michael@0: if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then michael@0: TESTDIR=${RESULTDIR} michael@0: BC_ACTION="" michael@0: DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary michael@0: return michael@0: fi michael@0: DON_T_SET_PATHS="TRUE" michael@0: case $1 in michael@0: 0) michael@0: #unset TESTDIR michael@0: TESTDIR=${RESULTDIR} michael@0: if [ "$O_WIN" = "ON" -a "$O_CYGNUS" != ON ] ; then michael@0: PATH="$TESTSCRIPTDIR;$LOCALDIST_BIN;$BASEPATH" michael@0: else michael@0: PATH=$TESTSCRIPTDIR:$LOCALDIST_BIN:$BASEPATH michael@0: fi michael@0: BC_ACTION="" michael@0: DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary michael@0: ;; michael@0: *) michael@0: if [ "$O_LOCAL" = "ON" ] ; then michael@0: Exit "FIXME Can't run backwardcompatibility tests locally yet" michael@0: fi michael@0: TESTSCRIPTDIR=${BCDIST}/../security/nss/tests michael@0: COMMON=${TESTSCRIPTDIR}/common michael@0: TESTDIR=${RESULTDIR}/bct michael@0: BC_ACTION="backward compatibility of binaries in $BC_MASTER to new libs" michael@0: BCDIST_BIN=${BCDIST}/${OBJDIR}/bin michael@0: LD_LIBRARY_PATH=${LOCALDIST}/${OBJDIR}/lib michael@0: if [ "$O_WIN" = "ON" ] ; then michael@0: if [ "$O_CYGNUS" = ON ] ; then michael@0: PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH:$LD_LIBRARY_PATH michael@0: else michael@0: PATH="$TESTSCRIPTDIR;$BCDIST_BIN;$BASEPATH;$LD_LIBRARY_PATH" michael@0: fi michael@0: else michael@0: PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH michael@0: fi michael@0: Debug "1st stage of backward compatibility test" michael@0: ;; michael@0: esac michael@0: if [ -n "$TESTDIR" ] ; then michael@0: if [ ! -d $TESTDIR ] ; then michael@0: mkdir -p $TESTDIR michael@0: fi michael@0: export TESTDIR michael@0: fi michael@0: SHLIB_PATH=${LD_LIBRARY_PATH} michael@0: LIBPATH=${LD_LIBRARY_PATH} michael@0: Debug "PATH $PATH" michael@0: Debug "LD_LIBRARY_PATH $LD_LIBRARY_PATH" michael@0: export PATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH michael@0: export DON_T_SET_PATHS BC_ACTION michael@0: export TESTSCRIPTDIR COMMON michael@0: } michael@0: michael@0: ########################### Ps ######################################### michael@0: # global shell function , attempts a platform specific ps michael@0: ######################################################################## michael@0: Ps() michael@0: { michael@0: #AIX, OSF ps -ef, solaris /usr/5bin/ps -ef, win ps -ef but no user id michael@0: #linux ps -ef, HP michael@0: michael@0: if [ $os_name = "SunOS" ] michael@0: then michael@0: /usr/5bin/ps -ef michael@0: else michael@0: ps -ef michael@0: fi michael@0: } michael@0: michael@0: ########################### kill_by_name ################################ michael@0: # global shell function , kills the process whose name is given as michael@0: # parameter michael@0: ######################################################################## michael@0: kill_by_name() michael@0: { michael@0: for PID in `Ps | grep "$1" | grep -v grep | \ michael@0: sed -e "s/^ *//g" -e "s/^[^ ]* //" -e "s/^ *//g" -e "s/ .*//g"` michael@0: do michael@0: if [ $O_WIN = "ON" -a $O_CYGNUS = "ON" ] michael@0: then michael@0: ask "Do you want to kill Process $PID (`Ps | grep $PID | \ michael@0: grep -v grep | awk '{ print $1, $2, $6, $7, $8, $9 }' | \ michael@0: sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \ michael@0: "y" "n" && { michael@0: kill $PID michael@0: sleep 1 michael@0: kill -9 $PID 2>/dev/null michael@0: } michael@0: else michael@0: ask "Do you want to kill Process $PID (`Ps | grep $PID | \ michael@0: grep -v grep | awk '{ print $1, $2, $8, $9, $10, $11 }' | \ michael@0: sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \ michael@0: "y" "n" && { michael@0: kill $PID michael@0: sleep 1 michael@0: kill -9 $PID 2>/dev/null michael@0: } michael@0: fi michael@0: done michael@0: } michael@0: michael@0: ############################### early_exit ################################### michael@0: # global shell function , attempts a little more usefull user notification michael@0: # of a complete failure michael@0: ######################################################################## michael@0: michael@0: early_exit() michael@0: { michael@0: if [ -z "$DOCDIR" ] michael@0: then michael@0: DOCDIR=`dirname $0`/../doc michael@0: fi michael@0: if [ -f $DOCDIR/QAerror.html ] michael@0: then michael@0: Debug "Found QA errorheader" michael@0: rm ${FILENAME}.err 2>/dev/null michael@0: cp $DOCDIR/QAerror.html ${FILENAME}.err michael@0: echo "$1" >>${FILENAME}.err michael@0: echo '' >>${FILENAME}.err michael@0: if [ -n "$FILENAME" -a -f "$FILENAME" ] michael@0: then michael@0: cat $FILENAME | sed -e "s/^/
/" >>${FILENAME}.err michael@0: fi michael@0: echo '' >>${FILENAME}.err michael@0: cat ${FILENAME}.err | $RMAIL $MAILINGLIST michael@0: michael@0: rm ${FILENAME}.err 2>/dev/null michael@0: #echo "cat ${FILENAME}.err | $RMAIL $MAILINGLIST " michael@0: fi michael@0: } michael@0: michael@0: ############################### Exit ################################### michael@0: # global shell function , central exiting point michael@0: # cleanup: temporary files, kill the remaining selfservers if sourcing michael@0: # script sets KILL_SELFSERV michael@0: ######################################################################## michael@0: Exit() michael@0: { michael@0: Echo $1 michael@0: if [ "$O_CRON" = "OFF" ] michael@0: then michael@0: echo $1 >&2 michael@0: fi michael@0: if [ -f "${KILLPIDS}" ] michael@0: then michael@0: Debug "Attempting to kill background processes...`cat ${KILLPIDS}`" michael@0: kill `cat "${KILLPIDS}"` michael@0: sleep 1 michael@0: kill -9 `cat "${KILLPIDS}"` michael@0: fi michael@0: if [ -n "${TMPFILES}" ] michael@0: then michael@0: Debug "rm -f ${TMPFILES}" michael@0: rm -f $TMPFILES 2>/dev/null michael@0: fi michael@0: O_ALWAYS_YES=ON # set to non-interactive - don't ask anymore questions here michael@0: if [ $KILL_SELFSERV = "ON" ] michael@0: then michael@0: kill_by_name selfserv michael@0: fi michael@0: if [ $O_MAIL_LINK = "ON" -a $O_FILE = "ON" ] michael@0: then michael@0: if [ $EARLY_EXIT = TRUE ] #before the report file has been created michael@0: then michael@0: early_exit "$1" michael@0: else michael@0: head -3 $FILENAME >$ML_FILE michael@0: echo "Content-Type: text/plain; charset=us-ascii; format=flowed michael@0: Content-Transfer-Encoding: 7bit michael@0: michael@0: " >>$ML_FILE michael@0: echo $HREF_TMP_HTML_FILE >>$ML_FILE michael@0: cat $ML_FILE | $RMAIL $MAILINGLIST michael@0: fi michael@0: michael@0: #FIXME - early exit etc michael@0: elif [ $O_MAIL = "ON" -a $O_FILE = "ON" ] michael@0: then michael@0: if [ $EARLY_EXIT = TRUE ] #before the report file has been created michael@0: then michael@0: early_exit "$1" michael@0: elif [ -n "$FILENAME" -a -f "$FILENAME" ] michael@0: then michael@0: cat $FILENAME | $RMAIL $MAILINGLIST michael@0: fi michael@0: #rm $FILENAME 2>/dev/null michael@0: elif [ $O_MAIL = "ON" -a $EARLY_EXIT = TRUE ] michael@0: then michael@0: early_exit "$1" michael@0: rm $FILENAME 2>/dev/null michael@0: fi michael@0: #chmod a+rw ${RESULTDIR} ${RESULTDIR}/* ${RESULTDIR}/*/* & michael@0: if [ -n "$O_TBX" -a "$O_TBX" = "ON" ] ; then michael@0: rm ${TESTDIR}/QAstatus michael@0: michael@0: if [ "$1" = "killed... cleaning up..." ] ; then michael@0: echo "QA killed" >${TESTDIR}/QAstatus michael@0: elif [ "$TBX_EXIT" = 0 ] ; then michael@0: echo "QA passed" >${TESTDIR}/QAstatus michael@0: else michael@0: echo "QA failed" >${TESTDIR}/QAstatus michael@0: fi michael@0: michael@0: exit $TBX_EXIT michael@0: michael@0: else michael@0: exit michael@0: fi michael@0: } michael@0: michael@0: trap "rm -f ${TMPFILES} 2>/dev/null; Exit 'killed... cleaning up...'" 2 3 15 michael@0: michael@0: ################################ Wait ################################## michael@0: # global shell function to wait for an event to happen, 1st parameter michael@0: # filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait michael@0: # for it to be created. michael@0: # uses the variables WAIT_FOR and WAIT_TIMES michael@0: # WAIT_FOR: if waiting for an event sleep n seconds before rechecking michael@0: # recomended value 10 minutes 600 michael@0: # WAIT_TIMES: recheck n times before giving up to prevent endless loop michael@0: # recomended 30 - total of 5h michael@0: ######################################################################## michael@0: michael@0: Wait() michael@0: { michael@0: i=0 michael@0: Debug "Waiting for $1" michael@0: while [ $i -lt $WAIT_TIMES ] michael@0: do michael@0: i=`expr $i + 1` michael@0: if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to michael@0: then michael@0: return michael@0: fi michael@0: if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist michael@0: then michael@0: return michael@0: fi michael@0: Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds zzzz..." michael@0: sleep $WAIT_FOR michael@0: done michael@0: TOTAL=`expr $WAIT_TIMES \* $WAIT_FOR / 60` michael@0: Exit "I HAVE WAITED LONG ENOUGH FOR $1 NOW, I'M GONE! (THAT WAS A TOTAL OF $TOTAL MINUTES) I have better things to do... " michael@0: } michael@0: michael@0: ################################ WaitForever ################################## michael@0: # global shell function to wait for an event to happen, 1st parameter michael@0: # filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait michael@0: # for it to be created. michael@0: # because we daon't have any relyable cron on NT... michael@0: ######################################################################## michael@0: michael@0: WaitForever() michael@0: { michael@0: i=0 michael@0: Debug "Waiting for $1" michael@0: TOTAL=0 michael@0: while [ 1 ] michael@0: do michael@0: i=`expr $i + 1` michael@0: if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to michael@0: then michael@0: return michael@0: fi michael@0: if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist michael@0: then michael@0: return michael@0: fi michael@0: Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds Total $TOTAL" michael@0: sleep $WAIT_FOR michael@0: TOTAL=`expr $i \* $WAIT_FOR / 60` michael@0: if [ -n "$MAX_FOREVER" ] # we are cheating. Forever can be very short... michael@0: then michael@0: if [ "$TOTAL" -gt "$MAX_FOREVER" ] michael@0: then michael@0: Exit "I HAVE WAITED LONG ENOUGH FOR $1 NOW, I'M GONE! (THAT WAS A TOTAL OF $TOTAL MINUTES) I have better things to do... " michael@0: fi michael@0: fi michael@0: done michael@0: } michael@0: ################################### is_running ######################### michael@0: # global shell function , implements primitive locking mechanism michael@0: # filename is passed as a parameter, if filename.* exists we assume calling michael@0: # script is running already and exit, otherwise filename.processid is michael@0: # created michael@0: ######################################################################## michael@0: is_running() michael@0: { michael@0: Debug "Testing if $0 is already running... file ${1} - ${1}.$$" michael@0: if [ -f ${1}.* ] michael@0: then michael@0: Exit "$0 seems to be running already ($1 exists) - Exiting" michael@0: fi michael@0: TMPFILES="$TMPFILES ${1}.$$" michael@0: echo "running $0 on `date` PID $$" >${1}.$$ michael@0: Debug "wrote \"running $0 on `date` PID $$\" to ${1}.$$" michael@0: michael@0: } michael@0: michael@0: #---------------------------# USERCOM #--------------------------------- michael@0: ############################## Echo ##################################### michael@0: # global shell function , depending on the options the output gets written michael@0: # to a file, or is being discarded michael@0: # FIXME \n and \c are mistreates by differnet shells, and linux has /bin/echo michael@0: # instead of /usr/bin/echo michael@0: ######################################################################## michael@0: Echo () michael@0: { michael@0: if [ $O_SILENT = OFF ] michael@0: then michael@0: echo "$*" michael@0: #/usr/bin/echo "$*" michael@0: fi michael@0: if [ $O_FILE = ON ] michael@0: then michael@0: echo "$*" >>$FILENAME michael@0: fi michael@0: } michael@0: michael@0: ################################### ask ################################ michael@0: # global shell function, Asks the a question, and gives the returns 0 michael@0: # on the 1st choice, 1 on the 2nd choice michael@0: # michael@0: # PARAMETERS: michael@0: # $1 question text michael@0: # $2 1st choice michael@0: # $3 2nd choice michael@0: # michael@0: # MODIFIERS: michael@0: # -y O_ALWAYS_YES will assume a first choice always (not neccessaryly "y") michael@0: # michael@0: # RETURN: michael@0: # 0 - User picked 1st choice michael@0: # 1 - User picked 2nd choice michael@0: # michael@0: # EXAMPLE michael@0: # ask "Would you like to continue" "y" "n" || Exit michael@0: # will produce the string "Would you like to continue (y/n) ?", michael@0: # read input from keyboard (or assume a yes with option -y) michael@0: # - on a yes it will return 0, on a no it will return 1, the michael@0: # shell interprets it as error and the || Exit will be executed michael@0: # michael@0: # NOTE: NEVER use "n" as the second parameter - it will mess up -y michael@0: # don't ask "Continue" "n" "y" || Exit # it will Exit on a "y" michael@0: # michael@0: ######################################################################## michael@0: Ask() michael@0: { michael@0: ask $* michael@0: } michael@0: michael@0: ask() michael@0: { michael@0: if [ $O_ALWAYS_YES = ON ] michael@0: then michael@0: Echo "$1 ($2/$3) ?" michael@0: Echo "YES!" michael@0: return 0 michael@0: fi michael@0: A="" michael@0: while [ 1 ] michael@0: do michael@0: michael@0: Echo "$1 ($2/$3) ?" michael@0: read A michael@0: if [ -n "$A" ] michael@0: then michael@0: if [ $A = $2 ] michael@0: then michael@0: return 0 michael@0: elif [ $A = $3 ] michael@0: then michael@0: return 1 michael@0: fi michael@0: fi michael@0: done michael@0: return 0 michael@0: } michael@0: michael@0: ################################### Warning ############################ michael@0: # global shell function, Asks the user a "... continue? (y/n)" question, michael@0: # and exits when the user answers with no michael@0: # NOTE -y will answer the warnings always with yes michael@0: ######################################################################## michael@0: Warning () michael@0: { michael@0: ask "WARNING: $0: \n $* continue " "y" "n" || Exit michael@0: } michael@0: michael@0: ################################### Debug ############################ michael@0: # global shell function, when option -d Debugging output is written michael@0: ######################################################################## michael@0: Debug() michael@0: { michael@0: if [ $O_DEBUG = ON ] michael@0: then michael@0: Echo "DEBUG: (`date +%H:%M`) $0: $*" michael@0: fi michael@0: } michael@0: michael@0: ################################### line ############################### michael@0: # global shell function, supposed to make output more readable... michael@0: ######################################################################## michael@0: line() michael@0: { michael@0: Echo michael@0: #Echo "=======================================================================" michael@0: #Echo michael@0: } michael@0: michael@0: ################################### opt_usage ########################## michael@0: # global shell function, tells user about available options michael@0: ######################################################################## michael@0: opt_usage() michael@0: { michael@0: if [ $O_OPTIONS = "ON" ] michael@0: then michael@0: Echo michael@0: line michael@0: Echo michael@0: Echo " -y answer all questions with y - use at your own risk..." michael@0: Echo " -s silent (only usefull with -y)" michael@0: Echo " -h, -? - you guessed right - displays this text" michael@0: Echo " -d debug" michael@0: Echo " -f - write the (error)output to filename" michael@0: Echo " -fcronfile produces the resultfiles in the same locations" michael@0: Echo " as would have been produced with -cron" michael@0: Echo " -m - send filename to mailinglist (csl " michael@0: Echo " example sonmi,nelsonb,wtc) only useful with -f" michael@0: Echo " -ml - send link to filename to mailinglist " michael@0: Echo " (csl example sonmi,nelsonb,wtc) only useful with -f" michael@0: Echo " -cron equivalient to -y -s -d -f \$RESULTDIR/\$HOST.nssqa" michael@0: Echo " -t run on a tinderbox build (included -cron)" michael@0: if [ `basename $0` = nssqa ] ; then michael@0: Echo " -l run on a local build" michael@0: Echo " -ln copy a networkbuild to a local directory " michael@0: Echo " mozroot, used for networkindipendend QA " michael@0: Echo " -lt try to copy a networkbuild to a local directory, if" michael@0: Echo " not possible run on the network michael@0: Echo " used for networkindipendend QA michael@0: fi michael@0: # michael@0: # special strings michael@0: fi michael@0: michael@0: } michael@0: michael@0: ################################### glob_usage ######################### michael@0: # global shell function, how to use the calling script (parameters, options) michael@0: ######################################################################## michael@0: glob_usage() michael@0: { michael@0: line michael@0: Echo $1 michael@0: Echo michael@0: if [ $O_OPTIONS = "ON" ] michael@0: then michael@0: Echo "usage $0 [options] nssversion builddate" michael@0: else michael@0: Echo "usage $0 nssversion builddate" michael@0: fi michael@0: michael@0: Echo " for example: $0 30b 0926" michael@0: Echo " $0 31 1002" michael@0: opt_usage michael@0: Echo michael@0: Exit "$1" michael@0: } michael@0: michael@0: tell() michael@0: { michael@0: if [ $O_SILENT = OFF ] michael@0: then michael@0: line michael@0: pwd michael@0: ls -CF michael@0: line michael@0: fi michael@0: if [ $O_FILE = ON ] michael@0: then michael@0: line michael@0: pwd >>$FILENAME michael@0: ls -CF >>$FILENAME michael@0: line michael@0: fi michael@0: } michael@0: michael@0: if [ $O_INIT = "ON" ] michael@0: then michael@0: glob_init $* michael@0: fi michael@0: EARLY_EXIT=FALSE