security/nss/tests/header

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/tests/header	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,1636 @@
     1.4 +#! /bin/sh
     1.5 +
     1.6 +########################################################################
     1.7 +#
     1.8 +# /u/sonmi/bin/header - /u/svbld/bin/init/nss/header
     1.9 +#
    1.10 +# variables, utilities and shellfunctions global to NSS QA
    1.11 +# needs to work on all Unix platforms
    1.12 +#
    1.13 +# included from (don't expect this to be up to date)
    1.14 +# --------------------------------------------------
    1.15 +#   qa_stat
    1.16 +#   mksymlinks 
    1.17 +#   nssqa 
    1.18 +#
    1.19 +# parameters
    1.20 +# ----------
    1.21 +#   nssversion (supported: 30b, 31, 332, tip 32)
    1.22 +#   builddate (default - today)
    1.23 +#
    1.24 +# options
    1.25 +# -------
    1.26 +#   -y answer all questions with y - use at your own risk... ignores warnings 
    1.27 +#   -s silent (only usefull with -y)
    1.28 +#   -h, -? - you guessed right - displays this text
    1.29 +#   -d debug
    1.30 +#   -f <filename> - write the (error)output to filename
    1.31 +#   -fcronfile produces the resultfiles in the same locations
    1.32 +#       as would have been produced with -cron
    1.33 +#   -m <mailinglist> - send filename to mailinglist (csl) only useful
    1.34 +#       with -f
    1.35 +#   -ml <mailinglist> - send link to filename to mailinglist (csl) 
    1.36 +#       only useful with -f
    1.37 +#   -cron equivalient to -y -s -d -f $RESULTDIR/$HOST.<scriptname>
    1.38 +#   -t  run on a tinderbox build that means: local, from the startlocation
    1.39 +#   -l <mozroot directory>  run on a local build mozroot
    1.40 +#   -ln <mozroot> copy a networkbuild to a local directory mozroot, 
    1.41 +#        used for networkindipendend QA
    1.42 +#   -lt try to copy a networkbuild to a local directory, if not possible
    1.43 +#        run on the network
    1.44 +#        used for networkindipendend QA
    1.45 +#
    1.46 +# special strings
    1.47 +# ---------------
    1.48 +#   FIXME ... known problems, search for this string
    1.49 +#   NOTE .... unexpected behavior
    1.50 +#
    1.51 +# moduls (not yet)
    1.52 +# ----------------
    1.53 +#   --# INIT
    1.54 +#   --# USERCOM
    1.55 +#   --# UTILS
    1.56 +#
    1.57 +# FIXME - split in init / usercom / utils
    1.58 +#
    1.59 +########################################################################
    1.60 +
    1.61 +#------------------------------# INIT #------------------------------
    1.62 +
    1.63 +# below the option flags get initialized
    1.64 +
    1.65 +if [ -z "$QASCRIPT_DIR" ]
    1.66 +then
    1.67 +    QASCRIPT_DIR=`dirname $0`
    1.68 +    if [ "$QASCRIPT_DIR" = '.' ]
    1.69 +    then
    1.70 +        QASCRIPT_DIR=`pwd`
    1.71 +    fi
    1.72 +fi
    1.73 +export QASCRIPT_DIR
    1.74 +
    1.75 +O_HWACC=OFF
    1.76 +if [ -z "$O_ALWAYS_YES" ] ; then
    1.77 +    O_ALWAYS_YES=OFF    # turned on by -y answer all questions with y 
    1.78 +fi
    1.79 +
    1.80 +if [ -z "$O_INIT" ] # header is global, some including scripts may not
    1.81 +then                # want the init to run, the others don't need to bother
    1.82 +    O_INIT=ON
    1.83 +fi
    1.84 +if [ -z "$O_PARAM" ] # header is global, some including scripts may not
    1.85 +then                 # require parameters, the others don't need to bother
    1.86 +    O_PARAM=ON
    1.87 +fi
    1.88 +if [ -z "$O_OPTIONS" ] # header is global, some including scripts may not
    1.89 +then                # permit options, they don't need to bother
    1.90 +    O_OPTIONS=OFF
    1.91 +fi
    1.92 +O_SILENT=OFF        # turned on by -s silent (only usefull with -y)
    1.93 +if  [ -z "$O_DEBUG" ] ; then
    1.94 +    O_DEBUG=OFF     # turned on by -d - calls to Debug produce output when ON
    1.95 +fi
    1.96 +O_FILE=OFF          # turned on by -f echo all output to a file $FILENAME
    1.97 +O_CRON=OFF          # turned on by -cron cron use only
    1.98 +O_CRONFILE=OFF      # turned on by -cron cron and -fcron
    1.99 +O_LOCAL=OFF         # turned on by -l* run on a local build in $LOCAL_MOZROOT
   1.100 +O_LN=OFF            # turned on by -ln and -lt, test a networkbuild locally
   1.101 +O_MAIL=OFF          # turned on by -m - sends email
   1.102 +O_MAIL_LINK=OFF     # turned on by -ml - sends email
   1.103 +O_TBX=OFF           # turned on by -t run on a tinderbox build
   1.104 +                    # that means: local, from the startlocation
   1.105 +
   1.106 +if  [ -z "$DOMSUF" ]
   1.107 +then
   1.108 +    
   1.109 +    DOMSUF=red.iplanet.com
   1.110 +    DS_WAS_SET=FALSE
   1.111 +else
   1.112 +    DS_WAS_SET=TRUE
   1.113 +fi
   1.114 +
   1.115 +TMPFILES=""
   1.116 +
   1.117 +WAIT_FOR=600  # if waiting for an event sleep n seconds before rechecking 
   1.118 +              # recomended value 10 minutes 600
   1.119 +WAIT_TIMES=30 # recheck n times before giving up - recomended 30 - total of 5h
   1.120 +
   1.121 +if [ -z "$QAYEAR" ]   # may I introduce - the y2k+1 bug? QA for last year 
   1.122 +then                  # might not work
   1.123 +    QAYEAR=`date +%Y`
   1.124 +fi
   1.125 +
   1.126 +if [ -z "$TMP" ]        
   1.127 +then
   1.128 +    if [  -z "$TEMP" ]
   1.129 +    then
   1.130 +        TMP="/tmp"
   1.131 +    else
   1.132 +        TMP=$TEMP
   1.133 +    fi
   1.134 +fi
   1.135 +if [ ! -w "$TMP" ]        
   1.136 +then
   1.137 +    echo "Can't write to tmp directory $TMP - exiting"
   1.138 +    echo "Can't write to tmp directory $TMP - exiting" >&2
   1.139 +    exit 1
   1.140 +fi
   1.141 +
   1.142 +KILLPIDS="$TMP/killpids.$$"
   1.143 +export KILLERPIDS
   1.144 +TMPFILES="$TMPFILES $KILLPIDS"
   1.145 +
   1.146 +KILL_SELFSERV=OFF   # if sourcing script sets this to on cleanup will also 
   1.147 +                    # kill the running selfserv processes
   1.148 +
   1.149 +                    # Set the masterbuilds 
   1.150 +if [ -z "$UX_MASTERBUILD" ]
   1.151 +then                     
   1.152 +    UX_MASTERBUILD=booboo_Solaris8
   1.153 +    #if [ ! -d $UX_MASTERBUILD ] ; then
   1.154 +        #UX_MASTERBUILD=booboo_Solaris8_forte6
   1.155 +    #fi
   1.156 +    UX_MB_WAS_SET=FALSE
   1.157 +else
   1.158 +    UX_MB_WAS_SET=TRUE
   1.159 +fi
   1.160 +if [ -z "$NT_MASTERBUILD" ]
   1.161 +then                     
   1.162 +    NT_MASTERBUILD=blowfish_NT4.0_Win95
   1.163 +    NT_MB_WAS_SET=FALSE      # in this case later functions can override if
   1.164 +                             # they find a different build that looks like NT
   1.165 +else
   1.166 +    NT_MB_WAS_SET=TRUE
   1.167 +fi
   1.168 +if [ -z "$MASTERBUILD" ]    
   1.169 +then
   1.170 +    MASTERBUILD=$UX_MASTERBUILD
   1.171 +fi
   1.172 +
   1.173 +                    # Set the default build
   1.174 +if [ -z "$BUILDNUMBER" ]    
   1.175 +then
   1.176 +    BUILDNUMBER=1
   1.177 +fi
   1.178 +export BUILDNUMBER
   1.179 +O_LDIR=OFF          #local QA dir for NT, temporary
   1.180 +
   1.181 +if [ -z "$WIN_WAIT_FOREVER" ]    # header is global, some including scripts 
   1.182 +then                # want the init to wait forever for directories to
   1.183 +                    # appear (windows only) if OFF exit, if ON wait forever
   1.184 +    WIN_WAIT_FOREVER=OFF
   1.185 +fi
   1.186 +
   1.187 +                          # NOTE: following variables have to change 
   1.188 +                          # from release to release
   1.189 +if [ -z "$BC_MASTER" ]    # master directory for backwardscompatibility testing
   1.190 +then
   1.191 +    RH="NO"
   1.192 +    grep 7.1 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES"
   1.193 +    grep 7.2 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES"
   1.194 +
   1.195 +    if [ "$RH" = "YES" ] 
   1.196 +    then                      # NSS-3-3-1RTM
   1.197 +        BC_UX_MASTER=nss331/builds/20010928.2.331-RTM/booboo_Solaris8
   1.198 +        BC_NT_MASTER=nss331/builds/20010928.2.331-RTM/blowfish_NT4.0_Win95
   1.199 +    else                      # NSS-3-2-2RTM
   1.200 +        BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
   1.201 +        BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
   1.202 +    fi
   1.203 +    BC_MASTER=$BC_UX_MASTER
   1.204 +    BC_MASTER_WAS_SET=FALSE
   1.205 +else
   1.206 +    BC_MASTER_WAS_SET=TRUE
   1.207 +fi
   1.208 +BC_RELEASE=3.2
   1.209 +export BC_RELEASE
   1.210 +
   1.211 +EARLY_EXIT=TRUE     #before the report file has been created, causes Exit to 
   1.212 +                    #create it
   1.213 +
   1.214 +UX_D0=/share/builds/mccrel3/nss
   1.215 +
   1.216 +################################### glob_init ##########################
   1.217 +# global shell function, main initialisation function
   1.218 +########################################################################
   1.219 +glob_init()
   1.220 +{
   1.221 +    if [ $O_PARAM = "ON" ] ; then
   1.222 +        eval_opts $*    # parse parameters and options - set flags
   1.223 +    fi
   1.224 +                        # if running from cron HOST needs to be known early, 
   1.225 +    init_host            # so the output file name can be constructed. 
   1.226 +    Debug "Setting up environment...( $QASCRIPT_DIR/set_environment) "
   1.227 +    . $QASCRIPT_DIR/set_environment #finds out if we are running on Windows
   1.228 +    Debug "OPerating system: $os_name $os_full"
   1.229 +    umask 0    
   1.230 +    init_dirs
   1.231 +    init_files
   1.232 +    init_vars
   1.233 +}
   1.234 +
   1.235 +################################### init_vars ###########################
   1.236 +# global shell function, sets the environment variables, part of init 
   1.237 +########################################################################
   1.238 +init_vars()
   1.239 +{
   1.240 +    if [ -z "$LOGNAME" ]
   1.241 +    then
   1.242 +        if [ $O_WIN = "ON" ]
   1.243 +        then
   1.244 +            LOGNAME=$USERNAME
   1.245 +        else
   1.246 +            LOGNAME=$USER
   1.247 +        fi
   1.248 +        if [ -z "$LOGNAME" ]
   1.249 +        then
   1.250 +            LOGNAME=$UNAME
   1.251 +            if [ -z "$LOGNAME" ]
   1.252 +            then
   1.253 +                LOGNAME=`basename $HOME`
   1.254 +            fi
   1.255 +        fi
   1.256 +    fi
   1.257 +    if [ -z "$LOGNAME" ]
   1.258 +    then
   1.259 +        Exit "Can't determine current user"
   1.260 +    fi
   1.261 +    case $HOST in
   1.262 +        iws-perf)
   1.263 +            O_HWACC=ON
   1.264 +            HWACC_LIST="rainbow ncipher"
   1.265 +            #MODUTIL="-add rainbow -libfile /usr/lib/libcryptoki22.so"
   1.266 +            export HWACC_LIST
   1.267 +            ;;
   1.268 +        *)
   1.269 +            O_HWACC=OFF
   1.270 +            ;;
   1.271 +    esac
   1.272 +   export O_HWACC
   1.273 +}
   1.274 +
   1.275 +########################################################################
   1.276 +# functions below deal with setting up the directories and PATHs for
   1.277 +# all different flavors of OS (Unix, Linux, NT MKS, NT Cygnus) and QA
   1.278 +# (Standard, local tinderbox)
   1.279 +########################################################################
   1.280 +
   1.281 +########################## find_nt_masterbuild #########################
   1.282 +# global shell function, sets the nt masterbuild directories, part of init 
   1.283 +########################################################################
   1.284 +find_nt_masterbuild()
   1.285 +{
   1.286 +    NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD}
   1.287 +    if [ "${NT_MB_WAS_SET}" = "FALSE" -a ! -d $NT_MASTERDIR ] ; then
   1.288 +        if [ -d ${DAILY_BUILD}/*NT4* ] ; then
   1.289 +            NT_MASTERBUILD=` cd ${DAILY_BUILD}; ls -d *NT4* `
   1.290 +            Debug "NT_MASTERBUILD $NT_MASTERBUILD"
   1.291 +            NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD}
   1.292 +        fi
   1.293 +    fi
   1.294 +    Debug "NT_MASTERDIR $NT_MASTERDIR"
   1.295 +}
   1.296 +
   1.297 +################################### set_daily_build_dirs ###########################
   1.298 +# global shell function, sets directories 
   1.299 +########################################################################
   1.300 +set_daily_build_dirs()
   1.301 +{
   1.302 +    if [ "$O_LOCAL" = "ON" -a "$O_LN" = "OFF" ] ; then
   1.303 +        DAILY_BUILD=${LOCAL_MOZROOT}        # on local builds NSS_VER_DIR and DAILY_BUILD are 
   1.304 +                             # set to the LOCAL_MOZROOT, since it is not sure
   1.305 +                             # if ../.. (DAILY_BUILD) even exists
   1.306 +        LOCALDIST=${LOCAL_MOZROOT}/dist
   1.307 +    elif [ "$O_TBX" = "ON" ] ; then
   1.308 +        DAILY_BUILD="$TBX_DAILY_BUILD"
   1.309 +        LOCALDIST=${UXDIST}
   1.310 +    else
   1.311 +        DAILY_BUILD=${NSS_VER_DIR}/builds/${QAYEAR}${BUILDDATE}.${BUILDNUMBER}
   1.312 +        LOCALDIST=${DAILY_BUILD}/${MASTERBUILD}/mozilla/dist
   1.313 +    fi
   1.314 +}
   1.315 +
   1.316 +map_os64()
   1.317 +{
   1.318 +  IS_64=""
   1.319 +  case `uname -s` in
   1.320 +      #OSF1) has been done already - always 64 bit
   1.321 +      SunOS)
   1.322 +          MAPPED_OS=Solaris*8
   1.323 +          IS_64=`(isainfo -v | grep 64)>/dev/null 2>/dev/null && echo 64 bit`
   1.324 +          if [ "$O_TBX" = "OFF" ] ; then
   1.325 +              set_osdir
   1.326 +              if [ -n "$IS_64" ]
   1.327 +              then #Wait for the 64 bit build to finish...
   1.328 +                  Debug Testing build for $MAPPED_OS in $OSDIR
   1.329 +                  Wait ${OSDIR}/SVbuild.InProgress.1 0
   1.330 +              fi
   1.331 +          fi
   1.332 +          ;;
   1.333 +      AIX)
   1.334 +          IS_64=`lslpp -l | grep "bos.64bit"> /dev/null && echo 64 bit`
   1.335 +          ;;
   1.336 +      HP-UX)
   1.337 +          IS_64=`getconf KERNEL_BITS | grep 64 >/dev/null && echo 64 bit`
   1.338 +          ;;
   1.339 +  esac
   1.340 +  Debug "Mapped OS to $MAPPED_OS"
   1.341 +}
   1.342 +
   1.343 +
   1.344 +
   1.345 +################################### copy_to_local ########################
   1.346 +# global shell function, copies the necessary directories from the 
   1.347 +# daily build aerea to the local disk
   1.348 +########################################################################
   1.349 +copy_to_local()
   1.350 +{
   1.351 +    Debug "Copy network directories to local directories"
   1.352 +    C2L_ERROR=0
   1.353 +    if [ ! -d ${LOCAL_MOZROOT}/dist ] ; then
   1.354 +        mkdir -p ${LOCAL_MOZROOT}/dist || C2L_ERROR=1
   1.355 +    fi
   1.356 +    if [ ! -d ${LOCAL_MOZROOT}/security/nss ] ; then
   1.357 +        mkdir -p ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=2
   1.358 +    fi
   1.359 +    if [ $C2L_ERROR != 0 ] ; then
   1.360 +        Exit "copy_to_local: Can t make necesssary directories ($C2L_ERROR ) "
   1.361 +    fi
   1.362 +    if [ ! -d ${LOCAL_MOZROOT}/security/nss/tests ] ; then
   1.363 +        cp -r ${TESTSCRIPTDIR} ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=1
   1.364 +    fi
   1.365 +    if [ ! -d ${LOCAL_MOZROOT}/security/coreconf ] ; then
   1.366 +        cp -r ${MOZILLA_ROOT}/security/coreconf ${LOCAL_MOZROOT}/security || C2L_ERROR=2
   1.367 +    fi
   1.368 +    
   1.369 +    NO_DIRS=0;
   1.370 +    if [ "$O_WIN" = "ON" ] ; then
   1.371 +        OS_TARGET=WINNT;export OS_TARGET
   1.372 +    fi
   1.373 +    unset BUILD_OPT;export BUILD_OPT;
   1.374 +    unset USE_64;export USE_64;
   1.375 +#FIXME only tested on 64 bit Solaris and only got 32 bit builds
   1.376 +    while [ $NO_DIRS -lt 4 ] ; do
   1.377 +                                                  # first time thru: Debug 32 bit NT
   1.378 +        set_objdir
   1.379 +        Debug "Copying ${OBJDIR}..."
   1.380 +        if [ ! -d ${LOCAL_MOZROOT}/dist/${OBJDIR} ] ; then
   1.381 +            cp -r ${LOCALDIST}/${OBJDIR} ${LOCAL_MOZROOT}/dist || C2L_ERROR=3
   1.382 +        fi
   1.383 +        NO_DIRS=`expr $NO_DIRS + 1`
   1.384 +        if [ $NO_DIRS = 1 ] ; then                # 2nd time: OPT 32 bit NT
   1.385 +            BUILD_OPT=1; export BUILD_OPT;
   1.386 +        elif [ $NO_DIRS = 2 ] ; then              # 3rd time: OPT, either 64 bit or Win95 or force exit
   1.387 +            if [ "$O_WIN" = "ON" ] ; then
   1.388 +                OS_TARGET=WIN95;export OS_TARGET
   1.389 +            else
   1.390 +                map_os64
   1.391 +                if [ -z "$IS_64" ] ; then #32 bit platform
   1.392 +                    NO_DIRS=4
   1.393 +                else
   1.394 +                    USE_64=1; export USE_64
   1.395 +                fi
   1.396 +            fi
   1.397 +        elif [ $NO_DIRS = 3 ] ; then              # 4th time:  Debug either 64 bit or Win95
   1.398 +            unset BUILD_OPT;export BUILD_OPT;
   1.399 +        fi
   1.400 +     
   1.401 +            
   1.402 +    done
   1.403 +    if [ $C2L_ERROR != 0 ] ; then
   1.404 +        Exit "copy_to_local: Can t copy necesssary directories ($C2L_ERROR ) "
   1.405 +    fi
   1.406 +    unset TESTSCRIPTDIR
   1.407 +    unset TESTDIR
   1.408 +    unset RESULTDIR
   1.409 +    O_LN=OFF       #from here on pretend it is regular -l local QA FIXME, might cause 
   1.410 +                   #problems with the backwardcompatibility tests
   1.411 +    Debug "Successfully copied network directories to local directories"
   1.412 +}
   1.413 +
   1.414 +################################### local_dirs ###########################
   1.415 +# global shell function, sets the directories for local QA
   1.416 +########################################################################
   1.417 +local_dirs()
   1.418 +{
   1.419 +    Debug "Set directories for local QA"
   1.420 +    #if [ "$O_WIN" = "ON" ] ; then
   1.421 +        #win_set_tmp
   1.422 +    #fi
   1.423 +    NSS_VER_DIR=${LOCAL_MOZROOT}        # on local builds NSS_VER_DIR and DAILY_BUILD are 
   1.424 +                         # set to the LOCAL_MOZROOT, since it is not sure
   1.425 +                         # if ../../../.. (NSS_VER_DIR) even exists
   1.426 +    if [ -z "${RESULTDIR}" ] ; then # needs to be local as well
   1.427 +        Debug "Setting RESULTDIR for local QA"
   1.428 +        RESULTDIR="${LOCAL_MOZROOT}/tests_results/security/${HOST}-`date +%Y%m%d-%H.%M`"
   1.429 +    fi
   1.430 +    set_daily_build_dirs
   1.431 +    UX_MASTERDIR=`dirname ${LOCAL_MOZROOT}`
   1.432 +    NT_MASTERDIR=$UX_MASTERDIR
   1.433 +    MOZILLA_ROOT=${LOCAL_MOZROOT}
   1.434 +
   1.435 +    UXDIST=${MOZILLA_ROOT}/dist
   1.436 +    NTDIST=${UXDIST}
   1.437 +
   1.438 +    if [ -z "${TESTDIR}" ] ; then 
   1.439 +        Debug "Setting TESTDIR for local QA"
   1.440 +        TESTDIR=${RESULTDIR}
   1.441 +    fi
   1.442 +    if [ -n "$TESTDIR" ] ; then
   1.443 +        if [ ! -d $TESTDIR ] ; then
   1.444 +            Debug "Making TESTDIR for local QA"
   1.445 +            mkdir -p $TESTDIR
   1.446 +        fi
   1.447 +    fi
   1.448 +    export TESTDIR
   1.449 +    Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
   1.450 +
   1.451 +    TESTSCRIPTDIR=${LOCAL_MOZROOT}/security/nss/tests
   1.452 +    COMMON=${TESTSCRIPTDIR}/common
   1.453 +
   1.454 +    set_objdir
   1.455 +    debug_dirs
   1.456 +    export_dirs
   1.457 +}
   1.458 +
   1.459 +
   1.460 +################################### tbx_dirs ###########################
   1.461 +# global shell function, sets the directories for tinderbox QA
   1.462 +########################################################################
   1.463 +tbx_dirs()
   1.464 +{
   1.465 +    Debug "Set directories for tinderbox"
   1.466 +    if [ "$O_WIN" = "ON" ] ; then
   1.467 +        win_set_d1 # we need the NSS_VER_DIR later
   1.468 +    else
   1.469 +        NSS_VER_DIR="$UX_D0"/nss$NSSVER
   1.470 +    fi
   1.471 +    if [ -z "${RESULTDIR}" ] ; then # needs to be different for tinderbox
   1.472 +        Debug "Setting RESULTDIR for tinderbox"
   1.473 +        TBX_NOBITS=""
   1.474 +        echo $QASCRIPT_DIR | grep 64  >/dev/null && TBX_NOBITS=64
   1.475 +        TRD="${HOST}${TBX_NOBITS}-`date +%Y%m%d-%H.%M`"
   1.476 +        RESULTDIR="${NSS_VER_DIR}/tinderbox/tests_results/security/${TRD}"
   1.477 +        if [ ${DOMSUF} = "mcom.com" -o  ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
   1.478 +            URL="sbs-rel.nscp.aoltw.net"
   1.479 +        else
   1.480 +            URL="cindercone.red.iplanet.com"
   1.481 +        fi
   1.482 +        if [ "$O_WIN" = "ON" ] ; then
   1.483 +            RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${UX_D0}/nsstip/tinderbox/tests_results/security/${TRD}\">QA</a>"
   1.484 +        else
   1.485 +            RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${RESULTDIR}\">QA</a>"
   1.486 +        fi
   1.487 +        Debug "RESULTDIRURL TinderboxPrint:$RESULTDIRURL"
   1.488 +    fi
   1.489 +    TBX_DAILY_BUILD=`cd ../../../../..;pwd`
   1.490 +    NSS_VER_DIR="${TBX_DAILY_BUILD}/../.." 
   1.491 +    TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tinderbox | sed -e 's/ .*//g'`
   1.492 +    if [ -z "$TBX_LOGFILE_DIR" ] ; then
   1.493 +        TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tbx | sed -e 's/ .*//g'`
   1.494 +        TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tbx/${TBX_LOGFILE_DIR}"
   1.495 +    else
   1.496 +        TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tinderbox/${TBX_LOGFILE_DIR}"
   1.497 +    fi
   1.498 +    Debug "Set TBX_LOGFILE_DIR ${TBX_LOGFILE_DIR}"
   1.499 +    
   1.500 +    set_daily_build_dirs
   1.501 +    UX_MASTERDIR=`cd ../../../..;pwd`
   1.502 +    NT_MASTERDIR=$UX_MASTERDIR
   1.503 +    MOZILLA_ROOT=$UX_MASTERDIR/mozilla
   1.504 +
   1.505 +    UXDIST=${MOZILLA_ROOT}/dist
   1.506 +    NTDIST=${UXDIST}
   1.507 +
   1.508 +    if [ -z "${TESTDIR}" ] ; then 
   1.509 +        Debug "Setting TESTDIR for tinderbox"
   1.510 +        TESTDIR=${RESULTDIR}
   1.511 +    fi
   1.512 +    if [ -n "$TESTDIR" ] ; then
   1.513 +        if [ ! -d $TESTDIR ] ; then
   1.514 +            Debug "Making TESTDIR for tinderbox"
   1.515 +            mkdir -p $TESTDIR
   1.516 +        fi
   1.517 +    fi
   1.518 +    Debug "Making QAstatus file"
   1.519 +    echo "QA running" >${TESTDIR}/QAstatus
   1.520 +    export TESTDIR
   1.521 +    Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
   1.522 +
   1.523 +    TESTSCRIPTDIR=`pwd`
   1.524 +    COMMON=${TESTSCRIPTDIR}/common
   1.525 +
   1.526 +    set_objdir
   1.527 +    debug_dirs
   1.528 +    export_dirs
   1.529 +}
   1.530 +
   1.531 +################################### init_mcom ###########################
   1.532 +# global shell function, sets domain specific variables for AOL's 
   1.533 +# domains according to Bishakha's instructions
   1.534 +########################################################################
   1.535 +init_mcom()
   1.536 +{
   1.537 +    Debug "Running in mcom or netscape domain - changing directories..."
   1.538 +    if [ "${UX_MB_WAS_SET}" = "FALSE" ] ; then #in case it was set
   1.539 +        # before script was called use these values 
   1.540 +        UX_MASTERBUILD=spd04_Solaris8
   1.541 +    fi
   1.542 +    if [ "${NT_MB_WAS_SET}" = "FALSE" ] ; then 
   1.543 +        NT_MASTERBUILD=spd06_NT4
   1.544 +    fi
   1.545 + 
   1.546 +    MASTERBUILD=$UX_MASTERBUILD
   1.547 +    if [ "${BC_MASTER_WAS_SET}" = "FALSE" ] ; then
   1.548 +        BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
   1.549 +        BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
   1.550 +        BC_MASTER=$BC_UX_MASTER
   1.551 +    fi
   1.552 +    UX_D0=/share/builds/sbsrel2/nss
   1.553 +    URL="sbs-rel.nscp.aoltw.net"
   1.554 +}
   1.555 +################################### init_dirs ###########################
   1.556 +# global shell function, sets the directories for standard QA
   1.557 +# calls special functions for tinderbox, windows or local QA, part of init 
   1.558 +########################################################################
   1.559 +init_dirs()
   1.560 +{
   1.561 +    if [ ${DOMSUF} = "mcom.com" -o  ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
   1.562 +        init_mcom
   1.563 +    fi
   1.564 +    if [ $O_WIN = "ON" ] ; then
   1.565 +        win_set_tmp
   1.566 +        write_to_tmpfile
   1.567 +        MASTERBUILD=$NT_MASTERBUILD
   1.568 +        BC_MASTER=$BC_NT_MASTER
   1.569 +    fi
   1.570 +    if [ "$O_LOCAL" = "ON" -a $O_LN = "OFF" ] ; then  # if it is a LN we need to know
   1.571 +                       # all the directories off the network first to copy them
   1.572 +        local_dirs     # O_LOCAL alone assumes that all the directories are already there 
   1.573 +        return
   1.574 +    elif [ "$O_TBX" = "ON" ] ; then
   1.575 +        tbx_dirs
   1.576 +        return
   1.577 +    elif [ "$O_WIN" = "ON" ] ; then
   1.578 +        win_set_d1
   1.579 +    else
   1.580 +        NSS_VER_DIR="$UX_D0"/nss$NSSVER
   1.581 +    fi
   1.582 +    #set -x
   1.583 +
   1.584 +    set_daily_build_dirs
   1.585 +
   1.586 +    if [ -z "${BCDIST}" ] ; then
   1.587 +        #BCDIST=/share/builds/mccrel3/nss/${BC_MASTER}/mozilla/dist
   1.588 +        BCDIST=${NSS_VER_DIR}/../${BC_MASTER}/mozilla/dist
   1.589 +        if [ ! -d $BCDIST -a `basename $0` != jssqa ] ; then
   1.590 +            ask "Backward compatibility directory $BCDIST does not exist, continue" "y" "n" || Exit
   1.591 +        fi
   1.592 +    fi
   1.593 +
   1.594 +    UX_MASTERDIR=${DAILY_BUILD}/${UX_MASTERBUILD}
   1.595 +    find_nt_masterbuild
   1.596 +
   1.597 +    if [ "$O_WIN" = "ON" ]
   1.598 +    then
   1.599 +        MOZILLA_ROOT=${NT_MASTERDIR}/mozilla
   1.600 +    else
   1.601 +        MOZILLA_ROOT=${UX_MASTERDIR}/mozilla
   1.602 +    fi
   1.603 +
   1.604 +    UXDIST=${UX_MASTERDIR}/mozilla/dist
   1.605 +    NTDIST=${NT_MASTERDIR}/mozilla/dist
   1.606 +
   1.607 +    if [ -z "${RESULTDIR}" ] ; then 
   1.608 +        RESULTDIR=${UX_MASTERDIR}/mozilla/tests_results/security
   1.609 +    fi
   1.610 +
   1.611 +    if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
   1.612 +
   1.613 +        if [ "$O_WIN" = "ON" ] ; then
   1.614 +            JSS_NSS_SRC_DIR=$JSS_NSS_NT_SRC_DIR
   1.615 +        fi
   1.616 +        TESTSCRIPTDIR=${NSS_VER_DIR}/../${JSS_NSS_SRC_DIR}/mozilla/security/nss/tests
   1.617 +    else
   1.618 +        TESTSCRIPTDIR=${MOZILLA_ROOT}/security/nss/tests
   1.619 +    fi
   1.620 +
   1.621 +    if [ ! -d $TESTSCRIPTDIR -a `basename $0` != jssqa ] ; then
   1.622 +        if [ "$O_WIN" = "ON" -a "$WIN_WAIT_FOREVER" = "ON" ]
   1.623 +        then
   1.624 +            WaitForever $TESTSCRIPTDIR/all.sh 1
   1.625 +        else
   1.626 +            Exit "Test directory $TESTSCRIPTDIR does not exist"
   1.627 +        fi
   1.628 +    fi
   1.629 +
   1.630 +    COMMON=${TESTSCRIPTDIR}/common
   1.631 +    if [ "$O_LOCAL" = "ON" -a $O_LN = "ON" ] ; then  # if it is a LN we need to know
   1.632 +                       # all the directories off the network first to copy them
   1.633 +        copy_to_local
   1.634 +        local_dirs     
   1.635 +    fi
   1.636 +    #set +x
   1.637 +
   1.638 +
   1.639 +    set_objdir
   1.640 +    debug_dirs
   1.641 +    export_dirs
   1.642 +}
   1.643 +
   1.644 +debug_dirs()
   1.645 +{
   1.646 +    Debug "NTDIST $NTDIST"
   1.647 +    Debug "UXDIST $UXDIST"
   1.648 +    Debug "TESTSCRIPTDIR $TESTSCRIPTDIR"
   1.649 +    Debug "RESULTDIR $RESULTDIR"
   1.650 +    Debug "TMP $TMP"
   1.651 +    Debug "LOCALDIST_BIN $LOCALDIST_BIN"
   1.652 +    Debug "COMMON $COMMON"
   1.653 +    Debug "MOZILLA_ROOT $MOZILLA_ROOT"
   1.654 +    Debug "BCDIST $BCDIST"
   1.655 +}
   1.656 +
   1.657 +export_dirs()
   1.658 +{
   1.659 +    export NSS_VER_DIR DAILY_BUILD NTDIST UXDIST RESULTDIR TESTSCRIPTDIR BCDIST
   1.660 +    export UX_MASTERDIR NT_MASTERDIR COMMON MOZILLA_ROOT
   1.661 +}
   1.662 +
   1.663 +set_osdir()
   1.664 +{
   1.665 +    OSDIR=${DAILY_BUILD}/*${MAPPED_OS}*
   1.666 +}
   1.667 +
   1.668 +################################### init_files ###########################
   1.669 +# global shell function, sets filenames, initializes files, part of init 
   1.670 +########################################################################
   1.671 +init_files()
   1.672 +{
   1.673 +    if [ $O_CRONFILE = "ON" ]
   1.674 +    then
   1.675 +        Debug "attempting to create resultfiles"
   1.676 +        if [ "$O_TBX" = "ON" ] ; then
   1.677 +            NEWFILENAME=${TBX_LOGFILE_DIR}/qa.log
   1.678 +            if [ ! -w ${TBX_LOGFILE_DIR} ] ; then
   1.679 +                Exit "can't touch $NEWFILENAME"
   1.680 +            fi
   1.681 +        else
   1.682 +            NEWFILENAME=$RESULTDIR/$HOST.`basename $0`
   1.683 +        fi
   1.684 +        if [ ! -d $RESULTDIR ]
   1.685 +        then
   1.686 +            mkdir -p $RESULTDIR || Exit "Error: can't make $RESULTDIR"
   1.687 +        fi
   1.688 +        if [ ! -w $RESULTDIR ] ; then
   1.689 +            Exit "can't touch $NEWFILENAME"
   1.690 +        fi
   1.691 +        Debug "About to touch $NEWFILENAME "
   1.692 +        touch $NEWFILENAME || Exit "Error: can't touch $NEWFILENAME"
   1.693 +        if [ "$O_TBX" = "ON" ] ; then
   1.694 +             echo "QA results in $RESULTDIR" >>$NEWFILENAME || Exit "Error: can't write to $NEWFILENAME"
   1.695 +        fi
   1.696 +        Debug "About to cat $FILENAME >>$NEWFILENAME "
   1.697 +        cat $FILENAME >>$NEWFILENAME || Exit "Error: can't append $FILENAME to $NEWFILENAME"
   1.698 +        TMPFILES="$TMPFILES $FILENAME"
   1.699 +        FILENAME=$NEWFILENAME
   1.700 +        Debug "Writing output to $FILENAME"
   1.701 +    fi
   1.702 +
   1.703 +}
   1.704 +
   1.705 +################################### write_to_tmpfile ##########################
   1.706 +# global shell function, for NT and cron operation, first a tmpfile 
   1.707 +# needs to be created
   1.708 +########################################################################
   1.709 +write_to_tmpfile()
   1.710 +{
   1.711 +    O_CRONFILE=ON
   1.712 +    O_FILE=ON
   1.713 +    FILENAME=${TMP}/nsstmp.$$    # for now write to the temporary file
   1.714 +                                 # since we don't know the hostname yet
   1.715 +                                 # will be inserted to the real file later
   1.716 +    TMPFILES="$TMPFILES nsstmp.$$"        
   1.717 +    touch $FILENAME || Exit "Error: can't touch $FILENAME"
   1.718 +    Debug "Writing output to $FILENAME"
   1.719 +}
   1.720 +
   1.721 +############################# turn_on_cronoptions ######################
   1.722 +# global shell function, turns on options needed for cron and tinderbox
   1.723 +########################################################################
   1.724 +turn_on_cronoptions()
   1.725 +{
   1.726 +    O_CRON=ON
   1.727 +    O_SILENT=ON
   1.728 +    O_DEBUG=ON                # FIXME take out!
   1.729 +    O_ALWAYS_YES=ON
   1.730 +    write_to_tmpfile
   1.731 +}
   1.732 +
   1.733 +########################## test_mozroot ##########################
   1.734 +# global shell function, determines if the variable LOCAL_MOZROOT is set, 
   1.735 +# and is usable as mozilla root diretory for a local QA
   1.736 +###################################################################
   1.737 +test_mozroot()
   1.738 +{
   1.739 +  PWD=`pwd`
   1.740 +  Debug "LOCAL_MOZROOT = $LOCAL_MOZROOT"
   1.741 +  case "$LOCAL_MOZROOT" in
   1.742 +      [0-9-]*|tip)
   1.743 +          glob_usage "Error: -"$1" requires a directoryname to follow (start with a letter) "
   1.744 +          ;;
   1.745 +      \.\.)
   1.746 +          LOCAL_MOZROOT=`dirname $PWD`
   1.747 +          ;;
   1.748 +      \.)
   1.749 +          LOCAL_MOZROOT=$PWD
   1.750 +          ;;
   1.751 +      \.\/*)
   1.752 +          LOCAL_MOZROOT=`echo $LOCAL_MOZROOT | sed -e "s/^\.//"`
   1.753 +          LOCAL_MOZROOT="${PWD}${LOCAL_MOZROOT}"
   1.754 +          ;;
   1.755 +      \.\.\/*)
   1.756 +          LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
   1.757 +          ;;
   1.758 +      \/*|[a-zA-Z]:\/*)
   1.759 +          ;;
   1.760 +      ?*)
   1.761 +          LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
   1.762 +          ;;
   1.763 +      *)
   1.764 +          glob_usage "Error: -"$1" requires a directoryname to follow"
   1.765 +          ;;
   1.766 +  esac
   1.767 +  Debug "Reformated MOZROOT to $LOCAL_MOZROOT"
   1.768 +  if [ "$1" = "ln" ] ; then
   1.769 +      LOCAL_MOZROOT_PARENT=`dirname $LOCAL_MOZROOT`
   1.770 +      if [ ! -d $LOCAL_MOZROOT_PARENT -o ! -w $LOCAL_MOZROOT_PARENT -o \
   1.771 +           ! -x $LOCAL_MOZROOT_PARENT ] ; then
   1.772 +              Exit "Error: Can't create $LOCAL_MOZROOT (permissions)"
   1.773 +      fi
   1.774 +      if [ ! -d "$LOCAL_MOZROOT" ] ; then
   1.775 +          mkdir $LOCAL_MOZROOT ||
   1.776 +              Exit "Error: Can't create mozroot $LOCAL_MOZROOT (mkdir failed)"
   1.777 +      else
   1.778 +          ask "mozroot $LOCAL_MOZROOT exists - continue (y will remove dir) ?" \
   1.779 +               "y" "n" || Exit
   1.780 +          rm -rf $LOCAL_MOZROOT/dist $LOCAL_MOZROOT/security $LOCAL_MOZROOT/tests_results ||
   1.781 +              Exit "Error: Can't clean mozroot $LOCAL_MOZROOT"
   1.782 +      fi
   1.783 +  fi
   1.784 +  if [ ! -d "$LOCAL_MOZROOT" ] ; then
   1.785 +      glob_usage "Error: mozilla root $LOCAL_MOZROOT not a valid directory"
   1.786 +  fi
   1.787 +}
   1.788 +
   1.789 +################################### eval_opts ##########################
   1.790 +# global shell function, evapuates options and parameters, sets flags
   1.791 +# variables and defaults
   1.792 +########################################################################
   1.793 +eval_opts()
   1.794 +{
   1.795 +  while [ -n "$1" ]
   1.796 +  do
   1.797 +    case $1 in
   1.798 +        -cron)
   1.799 +            turn_on_cronoptions
   1.800 +            ;;
   1.801 +        -T*|-t*)
   1.802 +            O_TBX=ON
   1.803 +            turn_on_cronoptions
   1.804 +            O_SILENT=OFF	#FIXME debug only
   1.805 +            ;;
   1.806 +        -S*|-s*)
   1.807 +            O_SILENT=ON
   1.808 +            ;;
   1.809 +        -Y*|-y)
   1.810 +            Debug "Option -y dedectet"
   1.811 +            O_ALWAYS_YES=ON
   1.812 +            ;;
   1.813 +        -d*|-D)
   1.814 +            O_DEBUG=ON
   1.815 +            #set -x
   1.816 +            ;;
   1.817 +        -ml|-ML)
   1.818 +            O_MAIL_LINK=ON
   1.819 +            shift
   1.820 +            MAILINGLIST=$1
   1.821 +            if [ -z "$MAILINGLIST" ]
   1.822 +            then
   1.823 +                glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
   1.824 +            fi
   1.825 +            Debug "Sending link to result to $MAILINGLIST"
   1.826 +            ;;
   1.827 +        -m|-M)
   1.828 +            O_MAIL=ON
   1.829 +            shift
   1.830 +            MAILINGLIST=$1
   1.831 +            if [ -z "$MAILINGLIST" ]
   1.832 +            then
   1.833 +                glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
   1.834 +            fi
   1.835 +            Debug "Sending result to $MAILINGLIST"
   1.836 +            ;;
   1.837 +        -fcron*|-F[Cc][Rr][Oo][Nn]*)
   1.838 +            write_to_tmpfile
   1.839 +            ;;
   1.840 +        -f|-F)
   1.841 +            O_FILE=ON
   1.842 +            shift
   1.843 +            FILENAME=$1
   1.844 +            if [ -z "$FILENAME" ]
   1.845 +            then
   1.846 +                glob_usage "Error: -f requires a filename to follow"
   1.847 +            fi
   1.848 +            #rm -f $FILENAME 2>/dev/null
   1.849 +            touch $FILENAME || Exit "Error: can't touch $FILENAME"
   1.850 +                                    #NOTE we append rather that creating
   1.851 +            Debug "Writing output to $FILENAME"
   1.852 +            ;;
   1.853 +        -h|-help|"-?")
   1.854 +            glob_usage
   1.855 +            ;;
   1.856 +        -ln)
   1.857 +            if [ `basename $0` != nssqa ] ; then
   1.858 +                glob_usage "Error: Can't handle option $1"
   1.859 +            fi
   1.860 +            O_LOCAL=ON
   1.861 +            O_LN=ON
   1.862 +            shift
   1.863 +            LOCAL_MOZROOT=$1
   1.864 +            test_mozroot ln
   1.865 +            ;;
   1.866 +        -lt)
   1.867 +            if [ `basename $0` != nssqa ] ; then
   1.868 +                glob_usage "Error: Can't handle option $1"
   1.869 +            fi
   1.870 +            O_LN=ON
   1.871 +            O_LOCAL=ON
   1.872 +            ;;
   1.873 +        -l)
   1.874 +            if [ `basename $0` != nssqa ] ; then
   1.875 +                glob_usage "Error: Can't handle option $1"
   1.876 +            fi
   1.877 +            O_LOCAL=ON
   1.878 +            shift
   1.879 +            LOCAL_MOZROOT=$1
   1.880 +            test_mozroot l
   1.881 +            ;;
   1.882 +        -p)
   1.883 +            shift
   1.884 +            PORT=$1
   1.885 +            export PORT
   1.886 +            ;;
   1.887 +        -*)
   1.888 +            glob_usage "Error: Can't handle option $1"
   1.889 +            ;;
   1.890 +        tip|3.|3..)
   1.891 +            NSSVER=$1
   1.892 +            if [ -z "$NSSVER" ] ; then
   1.893 +                glob_usage "Error: illegal parameter"
   1.894 +            fi
   1.895 +            ;;
   1.896 +        [01][0-9][0123][0-9])
   1.897 +            BUILDDATE=$1
   1.898 +            if [ -z "$BUILDDATE" ] ; then
   1.899 +                glob_usage "Error: illegal parameter"
   1.900 +            fi
   1.901 +            ;;
   1.902 +        ?*)
   1.903 +            glob_usage "Error: Can't handle parameter $1"
   1.904 +            ;;
   1.905 +    esac
   1.906 +    shift
   1.907 +  done
   1.908 +
   1.909 +  if [ -z "$PORT" -a "$O_TBX" = "ON" ] ; then
   1.910 +      PORT=8444
   1.911 +      export PORT
   1.912 +      if [ -z "$NSSVER" ] ; then
   1.913 +          NSSVER="tip"
   1.914 +          Debug "NSS Version: Parameters missing - defaulting to tip!"
   1.915 +      fi
   1.916 +  elif [ -z "$NSSVER" ] ; then
   1.917 +      NSSVER="tip"
   1.918 +      Debug "NSS Version: Parameters missing - defaulting to tip!"
   1.919 +  fi
   1.920 +  if [ -z "$BUILDDATE" ] ; then
   1.921 +      BUILDDATE=`date +%m%d`
   1.922 +      Debug "Builddate: Parameters missing - defaulting to today!"
   1.923 +  fi
   1.924 +  
   1.925 +  Debug "Builddate $BUILDDATE NssVersion $NSSVER"
   1.926 +  export BUILDDATE NSSVER
   1.927 +  export O_CRON O_SILENT O_DEBUG O_ALWAYS_YES O_TBX
   1.928 +}
   1.929 +
   1.930 +win_set_tmp()
   1.931 +{
   1.932 +    TMP=`echo "$TMP" | sed -e 's/	/\/t/g' -e 's//\/b/' -e 's/\\\/\//g'`
   1.933 +    Debug "TMP reformated to $TMP"
   1.934 +}
   1.935 +
   1.936 +######################### win_set_d1 ################################
   1.937 +# global shell function, interactively finds the directories in case
   1.938 +# windows can't get to the default
   1.939 +########################################################################
   1.940 +win_set_d1()
   1.941 +{
   1.942 +    Debug "set Windows Directories..."
   1.943 +    #win_set_tmp
   1.944 +    if [ "$O_CYGNUS" = ON ]
   1.945 +    then
   1.946 +        NSS_VER_DIR=/cygdrive/w/nss/nss$NSSVER
   1.947 +    else
   1.948 +        NSS_VER_DIR=w:/nss/nss$NSSVER
   1.949 +    fi
   1.950 +    if [ ! -w $NSS_VER_DIR ]
   1.951 +    then
   1.952 +        Echo "Windows special... can't write in $NSS_VER_DIR"
   1.953 +        if [ "$O_CYGNUS" = ON ]
   1.954 +        then
   1.955 +            NSS_VER_DIR=/cygdrive/u/nss/nss$NSSVER
   1.956 +        else
   1.957 +            NSS_VER_DIR="u:/nss/nss$NSSVER"
   1.958 +        fi
   1.959 +    else
   1.960 +        Debug "NSS_VER_DIR set to $NSS_VER_DIR"
   1.961 +        return
   1.962 +    fi
   1.963 +
   1.964 +    while [ ! -w $NSS_VER_DIR ]
   1.965 +    do
   1.966 +        if [ "$O_CRONFILE" = "ON" ] 
   1.967 +        then
   1.968 +            Exit "cant write in $NSS_VER_DIR" 
   1.969 +        fi
   1.970 +        Warning "cant write in $NSS_VER_DIR" 
   1.971 +        Echo "input start directory (u:/nss, d:/src/nss, f:/shared/nss) "
   1.972 +        read D
   1.973 +        if [ -n "$D" ]
   1.974 +        then
   1.975 +            NSS_VER_DIR=$D/nss$NSSVER
   1.976 +        fi
   1.977 +    done
   1.978 +    Debug "NSS_VER_DIR set to $NSS_VER_DIR"
   1.979 +}
   1.980 +
   1.981 +########################### init_host ##################################
   1.982 +# global shell function, sets required variables HOST and DOMSUF, and asks
   1.983 +# the user if it has been set right
   1.984 +########################################################################
   1.985 +set_host()
   1.986 +{
   1.987 +    init_host
   1.988 +}
   1.989 +init_host()
   1.990 +{
   1.991 +    if [ `basename $0` != nssqa ] ; then
   1.992 +        return
   1.993 +    fi
   1.994 +
   1.995 +    init_host_done=0
   1.996 +
   1.997 +    if [ $DS_WAS_SET = FALSE ] #give chance to overwrite, espec. for NT
   1.998 +    then
   1.999 +        Debug "Domainname was not set..."
  1.1000 +        DOMSUF=`domainname 2>/dev/null`
  1.1001 +        if [ -z "$DOMSUF" ]
  1.1002 +        then
  1.1003 +            Debug "domainname command did not work ..."
  1.1004 +            DOMSUF=`echo $HOST | grep '\.' | sed -e "s/[^\.]*\.//"`
  1.1005 +    
  1.1006 +            if [ -z "$DOMSUF" ]
  1.1007 +            then
  1.1008 +                Debug "Domainname not part of the hostname"
  1.1009 +                DOMSUF=`cat /etc/defaultdomain 2>/dev/null`
  1.1010 +                if [ -z "$DOMSUF" ]
  1.1011 +                then
  1.1012 +                    Debug "Domainname needs to be hardcoded to red.iplanet.com"
  1.1013 +                    DOMSUF="red.iplanet.com"
  1.1014 +                fi
  1.1015 +            fi
  1.1016 +        fi
  1.1017 +    fi
  1.1018 +    case $HOST in
  1.1019 +        *\.*)
  1.1020 +            Debug "HOSTNAME $HOST contains Dot"
  1.1021 +            HOST=`echo $HOST | sed -e "s/\..*//"`
  1.1022 +            ;;
  1.1023 +    esac
  1.1024 +    if [ -z "$HOST" ]
  1.1025 +    then
  1.1026 +        HOST=`uname -n`
  1.1027 +        case $HOST in
  1.1028 +            *\.*)
  1.1029 +                Debug "HOSTNAME $HOST contains Dot"
  1.1030 +                HOST=`echo $HOST | sed -e "s/\..*//"`
  1.1031 +                ;;
  1.1032 +        esac
  1.1033 +    fi
  1.1034 +    if [ $O_DEBUG = "ON" ]
  1.1035 +    then
  1.1036 +        while [ $init_host_done -eq 0 ]
  1.1037 +        do
  1.1038 +            Echo
  1.1039 +            ask "DOMSUF=$DOMSUF, HOST=$HOST - OK", "y" "n" &&
  1.1040 +                init_host_done=1
  1.1041 +            if [ $init_host_done -eq 0 ]
  1.1042 +            then
  1.1043 +                Echo "input DOMSUF: "
  1.1044 +                read D
  1.1045 +                if [ -n "$D" ]
  1.1046 +                then
  1.1047 +                    DOMSUF=$D
  1.1048 +                fi
  1.1049 +                Echo "input HOST: "
  1.1050 +                read H
  1.1051 +                if [ -n "$H" ]
  1.1052 +                then
  1.1053 +                    HOST=$H
  1.1054 +                fi
  1.1055 +            fi
  1.1056 +        done
  1.1057 +    fi
  1.1058 +    export HOST DOMSUF
  1.1059 +    Debug "HOST: $HOST, DOMSUF: $DOMSUF"
  1.1060 +}
  1.1061 +
  1.1062 +#-----------------------------# UTILS #----------------------------------
  1.1063 +
  1.1064 +########################### qa_stat_get_sysinfo ########################
  1.1065 +# local shell function, tries to determine the QA operating system
  1.1066 +########################################################################
  1.1067 +qa_stat_get_sysinfo()
  1.1068 +{
  1.1069 +    case $1 in
  1.1070 +        ?*) REM_SYS=$1
  1.1071 +            GET_SYSINFO="rsh $1"
  1.1072 +            ;;
  1.1073 +        *)  REM_SYS=""
  1.1074 +            GET_SYSINFO=""
  1.1075 +            ;;
  1.1076 +    esac
  1.1077 +    QA_SYS=`$GET_SYSINFO uname -sr`
  1.1078 +    echo $QA_SYS | grep Linux >/dev/null &&
  1.1079 +              QA_RHVER=`$GET_SYSINFO cat /etc/redhat-release`
  1.1080 +    if [ -n "$QA_RHVER" ]
  1.1081 +    then
  1.1082 +        QA_OS=`echo $REM_SYS $QA_RHVER | sed -e "s/Red Hat /RH /" \
  1.1083 +                    -e "s/ release//"`
  1.1084 +    else
  1.1085 +        case $QA_SYS in
  1.1086 +            *SunOS*5.[89]*)
  1.1087 +                ISAINFO=`$GET_SYSINFO isainfo -v`
  1.1088 +                IS_64=`echo $ISAINFO | grep 64 >/dev/null && \
  1.1089 +                    echo 64 bit`
  1.1090 +                IS_I386=`echo $ISAINFO | grep i386 >/dev/null && \
  1.1091 +                    echo i86pc`
  1.1092 +                if [ -n "$IS_I386" ] ; then IS_64="$IS_I386"; fi;
  1.1093 +                if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
  1.1094 +                ;;
  1.1095 +            *HP*)
  1.1096 +                IS_64=`$GET_SYSINFO getconf KERNEL_BITS |
  1.1097 +                    grep 64 >/dev/null && echo 64 bit`
  1.1098 +                if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
  1.1099 +                ;;
  1.1100 +            *AIX*)
  1.1101 +                IS_64=`$GET_SYSINFO lslpp -l |
  1.1102 +                    grep "bos.64bit"> /dev/null && echo 64 bit`
  1.1103 +                if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
  1.1104 +                ;;
  1.1105 +        esac
  1.1106 +        QA_OS=`echo "$REM_SYS $QA_SYS $IS_64"`
  1.1107 +    fi
  1.1108 +    if [ "$O_SILENT" != ON ] ; then
  1.1109 +        echo $QA_OS
  1.1110 +    fi
  1.1111 +    QA_OS_STRING=`echo $QA_OS | sed -e "s/^[_ ]//" -e "s/ /_/g"`
  1.1112 +}
  1.1113 +
  1.1114 +################################### set_objdir #########################
  1.1115 +# global shell function, sets the object directories and DIST
  1.1116 +########################################################################
  1.1117 +set_objdir()
  1.1118 +{
  1.1119 +    Debug "set object dir"
  1.1120 +    OBJDIR=`cd ${TESTSCRIPTDIR}/common; gmake objdir_name`
  1.1121 +    OS_ARCH=`cd ${TESTSCRIPTDIR}/common; gmake os_arch`
  1.1122 +    
  1.1123 +    #at this point $MASTERBUILD needs to be either NT or unix
  1.1124 +
  1.1125 +    set_daily_build_dirs
  1.1126 +    LOCALDIST_BIN=${LOCALDIST}/${OBJDIR}/bin
  1.1127 +    DIST=$LOCALDIST
  1.1128 +
  1.1129 +    if [ -z "${TEST_LEVEL}" ] ; then 
  1.1130 +        TEST_LEVEL=0
  1.1131 +    fi
  1.1132 +    bc ${TEST_LEVEL}   #set the path for the backward compatibility test
  1.1133 +
  1.1134 +    PATH_CONTAINS_BIN="TRUE"
  1.1135 +    export PATH_CONTAINS_BIN
  1.1136 +
  1.1137 +    export OBJDIR OS_ARCH LOCALDIST LOCALDIST_BIN DIST PATH 
  1.1138 +}
  1.1139 +
  1.1140 +########################### bc #########################################
  1.1141 +# global shell function , sets paths for the backward compatibility test
  1.1142 +########################################################################
  1.1143 +bc()
  1.1144 +{
  1.1145 +  if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
  1.1146 +      TESTDIR=${RESULTDIR}
  1.1147 +      BC_ACTION=""
  1.1148 +      DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary
  1.1149 +      return
  1.1150 +  fi
  1.1151 +  DON_T_SET_PATHS="TRUE"
  1.1152 +  case $1 in
  1.1153 +    0)
  1.1154 +      #unset TESTDIR
  1.1155 +      TESTDIR=${RESULTDIR}
  1.1156 +      if [ "$O_WIN" = "ON" -a "$O_CYGNUS" != ON ] ; then
  1.1157 +          PATH="$TESTSCRIPTDIR;$LOCALDIST_BIN;$BASEPATH"
  1.1158 +      else
  1.1159 +          PATH=$TESTSCRIPTDIR:$LOCALDIST_BIN:$BASEPATH
  1.1160 +      fi
  1.1161 +      BC_ACTION=""
  1.1162 +      DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary
  1.1163 +      ;;
  1.1164 +    *)
  1.1165 +      if [ "$O_LOCAL" = "ON" ] ; then
  1.1166 +          Exit "FIXME Can't run backwardcompatibility tests locally yet"
  1.1167 +      fi
  1.1168 +      TESTSCRIPTDIR=${BCDIST}/../security/nss/tests
  1.1169 +      COMMON=${TESTSCRIPTDIR}/common
  1.1170 +      TESTDIR=${RESULTDIR}/bct
  1.1171 +      BC_ACTION="backward compatibility of binaries in $BC_MASTER to new libs"
  1.1172 +      BCDIST_BIN=${BCDIST}/${OBJDIR}/bin
  1.1173 +      LD_LIBRARY_PATH=${LOCALDIST}/${OBJDIR}/lib
  1.1174 +      if [ "$O_WIN" = "ON" ] ; then
  1.1175 +          if [ "$O_CYGNUS" = ON ] ; then
  1.1176 +              PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH:$LD_LIBRARY_PATH
  1.1177 +          else
  1.1178 +              PATH="$TESTSCRIPTDIR;$BCDIST_BIN;$BASEPATH;$LD_LIBRARY_PATH"
  1.1179 +          fi
  1.1180 +      else
  1.1181 +          PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH
  1.1182 +      fi
  1.1183 +      Debug "1st stage of backward compatibility test"
  1.1184 +      ;;
  1.1185 +  esac
  1.1186 +  if [ -n "$TESTDIR" ] ; then
  1.1187 +      if [ ! -d $TESTDIR ] ; then
  1.1188 +          mkdir -p $TESTDIR
  1.1189 +      fi
  1.1190 +      export TESTDIR
  1.1191 +  fi
  1.1192 +  SHLIB_PATH=${LD_LIBRARY_PATH}
  1.1193 +  LIBPATH=${LD_LIBRARY_PATH}
  1.1194 +  Debug "PATH $PATH"
  1.1195 +  Debug "LD_LIBRARY_PATH $LD_LIBRARY_PATH"
  1.1196 +  export PATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH
  1.1197 +  export DON_T_SET_PATHS BC_ACTION
  1.1198 +  export TESTSCRIPTDIR COMMON
  1.1199 +}
  1.1200 +
  1.1201 +########################### Ps #########################################
  1.1202 +# global shell function , attempts a platform specific ps
  1.1203 +########################################################################
  1.1204 +Ps()
  1.1205 +{
  1.1206 +#AIX, OSF ps -ef, solaris /usr/5bin/ps -ef, win ps -ef but no user id
  1.1207 +#linux ps -ef, HP
  1.1208 +
  1.1209 +    if [ $os_name = "SunOS" ]
  1.1210 +    then
  1.1211 +        /usr/5bin/ps -ef
  1.1212 +    else
  1.1213 +        ps -ef
  1.1214 +    fi
  1.1215 +}
  1.1216 +
  1.1217 +########################### kill_by_name ################################
  1.1218 +# global shell function , kills the process whose name is given as 
  1.1219 +# parameter 
  1.1220 +########################################################################
  1.1221 +kill_by_name()
  1.1222 +{
  1.1223 +    for PID in `Ps | grep "$1" | grep -v grep | \
  1.1224 +        sed -e "s/^ *//g" -e "s/^[^ ]* //" -e "s/^ *//g" -e "s/ .*//g"`
  1.1225 +    do
  1.1226 +        if [ $O_WIN = "ON" -a $O_CYGNUS = "ON" ]
  1.1227 +        then
  1.1228 +            ask "Do you want to kill Process $PID (`Ps | grep $PID | \
  1.1229 +                grep -v grep | awk '{ print $1, $2, $6, $7, $8, $9 }' | \
  1.1230 +                sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \
  1.1231 +                "y" "n" && {
  1.1232 +                kill $PID
  1.1233 +                sleep 1
  1.1234 +                kill -9 $PID 2>/dev/null
  1.1235 +            }
  1.1236 +        else
  1.1237 +            ask "Do you want to kill Process $PID (`Ps | grep $PID | \
  1.1238 +                grep -v grep | awk '{ print $1, $2, $8, $9, $10, $11 }' | \
  1.1239 +                sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \
  1.1240 +                "y" "n" && {
  1.1241 +                kill $PID
  1.1242 +                sleep 1
  1.1243 +                kill -9 $PID 2>/dev/null
  1.1244 +            }
  1.1245 +        fi
  1.1246 +    done
  1.1247 +}
  1.1248 +
  1.1249 +############################### early_exit ###################################
  1.1250 +# global shell function , attempts a little more usefull user notification
  1.1251 +# of a complete failure
  1.1252 +########################################################################
  1.1253 +
  1.1254 +early_exit()
  1.1255 +{
  1.1256 +    if [ -z "$DOCDIR" ]
  1.1257 +    then
  1.1258 +        DOCDIR=`dirname $0`/../doc
  1.1259 +    fi
  1.1260 +    if [ -f $DOCDIR/QAerror.html ]
  1.1261 +    then
  1.1262 +        Debug "Found QA errorheader"
  1.1263 +        rm ${FILENAME}.err 2>/dev/null
  1.1264 +        cp $DOCDIR/QAerror.html ${FILENAME}.err
  1.1265 +        echo "$1" >>${FILENAME}.err
  1.1266 +        echo '</font></b></h1>' >>${FILENAME}.err
  1.1267 +        if [ -n "$FILENAME" -a -f "$FILENAME" ]
  1.1268 +        then
  1.1269 +            cat $FILENAME | sed -e "s/^/<br>/" >>${FILENAME}.err
  1.1270 +        fi
  1.1271 +        echo '</body></html>' >>${FILENAME}.err
  1.1272 +        cat ${FILENAME}.err | $RMAIL $MAILINGLIST
  1.1273 +        
  1.1274 +        rm ${FILENAME}.err 2>/dev/null
  1.1275 +        #echo "cat ${FILENAME}.err | $RMAIL $MAILINGLIST "
  1.1276 +    fi
  1.1277 +}
  1.1278 +
  1.1279 +############################### Exit ###################################
  1.1280 +# global shell function , central exiting point
  1.1281 +# cleanup: temporary files, kill the remaining selfservers if sourcing
  1.1282 +# script sets KILL_SELFSERV 
  1.1283 +########################################################################
  1.1284 +Exit()
  1.1285 +{
  1.1286 +    Echo $1    
  1.1287 +    if [ "$O_CRON" = "OFF" ] 
  1.1288 +    then
  1.1289 +        echo $1 >&2
  1.1290 +    fi
  1.1291 +    if [ -f "${KILLPIDS}" ]
  1.1292 +    then
  1.1293 +        Debug "Attempting to kill background processes...`cat ${KILLPIDS}`"
  1.1294 +        kill `cat "${KILLPIDS}"` 
  1.1295 +        sleep 1
  1.1296 +        kill -9  `cat "${KILLPIDS}"`
  1.1297 +    fi
  1.1298 +    if [ -n "${TMPFILES}" ]
  1.1299 +    then
  1.1300 +        Debug "rm -f ${TMPFILES}"
  1.1301 +        rm -f $TMPFILES 2>/dev/null
  1.1302 +    fi
  1.1303 +    O_ALWAYS_YES=ON # set to non-interactive - don't ask anymore questions here
  1.1304 +    if [ $KILL_SELFSERV = "ON" ]
  1.1305 +    then
  1.1306 +        kill_by_name selfserv
  1.1307 +    fi
  1.1308 +    if [ $O_MAIL_LINK = "ON" -a $O_FILE = "ON" ]
  1.1309 +    then
  1.1310 +        if [ $EARLY_EXIT = TRUE ]    #before the report file has been created
  1.1311 +        then
  1.1312 +            early_exit "$1"
  1.1313 +        else
  1.1314 +            head -3  $FILENAME >$ML_FILE
  1.1315 +            echo "Content-Type: text/plain; charset=us-ascii; format=flowed
  1.1316 +    Content-Transfer-Encoding: 7bit
  1.1317 +
  1.1318 +" >>$ML_FILE
  1.1319 +            echo $HREF_TMP_HTML_FILE >>$ML_FILE
  1.1320 +            cat $ML_FILE | $RMAIL $MAILINGLIST
  1.1321 +        fi
  1.1322 +
  1.1323 +#FIXME - early exit etc
  1.1324 +    elif [ $O_MAIL = "ON" -a $O_FILE = "ON" ]
  1.1325 +    then
  1.1326 +        if [ $EARLY_EXIT = TRUE ]    #before the report file has been created
  1.1327 +        then
  1.1328 +            early_exit "$1"
  1.1329 +        elif [ -n "$FILENAME" -a -f "$FILENAME" ]
  1.1330 +        then
  1.1331 +            cat $FILENAME | $RMAIL $MAILINGLIST
  1.1332 +        fi
  1.1333 +        #rm $FILENAME 2>/dev/null
  1.1334 +    elif  [ $O_MAIL = "ON" -a $EARLY_EXIT = TRUE ]
  1.1335 +    then
  1.1336 +        early_exit "$1"
  1.1337 +        rm $FILENAME 2>/dev/null
  1.1338 +    fi
  1.1339 +    #chmod a+rw ${RESULTDIR} ${RESULTDIR}/* ${RESULTDIR}/*/* &
  1.1340 +    if [ -n "$O_TBX" -a "$O_TBX" = "ON" ] ; then
  1.1341 +        rm ${TESTDIR}/QAstatus
  1.1342 +
  1.1343 +        if [ "$1" = "killed... cleaning up..." ] ; then
  1.1344 +            echo "QA killed" >${TESTDIR}/QAstatus
  1.1345 +        elif [ "$TBX_EXIT" = 0 ] ; then
  1.1346 +            echo "QA passed" >${TESTDIR}/QAstatus
  1.1347 +        else
  1.1348 +            echo "QA failed" >${TESTDIR}/QAstatus
  1.1349 +        fi
  1.1350 +
  1.1351 +        exit $TBX_EXIT
  1.1352 +         
  1.1353 +    else
  1.1354 +        exit
  1.1355 +    fi
  1.1356 +}
  1.1357 +
  1.1358 +trap "rm -f ${TMPFILES} 2>/dev/null; Exit 'killed... cleaning up...'" 2 3 15
  1.1359 +
  1.1360 +################################ Wait ##################################
  1.1361 +# global shell function to wait for an event to happen, 1st parameter
  1.1362 +# filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait
  1.1363 +# for it to be created.
  1.1364 +# uses the variables WAIT_FOR and WAIT_TIMES
  1.1365 +# WAIT_FOR: if waiting for an event sleep n seconds before rechecking 
  1.1366 +#     recomended value 10 minutes 600
  1.1367 +# WAIT_TIMES: recheck n times before giving up to prevent endless loop
  1.1368 +#     recomended 30 - total of 5h
  1.1369 +########################################################################
  1.1370 +
  1.1371 +Wait()
  1.1372 +{
  1.1373 +    i=0
  1.1374 +    Debug "Waiting for $1"
  1.1375 +    while [ $i -lt $WAIT_TIMES ]
  1.1376 +    do
  1.1377 +        i=`expr $i + 1`
  1.1378 +        if [ -f "$1" -a $2 -eq 1 ]   # if file exists and is supposed to 
  1.1379 +        then
  1.1380 +            return
  1.1381 +        fi
  1.1382 +        if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist
  1.1383 +        then
  1.1384 +            return
  1.1385 +        fi
  1.1386 +        Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds zzzz..."
  1.1387 +        sleep $WAIT_FOR
  1.1388 +    done
  1.1389 +    TOTAL=`expr $WAIT_TIMES \* $WAIT_FOR / 60`
  1.1390 +    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... "
  1.1391 +}
  1.1392 +
  1.1393 +################################ WaitForever ##################################
  1.1394 +# global shell function to wait for an event to happen, 1st parameter
  1.1395 +# filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait
  1.1396 +# for it to be created.
  1.1397 +# because we daon't have any relyable cron on NT...
  1.1398 +########################################################################
  1.1399 +
  1.1400 +WaitForever()
  1.1401 +{
  1.1402 +    i=0
  1.1403 +    Debug "Waiting for $1"
  1.1404 +    TOTAL=0
  1.1405 +    while [ 1 ]
  1.1406 +    do
  1.1407 +        i=`expr $i + 1`
  1.1408 +        if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to 
  1.1409 +        then
  1.1410 +            return
  1.1411 +        fi
  1.1412 +        if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist
  1.1413 +        then
  1.1414 +            return
  1.1415 +        fi
  1.1416 +        Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds Total $TOTAL"
  1.1417 +        sleep $WAIT_FOR
  1.1418 +        TOTAL=`expr $i \* $WAIT_FOR / 60`
  1.1419 +        if [ -n "$MAX_FOREVER" ] # we are cheating. Forever can be very short...
  1.1420 +        then
  1.1421 +            if [ "$TOTAL" -gt "$MAX_FOREVER" ] 
  1.1422 +            then
  1.1423 +                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... "
  1.1424 +            fi
  1.1425 +        fi
  1.1426 +    done
  1.1427 +}
  1.1428 +################################### is_running #########################
  1.1429 +# global shell function , implements primitive locking mechanism
  1.1430 +# filename is passed as a parameter, if filename.* exists we assume calling
  1.1431 +# script is running already and exit, otherwise filename.processid is 
  1.1432 +# created 
  1.1433 +########################################################################
  1.1434 +is_running()
  1.1435 +{
  1.1436 +    Debug "Testing if $0 is already running... file ${1} - ${1}.$$"
  1.1437 +    if [ -f ${1}.* ]
  1.1438 +    then
  1.1439 +        Exit "$0 seems to be running already ($1 exists) - Exiting"
  1.1440 +    fi
  1.1441 +    TMPFILES="$TMPFILES ${1}.$$"
  1.1442 +    echo "running $0 on `date` PID $$" >${1}.$$
  1.1443 +    Debug "wrote \"running $0 on `date` PID $$\" to ${1}.$$"
  1.1444 +    
  1.1445 +}
  1.1446 +
  1.1447 +#---------------------------# USERCOM #---------------------------------
  1.1448 +############################## Echo #####################################
  1.1449 +# global shell function , depending on the options the output gets written 
  1.1450 +# to a file, or is being discarded
  1.1451 +# FIXME  \n and \c are mistreates by differnet shells, and linux has /bin/echo
  1.1452 +# instead of /usr/bin/echo
  1.1453 +########################################################################
  1.1454 +Echo ()
  1.1455 +{
  1.1456 +    if [ $O_SILENT = OFF ]
  1.1457 +    then
  1.1458 +        echo "$*"
  1.1459 +        #/usr/bin/echo "$*"
  1.1460 +    fi
  1.1461 +    if [ $O_FILE = ON ]
  1.1462 +    then
  1.1463 +        echo "$*" >>$FILENAME
  1.1464 +    fi
  1.1465 +}
  1.1466 +
  1.1467 +################################### ask ################################
  1.1468 +# global shell function, Asks the a question, and gives the returns 0
  1.1469 +# on the 1st choice, 1 on the 2nd choice
  1.1470 +#
  1.1471 +# PARAMETERS:
  1.1472 +#    $1 question text
  1.1473 +#    $2 1st choice
  1.1474 +#    $3 2nd choice
  1.1475 +#
  1.1476 +# MODIFIERS:
  1.1477 +#    -y O_ALWAYS_YES will assume a first choice always (not neccessaryly "y")
  1.1478 +#
  1.1479 +# RETURN:
  1.1480 +#    0 - User picked 1st choice
  1.1481 +#    1 - User picked 2nd choice
  1.1482 +#
  1.1483 +# EXAMPLE
  1.1484 +#    ask "Would you like to continue" "y" "n" || Exit
  1.1485 +#        will produce the string "Would you like to continue (y/n) ?",
  1.1486 +#        read input from keyboard (or assume a yes with option -y)
  1.1487 +#        - on a yes it will return 0, on a no it will return 1, the 
  1.1488 +#        shell interprets it as error and the || Exit will be executed
  1.1489 +#
  1.1490 +# NOTE: NEVER use "n" as the second parameter - it will mess up -y
  1.1491 +#    don't ask "Continue" "n" "y" || Exit # it will Exit on a "y"
  1.1492 +#
  1.1493 +########################################################################
  1.1494 +Ask()
  1.1495 +{
  1.1496 +    ask $*
  1.1497 +}
  1.1498 +
  1.1499 +ask()
  1.1500 +{
  1.1501 +    if [ $O_ALWAYS_YES = ON ]
  1.1502 +    then
  1.1503 +        Echo "$1 ($2/$3) ?"
  1.1504 +        Echo "YES!"
  1.1505 +        return 0
  1.1506 +    fi
  1.1507 +    A=""
  1.1508 +    while [ 1 ]
  1.1509 +    do
  1.1510 +    
  1.1511 +        Echo "$1 ($2/$3) ?"
  1.1512 +        read A
  1.1513 +        if [ -n "$A" ]
  1.1514 +        then
  1.1515 +            if [ $A = $2 ]
  1.1516 +            then
  1.1517 +                return 0
  1.1518 +            elif [ $A = $3 ]
  1.1519 +            then
  1.1520 +                return 1
  1.1521 +            fi
  1.1522 +        fi
  1.1523 +    done
  1.1524 +    return 0
  1.1525 +}
  1.1526 +
  1.1527 +################################### Warning ############################
  1.1528 +# global shell function, Asks the user a "... continue? (y/n)" question, 
  1.1529 +# and exits when the user answers with no
  1.1530 +# NOTE -y will answer the warnings always with yes
  1.1531 +########################################################################
  1.1532 +Warning ()
  1.1533 +{
  1.1534 +    ask "WARNING: $0: \n $* continue " "y" "n" || Exit 
  1.1535 +}
  1.1536 +
  1.1537 +################################### Debug ############################
  1.1538 +# global shell function, when option -d Debugging output is written
  1.1539 +########################################################################
  1.1540 +Debug()
  1.1541 +{
  1.1542 +    if [ $O_DEBUG = ON ]
  1.1543 +    then
  1.1544 +        Echo "DEBUG: (`date +%H:%M`) $0: $*"
  1.1545 +    fi
  1.1546 +}
  1.1547 +
  1.1548 +################################### line ###############################
  1.1549 +# global shell function, supposed to make output more readable...
  1.1550 +########################################################################
  1.1551 +line()
  1.1552 +{
  1.1553 +Echo
  1.1554 +#Echo "======================================================================="
  1.1555 +#Echo
  1.1556 +}
  1.1557 +
  1.1558 +################################### opt_usage ##########################
  1.1559 +# global shell function, tells user about available options
  1.1560 +########################################################################
  1.1561 +opt_usage()
  1.1562 +{
  1.1563 +  if [ $O_OPTIONS = "ON" ]
  1.1564 +  then
  1.1565 +    Echo
  1.1566 +    line
  1.1567 +    Echo
  1.1568 +    Echo "    -y answer all questions with y - use at your own risk..."
  1.1569 +    Echo "    -s silent (only usefull with -y)"
  1.1570 +    Echo "    -h, -? - you guessed right - displays this text"
  1.1571 +    Echo "    -d debug"
  1.1572 +    Echo "    -f <filename> - write the (error)output to filename"
  1.1573 +    Echo "    -fcronfile produces the resultfiles in the same locations"
  1.1574 +    Echo "        as would have been produced with -cron"
  1.1575 +    Echo "    -m <mailinglist> - send filename to mailinglist (csl "
  1.1576 +    Echo "         example sonmi,nelsonb,wtc) only useful with -f"
  1.1577 +    Echo "    -ml <mailinglist> - send link to filename to mailinglist "
  1.1578 +    Echo "         (csl example sonmi,nelsonb,wtc) only useful with -f"
  1.1579 +    Echo "    -cron equivalient to -y -s -d -f \$RESULTDIR/\$HOST.nssqa"
  1.1580 +    Echo "    -t run on a tinderbox build (included -cron)"
  1.1581 +    if [ `basename $0` = nssqa ] ; then
  1.1582 +        Echo "    -l <mozroot> run on a local build"
  1.1583 +        Echo "    -ln <mozroot> copy a networkbuild to a local directory "
  1.1584 +        Echo "        mozroot,  used for networkindipendend QA "
  1.1585 +        Echo "    -lt try to copy a networkbuild to a local directory, if"
  1.1586 +        Echo "        not possible run on the network
  1.1587 +        Echo "        used for networkindipendend QA
  1.1588 +    fi
  1.1589 +#
  1.1590 +# special strings
  1.1591 +  fi
  1.1592 +    
  1.1593 +}
  1.1594 +
  1.1595 +################################### glob_usage #########################
  1.1596 +# global shell function, how to use the calling script (parameters, options)
  1.1597 +########################################################################
  1.1598 +glob_usage()
  1.1599 +{
  1.1600 +    line
  1.1601 +    Echo $1
  1.1602 +    Echo
  1.1603 +    if [ $O_OPTIONS = "ON" ]
  1.1604 +    then
  1.1605 +        Echo "usage $0 [options] nssversion builddate"
  1.1606 +    else
  1.1607 +        Echo "usage $0 nssversion builddate"
  1.1608 +    fi
  1.1609 +        
  1.1610 +    Echo " for example: $0 30b 0926"
  1.1611 +    Echo "     $0 31 1002"
  1.1612 +    opt_usage
  1.1613 +    Echo
  1.1614 +    Exit "$1"
  1.1615 +}
  1.1616 +
  1.1617 +tell()
  1.1618 +{
  1.1619 +    if [ $O_SILENT = OFF ]
  1.1620 +    then
  1.1621 +        line
  1.1622 +        pwd
  1.1623 +        ls -CF
  1.1624 +        line
  1.1625 +    fi
  1.1626 +    if [ $O_FILE = ON ]
  1.1627 +    then
  1.1628 +        line
  1.1629 +        pwd >>$FILENAME
  1.1630 +        ls -CF >>$FILENAME
  1.1631 +        line 
  1.1632 +    fi
  1.1633 +}
  1.1634 +
  1.1635 +if [ $O_INIT = "ON" ]
  1.1636 +then
  1.1637 +    glob_init $*
  1.1638 +fi
  1.1639 +EARLY_EXIT=FALSE

mercurial