security/nss/tests/header

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #! /bin/sh
michael@0 2
michael@0 3 ########################################################################
michael@0 4 #
michael@0 5 # /u/sonmi/bin/header - /u/svbld/bin/init/nss/header
michael@0 6 #
michael@0 7 # variables, utilities and shellfunctions global to NSS QA
michael@0 8 # needs to work on all Unix platforms
michael@0 9 #
michael@0 10 # included from (don't expect this to be up to date)
michael@0 11 # --------------------------------------------------
michael@0 12 # qa_stat
michael@0 13 # mksymlinks
michael@0 14 # nssqa
michael@0 15 #
michael@0 16 # parameters
michael@0 17 # ----------
michael@0 18 # nssversion (supported: 30b, 31, 332, tip 32)
michael@0 19 # builddate (default - today)
michael@0 20 #
michael@0 21 # options
michael@0 22 # -------
michael@0 23 # -y answer all questions with y - use at your own risk... ignores warnings
michael@0 24 # -s silent (only usefull with -y)
michael@0 25 # -h, -? - you guessed right - displays this text
michael@0 26 # -d debug
michael@0 27 # -f <filename> - write the (error)output to filename
michael@0 28 # -fcronfile produces the resultfiles in the same locations
michael@0 29 # as would have been produced with -cron
michael@0 30 # -m <mailinglist> - send filename to mailinglist (csl) only useful
michael@0 31 # with -f
michael@0 32 # -ml <mailinglist> - send link to filename to mailinglist (csl)
michael@0 33 # only useful with -f
michael@0 34 # -cron equivalient to -y -s -d -f $RESULTDIR/$HOST.<scriptname>
michael@0 35 # -t run on a tinderbox build that means: local, from the startlocation
michael@0 36 # -l <mozroot directory> run on a local build mozroot
michael@0 37 # -ln <mozroot> copy a networkbuild to a local directory mozroot,
michael@0 38 # used for networkindipendend QA
michael@0 39 # -lt try to copy a networkbuild to a local directory, if not possible
michael@0 40 # run on the network
michael@0 41 # used for networkindipendend QA
michael@0 42 #
michael@0 43 # special strings
michael@0 44 # ---------------
michael@0 45 # FIXME ... known problems, search for this string
michael@0 46 # NOTE .... unexpected behavior
michael@0 47 #
michael@0 48 # moduls (not yet)
michael@0 49 # ----------------
michael@0 50 # --# INIT
michael@0 51 # --# USERCOM
michael@0 52 # --# UTILS
michael@0 53 #
michael@0 54 # FIXME - split in init / usercom / utils
michael@0 55 #
michael@0 56 ########################################################################
michael@0 57
michael@0 58 #------------------------------# INIT #------------------------------
michael@0 59
michael@0 60 # below the option flags get initialized
michael@0 61
michael@0 62 if [ -z "$QASCRIPT_DIR" ]
michael@0 63 then
michael@0 64 QASCRIPT_DIR=`dirname $0`
michael@0 65 if [ "$QASCRIPT_DIR" = '.' ]
michael@0 66 then
michael@0 67 QASCRIPT_DIR=`pwd`
michael@0 68 fi
michael@0 69 fi
michael@0 70 export QASCRIPT_DIR
michael@0 71
michael@0 72 O_HWACC=OFF
michael@0 73 if [ -z "$O_ALWAYS_YES" ] ; then
michael@0 74 O_ALWAYS_YES=OFF # turned on by -y answer all questions with y
michael@0 75 fi
michael@0 76
michael@0 77 if [ -z "$O_INIT" ] # header is global, some including scripts may not
michael@0 78 then # want the init to run, the others don't need to bother
michael@0 79 O_INIT=ON
michael@0 80 fi
michael@0 81 if [ -z "$O_PARAM" ] # header is global, some including scripts may not
michael@0 82 then # require parameters, the others don't need to bother
michael@0 83 O_PARAM=ON
michael@0 84 fi
michael@0 85 if [ -z "$O_OPTIONS" ] # header is global, some including scripts may not
michael@0 86 then # permit options, they don't need to bother
michael@0 87 O_OPTIONS=OFF
michael@0 88 fi
michael@0 89 O_SILENT=OFF # turned on by -s silent (only usefull with -y)
michael@0 90 if [ -z "$O_DEBUG" ] ; then
michael@0 91 O_DEBUG=OFF # turned on by -d - calls to Debug produce output when ON
michael@0 92 fi
michael@0 93 O_FILE=OFF # turned on by -f echo all output to a file $FILENAME
michael@0 94 O_CRON=OFF # turned on by -cron cron use only
michael@0 95 O_CRONFILE=OFF # turned on by -cron cron and -fcron
michael@0 96 O_LOCAL=OFF # turned on by -l* run on a local build in $LOCAL_MOZROOT
michael@0 97 O_LN=OFF # turned on by -ln and -lt, test a networkbuild locally
michael@0 98 O_MAIL=OFF # turned on by -m - sends email
michael@0 99 O_MAIL_LINK=OFF # turned on by -ml - sends email
michael@0 100 O_TBX=OFF # turned on by -t run on a tinderbox build
michael@0 101 # that means: local, from the startlocation
michael@0 102
michael@0 103 if [ -z "$DOMSUF" ]
michael@0 104 then
michael@0 105
michael@0 106 DOMSUF=red.iplanet.com
michael@0 107 DS_WAS_SET=FALSE
michael@0 108 else
michael@0 109 DS_WAS_SET=TRUE
michael@0 110 fi
michael@0 111
michael@0 112 TMPFILES=""
michael@0 113
michael@0 114 WAIT_FOR=600 # if waiting for an event sleep n seconds before rechecking
michael@0 115 # recomended value 10 minutes 600
michael@0 116 WAIT_TIMES=30 # recheck n times before giving up - recomended 30 - total of 5h
michael@0 117
michael@0 118 if [ -z "$QAYEAR" ] # may I introduce - the y2k+1 bug? QA for last year
michael@0 119 then # might not work
michael@0 120 QAYEAR=`date +%Y`
michael@0 121 fi
michael@0 122
michael@0 123 if [ -z "$TMP" ]
michael@0 124 then
michael@0 125 if [ -z "$TEMP" ]
michael@0 126 then
michael@0 127 TMP="/tmp"
michael@0 128 else
michael@0 129 TMP=$TEMP
michael@0 130 fi
michael@0 131 fi
michael@0 132 if [ ! -w "$TMP" ]
michael@0 133 then
michael@0 134 echo "Can't write to tmp directory $TMP - exiting"
michael@0 135 echo "Can't write to tmp directory $TMP - exiting" >&2
michael@0 136 exit 1
michael@0 137 fi
michael@0 138
michael@0 139 KILLPIDS="$TMP/killpids.$$"
michael@0 140 export KILLERPIDS
michael@0 141 TMPFILES="$TMPFILES $KILLPIDS"
michael@0 142
michael@0 143 KILL_SELFSERV=OFF # if sourcing script sets this to on cleanup will also
michael@0 144 # kill the running selfserv processes
michael@0 145
michael@0 146 # Set the masterbuilds
michael@0 147 if [ -z "$UX_MASTERBUILD" ]
michael@0 148 then
michael@0 149 UX_MASTERBUILD=booboo_Solaris8
michael@0 150 #if [ ! -d $UX_MASTERBUILD ] ; then
michael@0 151 #UX_MASTERBUILD=booboo_Solaris8_forte6
michael@0 152 #fi
michael@0 153 UX_MB_WAS_SET=FALSE
michael@0 154 else
michael@0 155 UX_MB_WAS_SET=TRUE
michael@0 156 fi
michael@0 157 if [ -z "$NT_MASTERBUILD" ]
michael@0 158 then
michael@0 159 NT_MASTERBUILD=blowfish_NT4.0_Win95
michael@0 160 NT_MB_WAS_SET=FALSE # in this case later functions can override if
michael@0 161 # they find a different build that looks like NT
michael@0 162 else
michael@0 163 NT_MB_WAS_SET=TRUE
michael@0 164 fi
michael@0 165 if [ -z "$MASTERBUILD" ]
michael@0 166 then
michael@0 167 MASTERBUILD=$UX_MASTERBUILD
michael@0 168 fi
michael@0 169
michael@0 170 # Set the default build
michael@0 171 if [ -z "$BUILDNUMBER" ]
michael@0 172 then
michael@0 173 BUILDNUMBER=1
michael@0 174 fi
michael@0 175 export BUILDNUMBER
michael@0 176 O_LDIR=OFF #local QA dir for NT, temporary
michael@0 177
michael@0 178 if [ -z "$WIN_WAIT_FOREVER" ] # header is global, some including scripts
michael@0 179 then # want the init to wait forever for directories to
michael@0 180 # appear (windows only) if OFF exit, if ON wait forever
michael@0 181 WIN_WAIT_FOREVER=OFF
michael@0 182 fi
michael@0 183
michael@0 184 # NOTE: following variables have to change
michael@0 185 # from release to release
michael@0 186 if [ -z "$BC_MASTER" ] # master directory for backwardscompatibility testing
michael@0 187 then
michael@0 188 RH="NO"
michael@0 189 grep 7.1 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES"
michael@0 190 grep 7.2 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES"
michael@0 191
michael@0 192 if [ "$RH" = "YES" ]
michael@0 193 then # NSS-3-3-1RTM
michael@0 194 BC_UX_MASTER=nss331/builds/20010928.2.331-RTM/booboo_Solaris8
michael@0 195 BC_NT_MASTER=nss331/builds/20010928.2.331-RTM/blowfish_NT4.0_Win95
michael@0 196 else # NSS-3-2-2RTM
michael@0 197 BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
michael@0 198 BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
michael@0 199 fi
michael@0 200 BC_MASTER=$BC_UX_MASTER
michael@0 201 BC_MASTER_WAS_SET=FALSE
michael@0 202 else
michael@0 203 BC_MASTER_WAS_SET=TRUE
michael@0 204 fi
michael@0 205 BC_RELEASE=3.2
michael@0 206 export BC_RELEASE
michael@0 207
michael@0 208 EARLY_EXIT=TRUE #before the report file has been created, causes Exit to
michael@0 209 #create it
michael@0 210
michael@0 211 UX_D0=/share/builds/mccrel3/nss
michael@0 212
michael@0 213 ################################### glob_init ##########################
michael@0 214 # global shell function, main initialisation function
michael@0 215 ########################################################################
michael@0 216 glob_init()
michael@0 217 {
michael@0 218 if [ $O_PARAM = "ON" ] ; then
michael@0 219 eval_opts $* # parse parameters and options - set flags
michael@0 220 fi
michael@0 221 # if running from cron HOST needs to be known early,
michael@0 222 init_host # so the output file name can be constructed.
michael@0 223 Debug "Setting up environment...( $QASCRIPT_DIR/set_environment) "
michael@0 224 . $QASCRIPT_DIR/set_environment #finds out if we are running on Windows
michael@0 225 Debug "OPerating system: $os_name $os_full"
michael@0 226 umask 0
michael@0 227 init_dirs
michael@0 228 init_files
michael@0 229 init_vars
michael@0 230 }
michael@0 231
michael@0 232 ################################### init_vars ###########################
michael@0 233 # global shell function, sets the environment variables, part of init
michael@0 234 ########################################################################
michael@0 235 init_vars()
michael@0 236 {
michael@0 237 if [ -z "$LOGNAME" ]
michael@0 238 then
michael@0 239 if [ $O_WIN = "ON" ]
michael@0 240 then
michael@0 241 LOGNAME=$USERNAME
michael@0 242 else
michael@0 243 LOGNAME=$USER
michael@0 244 fi
michael@0 245 if [ -z "$LOGNAME" ]
michael@0 246 then
michael@0 247 LOGNAME=$UNAME
michael@0 248 if [ -z "$LOGNAME" ]
michael@0 249 then
michael@0 250 LOGNAME=`basename $HOME`
michael@0 251 fi
michael@0 252 fi
michael@0 253 fi
michael@0 254 if [ -z "$LOGNAME" ]
michael@0 255 then
michael@0 256 Exit "Can't determine current user"
michael@0 257 fi
michael@0 258 case $HOST in
michael@0 259 iws-perf)
michael@0 260 O_HWACC=ON
michael@0 261 HWACC_LIST="rainbow ncipher"
michael@0 262 #MODUTIL="-add rainbow -libfile /usr/lib/libcryptoki22.so"
michael@0 263 export HWACC_LIST
michael@0 264 ;;
michael@0 265 *)
michael@0 266 O_HWACC=OFF
michael@0 267 ;;
michael@0 268 esac
michael@0 269 export O_HWACC
michael@0 270 }
michael@0 271
michael@0 272 ########################################################################
michael@0 273 # functions below deal with setting up the directories and PATHs for
michael@0 274 # all different flavors of OS (Unix, Linux, NT MKS, NT Cygnus) and QA
michael@0 275 # (Standard, local tinderbox)
michael@0 276 ########################################################################
michael@0 277
michael@0 278 ########################## find_nt_masterbuild #########################
michael@0 279 # global shell function, sets the nt masterbuild directories, part of init
michael@0 280 ########################################################################
michael@0 281 find_nt_masterbuild()
michael@0 282 {
michael@0 283 NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD}
michael@0 284 if [ "${NT_MB_WAS_SET}" = "FALSE" -a ! -d $NT_MASTERDIR ] ; then
michael@0 285 if [ -d ${DAILY_BUILD}/*NT4* ] ; then
michael@0 286 NT_MASTERBUILD=` cd ${DAILY_BUILD}; ls -d *NT4* `
michael@0 287 Debug "NT_MASTERBUILD $NT_MASTERBUILD"
michael@0 288 NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD}
michael@0 289 fi
michael@0 290 fi
michael@0 291 Debug "NT_MASTERDIR $NT_MASTERDIR"
michael@0 292 }
michael@0 293
michael@0 294 ################################### set_daily_build_dirs ###########################
michael@0 295 # global shell function, sets directories
michael@0 296 ########################################################################
michael@0 297 set_daily_build_dirs()
michael@0 298 {
michael@0 299 if [ "$O_LOCAL" = "ON" -a "$O_LN" = "OFF" ] ; then
michael@0 300 DAILY_BUILD=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are
michael@0 301 # set to the LOCAL_MOZROOT, since it is not sure
michael@0 302 # if ../.. (DAILY_BUILD) even exists
michael@0 303 LOCALDIST=${LOCAL_MOZROOT}/dist
michael@0 304 elif [ "$O_TBX" = "ON" ] ; then
michael@0 305 DAILY_BUILD="$TBX_DAILY_BUILD"
michael@0 306 LOCALDIST=${UXDIST}
michael@0 307 else
michael@0 308 DAILY_BUILD=${NSS_VER_DIR}/builds/${QAYEAR}${BUILDDATE}.${BUILDNUMBER}
michael@0 309 LOCALDIST=${DAILY_BUILD}/${MASTERBUILD}/mozilla/dist
michael@0 310 fi
michael@0 311 }
michael@0 312
michael@0 313 map_os64()
michael@0 314 {
michael@0 315 IS_64=""
michael@0 316 case `uname -s` in
michael@0 317 #OSF1) has been done already - always 64 bit
michael@0 318 SunOS)
michael@0 319 MAPPED_OS=Solaris*8
michael@0 320 IS_64=`(isainfo -v | grep 64)>/dev/null 2>/dev/null && echo 64 bit`
michael@0 321 if [ "$O_TBX" = "OFF" ] ; then
michael@0 322 set_osdir
michael@0 323 if [ -n "$IS_64" ]
michael@0 324 then #Wait for the 64 bit build to finish...
michael@0 325 Debug Testing build for $MAPPED_OS in $OSDIR
michael@0 326 Wait ${OSDIR}/SVbuild.InProgress.1 0
michael@0 327 fi
michael@0 328 fi
michael@0 329 ;;
michael@0 330 AIX)
michael@0 331 IS_64=`lslpp -l | grep "bos.64bit"> /dev/null && echo 64 bit`
michael@0 332 ;;
michael@0 333 HP-UX)
michael@0 334 IS_64=`getconf KERNEL_BITS | grep 64 >/dev/null && echo 64 bit`
michael@0 335 ;;
michael@0 336 esac
michael@0 337 Debug "Mapped OS to $MAPPED_OS"
michael@0 338 }
michael@0 339
michael@0 340
michael@0 341
michael@0 342 ################################### copy_to_local ########################
michael@0 343 # global shell function, copies the necessary directories from the
michael@0 344 # daily build aerea to the local disk
michael@0 345 ########################################################################
michael@0 346 copy_to_local()
michael@0 347 {
michael@0 348 Debug "Copy network directories to local directories"
michael@0 349 C2L_ERROR=0
michael@0 350 if [ ! -d ${LOCAL_MOZROOT}/dist ] ; then
michael@0 351 mkdir -p ${LOCAL_MOZROOT}/dist || C2L_ERROR=1
michael@0 352 fi
michael@0 353 if [ ! -d ${LOCAL_MOZROOT}/security/nss ] ; then
michael@0 354 mkdir -p ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=2
michael@0 355 fi
michael@0 356 if [ $C2L_ERROR != 0 ] ; then
michael@0 357 Exit "copy_to_local: Can t make necesssary directories ($C2L_ERROR ) "
michael@0 358 fi
michael@0 359 if [ ! -d ${LOCAL_MOZROOT}/security/nss/tests ] ; then
michael@0 360 cp -r ${TESTSCRIPTDIR} ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=1
michael@0 361 fi
michael@0 362 if [ ! -d ${LOCAL_MOZROOT}/security/coreconf ] ; then
michael@0 363 cp -r ${MOZILLA_ROOT}/security/coreconf ${LOCAL_MOZROOT}/security || C2L_ERROR=2
michael@0 364 fi
michael@0 365
michael@0 366 NO_DIRS=0;
michael@0 367 if [ "$O_WIN" = "ON" ] ; then
michael@0 368 OS_TARGET=WINNT;export OS_TARGET
michael@0 369 fi
michael@0 370 unset BUILD_OPT;export BUILD_OPT;
michael@0 371 unset USE_64;export USE_64;
michael@0 372 #FIXME only tested on 64 bit Solaris and only got 32 bit builds
michael@0 373 while [ $NO_DIRS -lt 4 ] ; do
michael@0 374 # first time thru: Debug 32 bit NT
michael@0 375 set_objdir
michael@0 376 Debug "Copying ${OBJDIR}..."
michael@0 377 if [ ! -d ${LOCAL_MOZROOT}/dist/${OBJDIR} ] ; then
michael@0 378 cp -r ${LOCALDIST}/${OBJDIR} ${LOCAL_MOZROOT}/dist || C2L_ERROR=3
michael@0 379 fi
michael@0 380 NO_DIRS=`expr $NO_DIRS + 1`
michael@0 381 if [ $NO_DIRS = 1 ] ; then # 2nd time: OPT 32 bit NT
michael@0 382 BUILD_OPT=1; export BUILD_OPT;
michael@0 383 elif [ $NO_DIRS = 2 ] ; then # 3rd time: OPT, either 64 bit or Win95 or force exit
michael@0 384 if [ "$O_WIN" = "ON" ] ; then
michael@0 385 OS_TARGET=WIN95;export OS_TARGET
michael@0 386 else
michael@0 387 map_os64
michael@0 388 if [ -z "$IS_64" ] ; then #32 bit platform
michael@0 389 NO_DIRS=4
michael@0 390 else
michael@0 391 USE_64=1; export USE_64
michael@0 392 fi
michael@0 393 fi
michael@0 394 elif [ $NO_DIRS = 3 ] ; then # 4th time: Debug either 64 bit or Win95
michael@0 395 unset BUILD_OPT;export BUILD_OPT;
michael@0 396 fi
michael@0 397
michael@0 398
michael@0 399 done
michael@0 400 if [ $C2L_ERROR != 0 ] ; then
michael@0 401 Exit "copy_to_local: Can t copy necesssary directories ($C2L_ERROR ) "
michael@0 402 fi
michael@0 403 unset TESTSCRIPTDIR
michael@0 404 unset TESTDIR
michael@0 405 unset RESULTDIR
michael@0 406 O_LN=OFF #from here on pretend it is regular -l local QA FIXME, might cause
michael@0 407 #problems with the backwardcompatibility tests
michael@0 408 Debug "Successfully copied network directories to local directories"
michael@0 409 }
michael@0 410
michael@0 411 ################################### local_dirs ###########################
michael@0 412 # global shell function, sets the directories for local QA
michael@0 413 ########################################################################
michael@0 414 local_dirs()
michael@0 415 {
michael@0 416 Debug "Set directories for local QA"
michael@0 417 #if [ "$O_WIN" = "ON" ] ; then
michael@0 418 #win_set_tmp
michael@0 419 #fi
michael@0 420 NSS_VER_DIR=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are
michael@0 421 # set to the LOCAL_MOZROOT, since it is not sure
michael@0 422 # if ../../../.. (NSS_VER_DIR) even exists
michael@0 423 if [ -z "${RESULTDIR}" ] ; then # needs to be local as well
michael@0 424 Debug "Setting RESULTDIR for local QA"
michael@0 425 RESULTDIR="${LOCAL_MOZROOT}/tests_results/security/${HOST}-`date +%Y%m%d-%H.%M`"
michael@0 426 fi
michael@0 427 set_daily_build_dirs
michael@0 428 UX_MASTERDIR=`dirname ${LOCAL_MOZROOT}`
michael@0 429 NT_MASTERDIR=$UX_MASTERDIR
michael@0 430 MOZILLA_ROOT=${LOCAL_MOZROOT}
michael@0 431
michael@0 432 UXDIST=${MOZILLA_ROOT}/dist
michael@0 433 NTDIST=${UXDIST}
michael@0 434
michael@0 435 if [ -z "${TESTDIR}" ] ; then
michael@0 436 Debug "Setting TESTDIR for local QA"
michael@0 437 TESTDIR=${RESULTDIR}
michael@0 438 fi
michael@0 439 if [ -n "$TESTDIR" ] ; then
michael@0 440 if [ ! -d $TESTDIR ] ; then
michael@0 441 Debug "Making TESTDIR for local QA"
michael@0 442 mkdir -p $TESTDIR
michael@0 443 fi
michael@0 444 fi
michael@0 445 export TESTDIR
michael@0 446 Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
michael@0 447
michael@0 448 TESTSCRIPTDIR=${LOCAL_MOZROOT}/security/nss/tests
michael@0 449 COMMON=${TESTSCRIPTDIR}/common
michael@0 450
michael@0 451 set_objdir
michael@0 452 debug_dirs
michael@0 453 export_dirs
michael@0 454 }
michael@0 455
michael@0 456
michael@0 457 ################################### tbx_dirs ###########################
michael@0 458 # global shell function, sets the directories for tinderbox QA
michael@0 459 ########################################################################
michael@0 460 tbx_dirs()
michael@0 461 {
michael@0 462 Debug "Set directories for tinderbox"
michael@0 463 if [ "$O_WIN" = "ON" ] ; then
michael@0 464 win_set_d1 # we need the NSS_VER_DIR later
michael@0 465 else
michael@0 466 NSS_VER_DIR="$UX_D0"/nss$NSSVER
michael@0 467 fi
michael@0 468 if [ -z "${RESULTDIR}" ] ; then # needs to be different for tinderbox
michael@0 469 Debug "Setting RESULTDIR for tinderbox"
michael@0 470 TBX_NOBITS=""
michael@0 471 echo $QASCRIPT_DIR | grep 64 >/dev/null && TBX_NOBITS=64
michael@0 472 TRD="${HOST}${TBX_NOBITS}-`date +%Y%m%d-%H.%M`"
michael@0 473 RESULTDIR="${NSS_VER_DIR}/tinderbox/tests_results/security/${TRD}"
michael@0 474 if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
michael@0 475 URL="sbs-rel.nscp.aoltw.net"
michael@0 476 else
michael@0 477 URL="cindercone.red.iplanet.com"
michael@0 478 fi
michael@0 479 if [ "$O_WIN" = "ON" ] ; then
michael@0 480 RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${UX_D0}/nsstip/tinderbox/tests_results/security/${TRD}\">QA</a>"
michael@0 481 else
michael@0 482 RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${RESULTDIR}\">QA</a>"
michael@0 483 fi
michael@0 484 Debug "RESULTDIRURL TinderboxPrint:$RESULTDIRURL"
michael@0 485 fi
michael@0 486 TBX_DAILY_BUILD=`cd ../../../../..;pwd`
michael@0 487 NSS_VER_DIR="${TBX_DAILY_BUILD}/../.."
michael@0 488 TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tinderbox | sed -e 's/ .*//g'`
michael@0 489 if [ -z "$TBX_LOGFILE_DIR" ] ; then
michael@0 490 TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tbx | sed -e 's/ .*//g'`
michael@0 491 TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tbx/${TBX_LOGFILE_DIR}"
michael@0 492 else
michael@0 493 TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tinderbox/${TBX_LOGFILE_DIR}"
michael@0 494 fi
michael@0 495 Debug "Set TBX_LOGFILE_DIR ${TBX_LOGFILE_DIR}"
michael@0 496
michael@0 497 set_daily_build_dirs
michael@0 498 UX_MASTERDIR=`cd ../../../..;pwd`
michael@0 499 NT_MASTERDIR=$UX_MASTERDIR
michael@0 500 MOZILLA_ROOT=$UX_MASTERDIR/mozilla
michael@0 501
michael@0 502 UXDIST=${MOZILLA_ROOT}/dist
michael@0 503 NTDIST=${UXDIST}
michael@0 504
michael@0 505 if [ -z "${TESTDIR}" ] ; then
michael@0 506 Debug "Setting TESTDIR for tinderbox"
michael@0 507 TESTDIR=${RESULTDIR}
michael@0 508 fi
michael@0 509 if [ -n "$TESTDIR" ] ; then
michael@0 510 if [ ! -d $TESTDIR ] ; then
michael@0 511 Debug "Making TESTDIR for tinderbox"
michael@0 512 mkdir -p $TESTDIR
michael@0 513 fi
michael@0 514 fi
michael@0 515 Debug "Making QAstatus file"
michael@0 516 echo "QA running" >${TESTDIR}/QAstatus
michael@0 517 export TESTDIR
michael@0 518 Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
michael@0 519
michael@0 520 TESTSCRIPTDIR=`pwd`
michael@0 521 COMMON=${TESTSCRIPTDIR}/common
michael@0 522
michael@0 523 set_objdir
michael@0 524 debug_dirs
michael@0 525 export_dirs
michael@0 526 }
michael@0 527
michael@0 528 ################################### init_mcom ###########################
michael@0 529 # global shell function, sets domain specific variables for AOL's
michael@0 530 # domains according to Bishakha's instructions
michael@0 531 ########################################################################
michael@0 532 init_mcom()
michael@0 533 {
michael@0 534 Debug "Running in mcom or netscape domain - changing directories..."
michael@0 535 if [ "${UX_MB_WAS_SET}" = "FALSE" ] ; then #in case it was set
michael@0 536 # before script was called use these values
michael@0 537 UX_MASTERBUILD=spd04_Solaris8
michael@0 538 fi
michael@0 539 if [ "${NT_MB_WAS_SET}" = "FALSE" ] ; then
michael@0 540 NT_MASTERBUILD=spd06_NT4
michael@0 541 fi
michael@0 542
michael@0 543 MASTERBUILD=$UX_MASTERBUILD
michael@0 544 if [ "${BC_MASTER_WAS_SET}" = "FALSE" ] ; then
michael@0 545 BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
michael@0 546 BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
michael@0 547 BC_MASTER=$BC_UX_MASTER
michael@0 548 fi
michael@0 549 UX_D0=/share/builds/sbsrel2/nss
michael@0 550 URL="sbs-rel.nscp.aoltw.net"
michael@0 551 }
michael@0 552 ################################### init_dirs ###########################
michael@0 553 # global shell function, sets the directories for standard QA
michael@0 554 # calls special functions for tinderbox, windows or local QA, part of init
michael@0 555 ########################################################################
michael@0 556 init_dirs()
michael@0 557 {
michael@0 558 if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
michael@0 559 init_mcom
michael@0 560 fi
michael@0 561 if [ $O_WIN = "ON" ] ; then
michael@0 562 win_set_tmp
michael@0 563 write_to_tmpfile
michael@0 564 MASTERBUILD=$NT_MASTERBUILD
michael@0 565 BC_MASTER=$BC_NT_MASTER
michael@0 566 fi
michael@0 567 if [ "$O_LOCAL" = "ON" -a $O_LN = "OFF" ] ; then # if it is a LN we need to know
michael@0 568 # all the directories off the network first to copy them
michael@0 569 local_dirs # O_LOCAL alone assumes that all the directories are already there
michael@0 570 return
michael@0 571 elif [ "$O_TBX" = "ON" ] ; then
michael@0 572 tbx_dirs
michael@0 573 return
michael@0 574 elif [ "$O_WIN" = "ON" ] ; then
michael@0 575 win_set_d1
michael@0 576 else
michael@0 577 NSS_VER_DIR="$UX_D0"/nss$NSSVER
michael@0 578 fi
michael@0 579 #set -x
michael@0 580
michael@0 581 set_daily_build_dirs
michael@0 582
michael@0 583 if [ -z "${BCDIST}" ] ; then
michael@0 584 #BCDIST=/share/builds/mccrel3/nss/${BC_MASTER}/mozilla/dist
michael@0 585 BCDIST=${NSS_VER_DIR}/../${BC_MASTER}/mozilla/dist
michael@0 586 if [ ! -d $BCDIST -a `basename $0` != jssqa ] ; then
michael@0 587 ask "Backward compatibility directory $BCDIST does not exist, continue" "y" "n" || Exit
michael@0 588 fi
michael@0 589 fi
michael@0 590
michael@0 591 UX_MASTERDIR=${DAILY_BUILD}/${UX_MASTERBUILD}
michael@0 592 find_nt_masterbuild
michael@0 593
michael@0 594 if [ "$O_WIN" = "ON" ]
michael@0 595 then
michael@0 596 MOZILLA_ROOT=${NT_MASTERDIR}/mozilla
michael@0 597 else
michael@0 598 MOZILLA_ROOT=${UX_MASTERDIR}/mozilla
michael@0 599 fi
michael@0 600
michael@0 601 UXDIST=${UX_MASTERDIR}/mozilla/dist
michael@0 602 NTDIST=${NT_MASTERDIR}/mozilla/dist
michael@0 603
michael@0 604 if [ -z "${RESULTDIR}" ] ; then
michael@0 605 RESULTDIR=${UX_MASTERDIR}/mozilla/tests_results/security
michael@0 606 fi
michael@0 607
michael@0 608 if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
michael@0 609
michael@0 610 if [ "$O_WIN" = "ON" ] ; then
michael@0 611 JSS_NSS_SRC_DIR=$JSS_NSS_NT_SRC_DIR
michael@0 612 fi
michael@0 613 TESTSCRIPTDIR=${NSS_VER_DIR}/../${JSS_NSS_SRC_DIR}/mozilla/security/nss/tests
michael@0 614 else
michael@0 615 TESTSCRIPTDIR=${MOZILLA_ROOT}/security/nss/tests
michael@0 616 fi
michael@0 617
michael@0 618 if [ ! -d $TESTSCRIPTDIR -a `basename $0` != jssqa ] ; then
michael@0 619 if [ "$O_WIN" = "ON" -a "$WIN_WAIT_FOREVER" = "ON" ]
michael@0 620 then
michael@0 621 WaitForever $TESTSCRIPTDIR/all.sh 1
michael@0 622 else
michael@0 623 Exit "Test directory $TESTSCRIPTDIR does not exist"
michael@0 624 fi
michael@0 625 fi
michael@0 626
michael@0 627 COMMON=${TESTSCRIPTDIR}/common
michael@0 628 if [ "$O_LOCAL" = "ON" -a $O_LN = "ON" ] ; then # if it is a LN we need to know
michael@0 629 # all the directories off the network first to copy them
michael@0 630 copy_to_local
michael@0 631 local_dirs
michael@0 632 fi
michael@0 633 #set +x
michael@0 634
michael@0 635
michael@0 636 set_objdir
michael@0 637 debug_dirs
michael@0 638 export_dirs
michael@0 639 }
michael@0 640
michael@0 641 debug_dirs()
michael@0 642 {
michael@0 643 Debug "NTDIST $NTDIST"
michael@0 644 Debug "UXDIST $UXDIST"
michael@0 645 Debug "TESTSCRIPTDIR $TESTSCRIPTDIR"
michael@0 646 Debug "RESULTDIR $RESULTDIR"
michael@0 647 Debug "TMP $TMP"
michael@0 648 Debug "LOCALDIST_BIN $LOCALDIST_BIN"
michael@0 649 Debug "COMMON $COMMON"
michael@0 650 Debug "MOZILLA_ROOT $MOZILLA_ROOT"
michael@0 651 Debug "BCDIST $BCDIST"
michael@0 652 }
michael@0 653
michael@0 654 export_dirs()
michael@0 655 {
michael@0 656 export NSS_VER_DIR DAILY_BUILD NTDIST UXDIST RESULTDIR TESTSCRIPTDIR BCDIST
michael@0 657 export UX_MASTERDIR NT_MASTERDIR COMMON MOZILLA_ROOT
michael@0 658 }
michael@0 659
michael@0 660 set_osdir()
michael@0 661 {
michael@0 662 OSDIR=${DAILY_BUILD}/*${MAPPED_OS}*
michael@0 663 }
michael@0 664
michael@0 665 ################################### init_files ###########################
michael@0 666 # global shell function, sets filenames, initializes files, part of init
michael@0 667 ########################################################################
michael@0 668 init_files()
michael@0 669 {
michael@0 670 if [ $O_CRONFILE = "ON" ]
michael@0 671 then
michael@0 672 Debug "attempting to create resultfiles"
michael@0 673 if [ "$O_TBX" = "ON" ] ; then
michael@0 674 NEWFILENAME=${TBX_LOGFILE_DIR}/qa.log
michael@0 675 if [ ! -w ${TBX_LOGFILE_DIR} ] ; then
michael@0 676 Exit "can't touch $NEWFILENAME"
michael@0 677 fi
michael@0 678 else
michael@0 679 NEWFILENAME=$RESULTDIR/$HOST.`basename $0`
michael@0 680 fi
michael@0 681 if [ ! -d $RESULTDIR ]
michael@0 682 then
michael@0 683 mkdir -p $RESULTDIR || Exit "Error: can't make $RESULTDIR"
michael@0 684 fi
michael@0 685 if [ ! -w $RESULTDIR ] ; then
michael@0 686 Exit "can't touch $NEWFILENAME"
michael@0 687 fi
michael@0 688 Debug "About to touch $NEWFILENAME "
michael@0 689 touch $NEWFILENAME || Exit "Error: can't touch $NEWFILENAME"
michael@0 690 if [ "$O_TBX" = "ON" ] ; then
michael@0 691 echo "QA results in $RESULTDIR" >>$NEWFILENAME || Exit "Error: can't write to $NEWFILENAME"
michael@0 692 fi
michael@0 693 Debug "About to cat $FILENAME >>$NEWFILENAME "
michael@0 694 cat $FILENAME >>$NEWFILENAME || Exit "Error: can't append $FILENAME to $NEWFILENAME"
michael@0 695 TMPFILES="$TMPFILES $FILENAME"
michael@0 696 FILENAME=$NEWFILENAME
michael@0 697 Debug "Writing output to $FILENAME"
michael@0 698 fi
michael@0 699
michael@0 700 }
michael@0 701
michael@0 702 ################################### write_to_tmpfile ##########################
michael@0 703 # global shell function, for NT and cron operation, first a tmpfile
michael@0 704 # needs to be created
michael@0 705 ########################################################################
michael@0 706 write_to_tmpfile()
michael@0 707 {
michael@0 708 O_CRONFILE=ON
michael@0 709 O_FILE=ON
michael@0 710 FILENAME=${TMP}/nsstmp.$$ # for now write to the temporary file
michael@0 711 # since we don't know the hostname yet
michael@0 712 # will be inserted to the real file later
michael@0 713 TMPFILES="$TMPFILES nsstmp.$$"
michael@0 714 touch $FILENAME || Exit "Error: can't touch $FILENAME"
michael@0 715 Debug "Writing output to $FILENAME"
michael@0 716 }
michael@0 717
michael@0 718 ############################# turn_on_cronoptions ######################
michael@0 719 # global shell function, turns on options needed for cron and tinderbox
michael@0 720 ########################################################################
michael@0 721 turn_on_cronoptions()
michael@0 722 {
michael@0 723 O_CRON=ON
michael@0 724 O_SILENT=ON
michael@0 725 O_DEBUG=ON # FIXME take out!
michael@0 726 O_ALWAYS_YES=ON
michael@0 727 write_to_tmpfile
michael@0 728 }
michael@0 729
michael@0 730 ########################## test_mozroot ##########################
michael@0 731 # global shell function, determines if the variable LOCAL_MOZROOT is set,
michael@0 732 # and is usable as mozilla root diretory for a local QA
michael@0 733 ###################################################################
michael@0 734 test_mozroot()
michael@0 735 {
michael@0 736 PWD=`pwd`
michael@0 737 Debug "LOCAL_MOZROOT = $LOCAL_MOZROOT"
michael@0 738 case "$LOCAL_MOZROOT" in
michael@0 739 [0-9-]*|tip)
michael@0 740 glob_usage "Error: -"$1" requires a directoryname to follow (start with a letter) "
michael@0 741 ;;
michael@0 742 \.\.)
michael@0 743 LOCAL_MOZROOT=`dirname $PWD`
michael@0 744 ;;
michael@0 745 \.)
michael@0 746 LOCAL_MOZROOT=$PWD
michael@0 747 ;;
michael@0 748 \.\/*)
michael@0 749 LOCAL_MOZROOT=`echo $LOCAL_MOZROOT | sed -e "s/^\.//"`
michael@0 750 LOCAL_MOZROOT="${PWD}${LOCAL_MOZROOT}"
michael@0 751 ;;
michael@0 752 \.\.\/*)
michael@0 753 LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
michael@0 754 ;;
michael@0 755 \/*|[a-zA-Z]:\/*)
michael@0 756 ;;
michael@0 757 ?*)
michael@0 758 LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
michael@0 759 ;;
michael@0 760 *)
michael@0 761 glob_usage "Error: -"$1" requires a directoryname to follow"
michael@0 762 ;;
michael@0 763 esac
michael@0 764 Debug "Reformated MOZROOT to $LOCAL_MOZROOT"
michael@0 765 if [ "$1" = "ln" ] ; then
michael@0 766 LOCAL_MOZROOT_PARENT=`dirname $LOCAL_MOZROOT`
michael@0 767 if [ ! -d $LOCAL_MOZROOT_PARENT -o ! -w $LOCAL_MOZROOT_PARENT -o \
michael@0 768 ! -x $LOCAL_MOZROOT_PARENT ] ; then
michael@0 769 Exit "Error: Can't create $LOCAL_MOZROOT (permissions)"
michael@0 770 fi
michael@0 771 if [ ! -d "$LOCAL_MOZROOT" ] ; then
michael@0 772 mkdir $LOCAL_MOZROOT ||
michael@0 773 Exit "Error: Can't create mozroot $LOCAL_MOZROOT (mkdir failed)"
michael@0 774 else
michael@0 775 ask "mozroot $LOCAL_MOZROOT exists - continue (y will remove dir) ?" \
michael@0 776 "y" "n" || Exit
michael@0 777 rm -rf $LOCAL_MOZROOT/dist $LOCAL_MOZROOT/security $LOCAL_MOZROOT/tests_results ||
michael@0 778 Exit "Error: Can't clean mozroot $LOCAL_MOZROOT"
michael@0 779 fi
michael@0 780 fi
michael@0 781 if [ ! -d "$LOCAL_MOZROOT" ] ; then
michael@0 782 glob_usage "Error: mozilla root $LOCAL_MOZROOT not a valid directory"
michael@0 783 fi
michael@0 784 }
michael@0 785
michael@0 786 ################################### eval_opts ##########################
michael@0 787 # global shell function, evapuates options and parameters, sets flags
michael@0 788 # variables and defaults
michael@0 789 ########################################################################
michael@0 790 eval_opts()
michael@0 791 {
michael@0 792 while [ -n "$1" ]
michael@0 793 do
michael@0 794 case $1 in
michael@0 795 -cron)
michael@0 796 turn_on_cronoptions
michael@0 797 ;;
michael@0 798 -T*|-t*)
michael@0 799 O_TBX=ON
michael@0 800 turn_on_cronoptions
michael@0 801 O_SILENT=OFF #FIXME debug only
michael@0 802 ;;
michael@0 803 -S*|-s*)
michael@0 804 O_SILENT=ON
michael@0 805 ;;
michael@0 806 -Y*|-y)
michael@0 807 Debug "Option -y dedectet"
michael@0 808 O_ALWAYS_YES=ON
michael@0 809 ;;
michael@0 810 -d*|-D)
michael@0 811 O_DEBUG=ON
michael@0 812 #set -x
michael@0 813 ;;
michael@0 814 -ml|-ML)
michael@0 815 O_MAIL_LINK=ON
michael@0 816 shift
michael@0 817 MAILINGLIST=$1
michael@0 818 if [ -z "$MAILINGLIST" ]
michael@0 819 then
michael@0 820 glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
michael@0 821 fi
michael@0 822 Debug "Sending link to result to $MAILINGLIST"
michael@0 823 ;;
michael@0 824 -m|-M)
michael@0 825 O_MAIL=ON
michael@0 826 shift
michael@0 827 MAILINGLIST=$1
michael@0 828 if [ -z "$MAILINGLIST" ]
michael@0 829 then
michael@0 830 glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
michael@0 831 fi
michael@0 832 Debug "Sending result to $MAILINGLIST"
michael@0 833 ;;
michael@0 834 -fcron*|-F[Cc][Rr][Oo][Nn]*)
michael@0 835 write_to_tmpfile
michael@0 836 ;;
michael@0 837 -f|-F)
michael@0 838 O_FILE=ON
michael@0 839 shift
michael@0 840 FILENAME=$1
michael@0 841 if [ -z "$FILENAME" ]
michael@0 842 then
michael@0 843 glob_usage "Error: -f requires a filename to follow"
michael@0 844 fi
michael@0 845 #rm -f $FILENAME 2>/dev/null
michael@0 846 touch $FILENAME || Exit "Error: can't touch $FILENAME"
michael@0 847 #NOTE we append rather that creating
michael@0 848 Debug "Writing output to $FILENAME"
michael@0 849 ;;
michael@0 850 -h|-help|"-?")
michael@0 851 glob_usage
michael@0 852 ;;
michael@0 853 -ln)
michael@0 854 if [ `basename $0` != nssqa ] ; then
michael@0 855 glob_usage "Error: Can't handle option $1"
michael@0 856 fi
michael@0 857 O_LOCAL=ON
michael@0 858 O_LN=ON
michael@0 859 shift
michael@0 860 LOCAL_MOZROOT=$1
michael@0 861 test_mozroot ln
michael@0 862 ;;
michael@0 863 -lt)
michael@0 864 if [ `basename $0` != nssqa ] ; then
michael@0 865 glob_usage "Error: Can't handle option $1"
michael@0 866 fi
michael@0 867 O_LN=ON
michael@0 868 O_LOCAL=ON
michael@0 869 ;;
michael@0 870 -l)
michael@0 871 if [ `basename $0` != nssqa ] ; then
michael@0 872 glob_usage "Error: Can't handle option $1"
michael@0 873 fi
michael@0 874 O_LOCAL=ON
michael@0 875 shift
michael@0 876 LOCAL_MOZROOT=$1
michael@0 877 test_mozroot l
michael@0 878 ;;
michael@0 879 -p)
michael@0 880 shift
michael@0 881 PORT=$1
michael@0 882 export PORT
michael@0 883 ;;
michael@0 884 -*)
michael@0 885 glob_usage "Error: Can't handle option $1"
michael@0 886 ;;
michael@0 887 tip|3.|3..)
michael@0 888 NSSVER=$1
michael@0 889 if [ -z "$NSSVER" ] ; then
michael@0 890 glob_usage "Error: illegal parameter"
michael@0 891 fi
michael@0 892 ;;
michael@0 893 [01][0-9][0123][0-9])
michael@0 894 BUILDDATE=$1
michael@0 895 if [ -z "$BUILDDATE" ] ; then
michael@0 896 glob_usage "Error: illegal parameter"
michael@0 897 fi
michael@0 898 ;;
michael@0 899 ?*)
michael@0 900 glob_usage "Error: Can't handle parameter $1"
michael@0 901 ;;
michael@0 902 esac
michael@0 903 shift
michael@0 904 done
michael@0 905
michael@0 906 if [ -z "$PORT" -a "$O_TBX" = "ON" ] ; then
michael@0 907 PORT=8444
michael@0 908 export PORT
michael@0 909 if [ -z "$NSSVER" ] ; then
michael@0 910 NSSVER="tip"
michael@0 911 Debug "NSS Version: Parameters missing - defaulting to tip!"
michael@0 912 fi
michael@0 913 elif [ -z "$NSSVER" ] ; then
michael@0 914 NSSVER="tip"
michael@0 915 Debug "NSS Version: Parameters missing - defaulting to tip!"
michael@0 916 fi
michael@0 917 if [ -z "$BUILDDATE" ] ; then
michael@0 918 BUILDDATE=`date +%m%d`
michael@0 919 Debug "Builddate: Parameters missing - defaulting to today!"
michael@0 920 fi
michael@0 921
michael@0 922 Debug "Builddate $BUILDDATE NssVersion $NSSVER"
michael@0 923 export BUILDDATE NSSVER
michael@0 924 export O_CRON O_SILENT O_DEBUG O_ALWAYS_YES O_TBX
michael@0 925 }
michael@0 926
michael@0 927 win_set_tmp()
michael@0 928 {
michael@0 929 TMP=`echo "$TMP" | sed -e 's/ /\/t/g' -e 's//\/b/' -e 's/\\\/\//g'`
michael@0 930 Debug "TMP reformated to $TMP"
michael@0 931 }
michael@0 932
michael@0 933 ######################### win_set_d1 ################################
michael@0 934 # global shell function, interactively finds the directories in case
michael@0 935 # windows can't get to the default
michael@0 936 ########################################################################
michael@0 937 win_set_d1()
michael@0 938 {
michael@0 939 Debug "set Windows Directories..."
michael@0 940 #win_set_tmp
michael@0 941 if [ "$O_CYGNUS" = ON ]
michael@0 942 then
michael@0 943 NSS_VER_DIR=/cygdrive/w/nss/nss$NSSVER
michael@0 944 else
michael@0 945 NSS_VER_DIR=w:/nss/nss$NSSVER
michael@0 946 fi
michael@0 947 if [ ! -w $NSS_VER_DIR ]
michael@0 948 then
michael@0 949 Echo "Windows special... can't write in $NSS_VER_DIR"
michael@0 950 if [ "$O_CYGNUS" = ON ]
michael@0 951 then
michael@0 952 NSS_VER_DIR=/cygdrive/u/nss/nss$NSSVER
michael@0 953 else
michael@0 954 NSS_VER_DIR="u:/nss/nss$NSSVER"
michael@0 955 fi
michael@0 956 else
michael@0 957 Debug "NSS_VER_DIR set to $NSS_VER_DIR"
michael@0 958 return
michael@0 959 fi
michael@0 960
michael@0 961 while [ ! -w $NSS_VER_DIR ]
michael@0 962 do
michael@0 963 if [ "$O_CRONFILE" = "ON" ]
michael@0 964 then
michael@0 965 Exit "cant write in $NSS_VER_DIR"
michael@0 966 fi
michael@0 967 Warning "cant write in $NSS_VER_DIR"
michael@0 968 Echo "input start directory (u:/nss, d:/src/nss, f:/shared/nss) "
michael@0 969 read D
michael@0 970 if [ -n "$D" ]
michael@0 971 then
michael@0 972 NSS_VER_DIR=$D/nss$NSSVER
michael@0 973 fi
michael@0 974 done
michael@0 975 Debug "NSS_VER_DIR set to $NSS_VER_DIR"
michael@0 976 }
michael@0 977
michael@0 978 ########################### init_host ##################################
michael@0 979 # global shell function, sets required variables HOST and DOMSUF, and asks
michael@0 980 # the user if it has been set right
michael@0 981 ########################################################################
michael@0 982 set_host()
michael@0 983 {
michael@0 984 init_host
michael@0 985 }
michael@0 986 init_host()
michael@0 987 {
michael@0 988 if [ `basename $0` != nssqa ] ; then
michael@0 989 return
michael@0 990 fi
michael@0 991
michael@0 992 init_host_done=0
michael@0 993
michael@0 994 if [ $DS_WAS_SET = FALSE ] #give chance to overwrite, espec. for NT
michael@0 995 then
michael@0 996 Debug "Domainname was not set..."
michael@0 997 DOMSUF=`domainname 2>/dev/null`
michael@0 998 if [ -z "$DOMSUF" ]
michael@0 999 then
michael@0 1000 Debug "domainname command did not work ..."
michael@0 1001 DOMSUF=`echo $HOST | grep '\.' | sed -e "s/[^\.]*\.//"`
michael@0 1002
michael@0 1003 if [ -z "$DOMSUF" ]
michael@0 1004 then
michael@0 1005 Debug "Domainname not part of the hostname"
michael@0 1006 DOMSUF=`cat /etc/defaultdomain 2>/dev/null`
michael@0 1007 if [ -z "$DOMSUF" ]
michael@0 1008 then
michael@0 1009 Debug "Domainname needs to be hardcoded to red.iplanet.com"
michael@0 1010 DOMSUF="red.iplanet.com"
michael@0 1011 fi
michael@0 1012 fi
michael@0 1013 fi
michael@0 1014 fi
michael@0 1015 case $HOST in
michael@0 1016 *\.*)
michael@0 1017 Debug "HOSTNAME $HOST contains Dot"
michael@0 1018 HOST=`echo $HOST | sed -e "s/\..*//"`
michael@0 1019 ;;
michael@0 1020 esac
michael@0 1021 if [ -z "$HOST" ]
michael@0 1022 then
michael@0 1023 HOST=`uname -n`
michael@0 1024 case $HOST in
michael@0 1025 *\.*)
michael@0 1026 Debug "HOSTNAME $HOST contains Dot"
michael@0 1027 HOST=`echo $HOST | sed -e "s/\..*//"`
michael@0 1028 ;;
michael@0 1029 esac
michael@0 1030 fi
michael@0 1031 if [ $O_DEBUG = "ON" ]
michael@0 1032 then
michael@0 1033 while [ $init_host_done -eq 0 ]
michael@0 1034 do
michael@0 1035 Echo
michael@0 1036 ask "DOMSUF=$DOMSUF, HOST=$HOST - OK", "y" "n" &&
michael@0 1037 init_host_done=1
michael@0 1038 if [ $init_host_done -eq 0 ]
michael@0 1039 then
michael@0 1040 Echo "input DOMSUF: "
michael@0 1041 read D
michael@0 1042 if [ -n "$D" ]
michael@0 1043 then
michael@0 1044 DOMSUF=$D
michael@0 1045 fi
michael@0 1046 Echo "input HOST: "
michael@0 1047 read H
michael@0 1048 if [ -n "$H" ]
michael@0 1049 then
michael@0 1050 HOST=$H
michael@0 1051 fi
michael@0 1052 fi
michael@0 1053 done
michael@0 1054 fi
michael@0 1055 export HOST DOMSUF
michael@0 1056 Debug "HOST: $HOST, DOMSUF: $DOMSUF"
michael@0 1057 }
michael@0 1058
michael@0 1059 #-----------------------------# UTILS #----------------------------------
michael@0 1060
michael@0 1061 ########################### qa_stat_get_sysinfo ########################
michael@0 1062 # local shell function, tries to determine the QA operating system
michael@0 1063 ########################################################################
michael@0 1064 qa_stat_get_sysinfo()
michael@0 1065 {
michael@0 1066 case $1 in
michael@0 1067 ?*) REM_SYS=$1
michael@0 1068 GET_SYSINFO="rsh $1"
michael@0 1069 ;;
michael@0 1070 *) REM_SYS=""
michael@0 1071 GET_SYSINFO=""
michael@0 1072 ;;
michael@0 1073 esac
michael@0 1074 QA_SYS=`$GET_SYSINFO uname -sr`
michael@0 1075 echo $QA_SYS | grep Linux >/dev/null &&
michael@0 1076 QA_RHVER=`$GET_SYSINFO cat /etc/redhat-release`
michael@0 1077 if [ -n "$QA_RHVER" ]
michael@0 1078 then
michael@0 1079 QA_OS=`echo $REM_SYS $QA_RHVER | sed -e "s/Red Hat /RH /" \
michael@0 1080 -e "s/ release//"`
michael@0 1081 else
michael@0 1082 case $QA_SYS in
michael@0 1083 *SunOS*5.[89]*)
michael@0 1084 ISAINFO=`$GET_SYSINFO isainfo -v`
michael@0 1085 IS_64=`echo $ISAINFO | grep 64 >/dev/null && \
michael@0 1086 echo 64 bit`
michael@0 1087 IS_I386=`echo $ISAINFO | grep i386 >/dev/null && \
michael@0 1088 echo i86pc`
michael@0 1089 if [ -n "$IS_I386" ] ; then IS_64="$IS_I386"; fi;
michael@0 1090 if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
michael@0 1091 ;;
michael@0 1092 *HP*)
michael@0 1093 IS_64=`$GET_SYSINFO getconf KERNEL_BITS |
michael@0 1094 grep 64 >/dev/null && echo 64 bit`
michael@0 1095 if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
michael@0 1096 ;;
michael@0 1097 *AIX*)
michael@0 1098 IS_64=`$GET_SYSINFO lslpp -l |
michael@0 1099 grep "bos.64bit"> /dev/null && echo 64 bit`
michael@0 1100 if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
michael@0 1101 ;;
michael@0 1102 esac
michael@0 1103 QA_OS=`echo "$REM_SYS $QA_SYS $IS_64"`
michael@0 1104 fi
michael@0 1105 if [ "$O_SILENT" != ON ] ; then
michael@0 1106 echo $QA_OS
michael@0 1107 fi
michael@0 1108 QA_OS_STRING=`echo $QA_OS | sed -e "s/^[_ ]//" -e "s/ /_/g"`
michael@0 1109 }
michael@0 1110
michael@0 1111 ################################### set_objdir #########################
michael@0 1112 # global shell function, sets the object directories and DIST
michael@0 1113 ########################################################################
michael@0 1114 set_objdir()
michael@0 1115 {
michael@0 1116 Debug "set object dir"
michael@0 1117 OBJDIR=`cd ${TESTSCRIPTDIR}/common; gmake objdir_name`
michael@0 1118 OS_ARCH=`cd ${TESTSCRIPTDIR}/common; gmake os_arch`
michael@0 1119
michael@0 1120 #at this point $MASTERBUILD needs to be either NT or unix
michael@0 1121
michael@0 1122 set_daily_build_dirs
michael@0 1123 LOCALDIST_BIN=${LOCALDIST}/${OBJDIR}/bin
michael@0 1124 DIST=$LOCALDIST
michael@0 1125
michael@0 1126 if [ -z "${TEST_LEVEL}" ] ; then
michael@0 1127 TEST_LEVEL=0
michael@0 1128 fi
michael@0 1129 bc ${TEST_LEVEL} #set the path for the backward compatibility test
michael@0 1130
michael@0 1131 PATH_CONTAINS_BIN="TRUE"
michael@0 1132 export PATH_CONTAINS_BIN
michael@0 1133
michael@0 1134 export OBJDIR OS_ARCH LOCALDIST LOCALDIST_BIN DIST PATH
michael@0 1135 }
michael@0 1136
michael@0 1137 ########################### bc #########################################
michael@0 1138 # global shell function , sets paths for the backward compatibility test
michael@0 1139 ########################################################################
michael@0 1140 bc()
michael@0 1141 {
michael@0 1142 if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
michael@0 1143 TESTDIR=${RESULTDIR}
michael@0 1144 BC_ACTION=""
michael@0 1145 DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary
michael@0 1146 return
michael@0 1147 fi
michael@0 1148 DON_T_SET_PATHS="TRUE"
michael@0 1149 case $1 in
michael@0 1150 0)
michael@0 1151 #unset TESTDIR
michael@0 1152 TESTDIR=${RESULTDIR}
michael@0 1153 if [ "$O_WIN" = "ON" -a "$O_CYGNUS" != ON ] ; then
michael@0 1154 PATH="$TESTSCRIPTDIR;$LOCALDIST_BIN;$BASEPATH"
michael@0 1155 else
michael@0 1156 PATH=$TESTSCRIPTDIR:$LOCALDIST_BIN:$BASEPATH
michael@0 1157 fi
michael@0 1158 BC_ACTION=""
michael@0 1159 DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary
michael@0 1160 ;;
michael@0 1161 *)
michael@0 1162 if [ "$O_LOCAL" = "ON" ] ; then
michael@0 1163 Exit "FIXME Can't run backwardcompatibility tests locally yet"
michael@0 1164 fi
michael@0 1165 TESTSCRIPTDIR=${BCDIST}/../security/nss/tests
michael@0 1166 COMMON=${TESTSCRIPTDIR}/common
michael@0 1167 TESTDIR=${RESULTDIR}/bct
michael@0 1168 BC_ACTION="backward compatibility of binaries in $BC_MASTER to new libs"
michael@0 1169 BCDIST_BIN=${BCDIST}/${OBJDIR}/bin
michael@0 1170 LD_LIBRARY_PATH=${LOCALDIST}/${OBJDIR}/lib
michael@0 1171 if [ "$O_WIN" = "ON" ] ; then
michael@0 1172 if [ "$O_CYGNUS" = ON ] ; then
michael@0 1173 PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH:$LD_LIBRARY_PATH
michael@0 1174 else
michael@0 1175 PATH="$TESTSCRIPTDIR;$BCDIST_BIN;$BASEPATH;$LD_LIBRARY_PATH"
michael@0 1176 fi
michael@0 1177 else
michael@0 1178 PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH
michael@0 1179 fi
michael@0 1180 Debug "1st stage of backward compatibility test"
michael@0 1181 ;;
michael@0 1182 esac
michael@0 1183 if [ -n "$TESTDIR" ] ; then
michael@0 1184 if [ ! -d $TESTDIR ] ; then
michael@0 1185 mkdir -p $TESTDIR
michael@0 1186 fi
michael@0 1187 export TESTDIR
michael@0 1188 fi
michael@0 1189 SHLIB_PATH=${LD_LIBRARY_PATH}
michael@0 1190 LIBPATH=${LD_LIBRARY_PATH}
michael@0 1191 Debug "PATH $PATH"
michael@0 1192 Debug "LD_LIBRARY_PATH $LD_LIBRARY_PATH"
michael@0 1193 export PATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH
michael@0 1194 export DON_T_SET_PATHS BC_ACTION
michael@0 1195 export TESTSCRIPTDIR COMMON
michael@0 1196 }
michael@0 1197
michael@0 1198 ########################### Ps #########################################
michael@0 1199 # global shell function , attempts a platform specific ps
michael@0 1200 ########################################################################
michael@0 1201 Ps()
michael@0 1202 {
michael@0 1203 #AIX, OSF ps -ef, solaris /usr/5bin/ps -ef, win ps -ef but no user id
michael@0 1204 #linux ps -ef, HP
michael@0 1205
michael@0 1206 if [ $os_name = "SunOS" ]
michael@0 1207 then
michael@0 1208 /usr/5bin/ps -ef
michael@0 1209 else
michael@0 1210 ps -ef
michael@0 1211 fi
michael@0 1212 }
michael@0 1213
michael@0 1214 ########################### kill_by_name ################################
michael@0 1215 # global shell function , kills the process whose name is given as
michael@0 1216 # parameter
michael@0 1217 ########################################################################
michael@0 1218 kill_by_name()
michael@0 1219 {
michael@0 1220 for PID in `Ps | grep "$1" | grep -v grep | \
michael@0 1221 sed -e "s/^ *//g" -e "s/^[^ ]* //" -e "s/^ *//g" -e "s/ .*//g"`
michael@0 1222 do
michael@0 1223 if [ $O_WIN = "ON" -a $O_CYGNUS = "ON" ]
michael@0 1224 then
michael@0 1225 ask "Do you want to kill Process $PID (`Ps | grep $PID | \
michael@0 1226 grep -v grep | awk '{ print $1, $2, $6, $7, $8, $9 }' | \
michael@0 1227 sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \
michael@0 1228 "y" "n" && {
michael@0 1229 kill $PID
michael@0 1230 sleep 1
michael@0 1231 kill -9 $PID 2>/dev/null
michael@0 1232 }
michael@0 1233 else
michael@0 1234 ask "Do you want to kill Process $PID (`Ps | grep $PID | \
michael@0 1235 grep -v grep | awk '{ print $1, $2, $8, $9, $10, $11 }' | \
michael@0 1236 sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \
michael@0 1237 "y" "n" && {
michael@0 1238 kill $PID
michael@0 1239 sleep 1
michael@0 1240 kill -9 $PID 2>/dev/null
michael@0 1241 }
michael@0 1242 fi
michael@0 1243 done
michael@0 1244 }
michael@0 1245
michael@0 1246 ############################### early_exit ###################################
michael@0 1247 # global shell function , attempts a little more usefull user notification
michael@0 1248 # of a complete failure
michael@0 1249 ########################################################################
michael@0 1250
michael@0 1251 early_exit()
michael@0 1252 {
michael@0 1253 if [ -z "$DOCDIR" ]
michael@0 1254 then
michael@0 1255 DOCDIR=`dirname $0`/../doc
michael@0 1256 fi
michael@0 1257 if [ -f $DOCDIR/QAerror.html ]
michael@0 1258 then
michael@0 1259 Debug "Found QA errorheader"
michael@0 1260 rm ${FILENAME}.err 2>/dev/null
michael@0 1261 cp $DOCDIR/QAerror.html ${FILENAME}.err
michael@0 1262 echo "$1" >>${FILENAME}.err
michael@0 1263 echo '</font></b></h1>' >>${FILENAME}.err
michael@0 1264 if [ -n "$FILENAME" -a -f "$FILENAME" ]
michael@0 1265 then
michael@0 1266 cat $FILENAME | sed -e "s/^/<br>/" >>${FILENAME}.err
michael@0 1267 fi
michael@0 1268 echo '</body></html>' >>${FILENAME}.err
michael@0 1269 cat ${FILENAME}.err | $RMAIL $MAILINGLIST
michael@0 1270
michael@0 1271 rm ${FILENAME}.err 2>/dev/null
michael@0 1272 #echo "cat ${FILENAME}.err | $RMAIL $MAILINGLIST "
michael@0 1273 fi
michael@0 1274 }
michael@0 1275
michael@0 1276 ############################### Exit ###################################
michael@0 1277 # global shell function , central exiting point
michael@0 1278 # cleanup: temporary files, kill the remaining selfservers if sourcing
michael@0 1279 # script sets KILL_SELFSERV
michael@0 1280 ########################################################################
michael@0 1281 Exit()
michael@0 1282 {
michael@0 1283 Echo $1
michael@0 1284 if [ "$O_CRON" = "OFF" ]
michael@0 1285 then
michael@0 1286 echo $1 >&2
michael@0 1287 fi
michael@0 1288 if [ -f "${KILLPIDS}" ]
michael@0 1289 then
michael@0 1290 Debug "Attempting to kill background processes...`cat ${KILLPIDS}`"
michael@0 1291 kill `cat "${KILLPIDS}"`
michael@0 1292 sleep 1
michael@0 1293 kill -9 `cat "${KILLPIDS}"`
michael@0 1294 fi
michael@0 1295 if [ -n "${TMPFILES}" ]
michael@0 1296 then
michael@0 1297 Debug "rm -f ${TMPFILES}"
michael@0 1298 rm -f $TMPFILES 2>/dev/null
michael@0 1299 fi
michael@0 1300 O_ALWAYS_YES=ON # set to non-interactive - don't ask anymore questions here
michael@0 1301 if [ $KILL_SELFSERV = "ON" ]
michael@0 1302 then
michael@0 1303 kill_by_name selfserv
michael@0 1304 fi
michael@0 1305 if [ $O_MAIL_LINK = "ON" -a $O_FILE = "ON" ]
michael@0 1306 then
michael@0 1307 if [ $EARLY_EXIT = TRUE ] #before the report file has been created
michael@0 1308 then
michael@0 1309 early_exit "$1"
michael@0 1310 else
michael@0 1311 head -3 $FILENAME >$ML_FILE
michael@0 1312 echo "Content-Type: text/plain; charset=us-ascii; format=flowed
michael@0 1313 Content-Transfer-Encoding: 7bit
michael@0 1314
michael@0 1315 " >>$ML_FILE
michael@0 1316 echo $HREF_TMP_HTML_FILE >>$ML_FILE
michael@0 1317 cat $ML_FILE | $RMAIL $MAILINGLIST
michael@0 1318 fi
michael@0 1319
michael@0 1320 #FIXME - early exit etc
michael@0 1321 elif [ $O_MAIL = "ON" -a $O_FILE = "ON" ]
michael@0 1322 then
michael@0 1323 if [ $EARLY_EXIT = TRUE ] #before the report file has been created
michael@0 1324 then
michael@0 1325 early_exit "$1"
michael@0 1326 elif [ -n "$FILENAME" -a -f "$FILENAME" ]
michael@0 1327 then
michael@0 1328 cat $FILENAME | $RMAIL $MAILINGLIST
michael@0 1329 fi
michael@0 1330 #rm $FILENAME 2>/dev/null
michael@0 1331 elif [ $O_MAIL = "ON" -a $EARLY_EXIT = TRUE ]
michael@0 1332 then
michael@0 1333 early_exit "$1"
michael@0 1334 rm $FILENAME 2>/dev/null
michael@0 1335 fi
michael@0 1336 #chmod a+rw ${RESULTDIR} ${RESULTDIR}/* ${RESULTDIR}/*/* &
michael@0 1337 if [ -n "$O_TBX" -a "$O_TBX" = "ON" ] ; then
michael@0 1338 rm ${TESTDIR}/QAstatus
michael@0 1339
michael@0 1340 if [ "$1" = "killed... cleaning up..." ] ; then
michael@0 1341 echo "QA killed" >${TESTDIR}/QAstatus
michael@0 1342 elif [ "$TBX_EXIT" = 0 ] ; then
michael@0 1343 echo "QA passed" >${TESTDIR}/QAstatus
michael@0 1344 else
michael@0 1345 echo "QA failed" >${TESTDIR}/QAstatus
michael@0 1346 fi
michael@0 1347
michael@0 1348 exit $TBX_EXIT
michael@0 1349
michael@0 1350 else
michael@0 1351 exit
michael@0 1352 fi
michael@0 1353 }
michael@0 1354
michael@0 1355 trap "rm -f ${TMPFILES} 2>/dev/null; Exit 'killed... cleaning up...'" 2 3 15
michael@0 1356
michael@0 1357 ################################ Wait ##################################
michael@0 1358 # global shell function to wait for an event to happen, 1st parameter
michael@0 1359 # filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait
michael@0 1360 # for it to be created.
michael@0 1361 # uses the variables WAIT_FOR and WAIT_TIMES
michael@0 1362 # WAIT_FOR: if waiting for an event sleep n seconds before rechecking
michael@0 1363 # recomended value 10 minutes 600
michael@0 1364 # WAIT_TIMES: recheck n times before giving up to prevent endless loop
michael@0 1365 # recomended 30 - total of 5h
michael@0 1366 ########################################################################
michael@0 1367
michael@0 1368 Wait()
michael@0 1369 {
michael@0 1370 i=0
michael@0 1371 Debug "Waiting for $1"
michael@0 1372 while [ $i -lt $WAIT_TIMES ]
michael@0 1373 do
michael@0 1374 i=`expr $i + 1`
michael@0 1375 if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to
michael@0 1376 then
michael@0 1377 return
michael@0 1378 fi
michael@0 1379 if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist
michael@0 1380 then
michael@0 1381 return
michael@0 1382 fi
michael@0 1383 Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds zzzz..."
michael@0 1384 sleep $WAIT_FOR
michael@0 1385 done
michael@0 1386 TOTAL=`expr $WAIT_TIMES \* $WAIT_FOR / 60`
michael@0 1387 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 1388 }
michael@0 1389
michael@0 1390 ################################ WaitForever ##################################
michael@0 1391 # global shell function to wait for an event to happen, 1st parameter
michael@0 1392 # filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait
michael@0 1393 # for it to be created.
michael@0 1394 # because we daon't have any relyable cron on NT...
michael@0 1395 ########################################################################
michael@0 1396
michael@0 1397 WaitForever()
michael@0 1398 {
michael@0 1399 i=0
michael@0 1400 Debug "Waiting for $1"
michael@0 1401 TOTAL=0
michael@0 1402 while [ 1 ]
michael@0 1403 do
michael@0 1404 i=`expr $i + 1`
michael@0 1405 if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to
michael@0 1406 then
michael@0 1407 return
michael@0 1408 fi
michael@0 1409 if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist
michael@0 1410 then
michael@0 1411 return
michael@0 1412 fi
michael@0 1413 Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds Total $TOTAL"
michael@0 1414 sleep $WAIT_FOR
michael@0 1415 TOTAL=`expr $i \* $WAIT_FOR / 60`
michael@0 1416 if [ -n "$MAX_FOREVER" ] # we are cheating. Forever can be very short...
michael@0 1417 then
michael@0 1418 if [ "$TOTAL" -gt "$MAX_FOREVER" ]
michael@0 1419 then
michael@0 1420 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 1421 fi
michael@0 1422 fi
michael@0 1423 done
michael@0 1424 }
michael@0 1425 ################################### is_running #########################
michael@0 1426 # global shell function , implements primitive locking mechanism
michael@0 1427 # filename is passed as a parameter, if filename.* exists we assume calling
michael@0 1428 # script is running already and exit, otherwise filename.processid is
michael@0 1429 # created
michael@0 1430 ########################################################################
michael@0 1431 is_running()
michael@0 1432 {
michael@0 1433 Debug "Testing if $0 is already running... file ${1} - ${1}.$$"
michael@0 1434 if [ -f ${1}.* ]
michael@0 1435 then
michael@0 1436 Exit "$0 seems to be running already ($1 exists) - Exiting"
michael@0 1437 fi
michael@0 1438 TMPFILES="$TMPFILES ${1}.$$"
michael@0 1439 echo "running $0 on `date` PID $$" >${1}.$$
michael@0 1440 Debug "wrote \"running $0 on `date` PID $$\" to ${1}.$$"
michael@0 1441
michael@0 1442 }
michael@0 1443
michael@0 1444 #---------------------------# USERCOM #---------------------------------
michael@0 1445 ############################## Echo #####################################
michael@0 1446 # global shell function , depending on the options the output gets written
michael@0 1447 # to a file, or is being discarded
michael@0 1448 # FIXME \n and \c are mistreates by differnet shells, and linux has /bin/echo
michael@0 1449 # instead of /usr/bin/echo
michael@0 1450 ########################################################################
michael@0 1451 Echo ()
michael@0 1452 {
michael@0 1453 if [ $O_SILENT = OFF ]
michael@0 1454 then
michael@0 1455 echo "$*"
michael@0 1456 #/usr/bin/echo "$*"
michael@0 1457 fi
michael@0 1458 if [ $O_FILE = ON ]
michael@0 1459 then
michael@0 1460 echo "$*" >>$FILENAME
michael@0 1461 fi
michael@0 1462 }
michael@0 1463
michael@0 1464 ################################### ask ################################
michael@0 1465 # global shell function, Asks the a question, and gives the returns 0
michael@0 1466 # on the 1st choice, 1 on the 2nd choice
michael@0 1467 #
michael@0 1468 # PARAMETERS:
michael@0 1469 # $1 question text
michael@0 1470 # $2 1st choice
michael@0 1471 # $3 2nd choice
michael@0 1472 #
michael@0 1473 # MODIFIERS:
michael@0 1474 # -y O_ALWAYS_YES will assume a first choice always (not neccessaryly "y")
michael@0 1475 #
michael@0 1476 # RETURN:
michael@0 1477 # 0 - User picked 1st choice
michael@0 1478 # 1 - User picked 2nd choice
michael@0 1479 #
michael@0 1480 # EXAMPLE
michael@0 1481 # ask "Would you like to continue" "y" "n" || Exit
michael@0 1482 # will produce the string "Would you like to continue (y/n) ?",
michael@0 1483 # read input from keyboard (or assume a yes with option -y)
michael@0 1484 # - on a yes it will return 0, on a no it will return 1, the
michael@0 1485 # shell interprets it as error and the || Exit will be executed
michael@0 1486 #
michael@0 1487 # NOTE: NEVER use "n" as the second parameter - it will mess up -y
michael@0 1488 # don't ask "Continue" "n" "y" || Exit # it will Exit on a "y"
michael@0 1489 #
michael@0 1490 ########################################################################
michael@0 1491 Ask()
michael@0 1492 {
michael@0 1493 ask $*
michael@0 1494 }
michael@0 1495
michael@0 1496 ask()
michael@0 1497 {
michael@0 1498 if [ $O_ALWAYS_YES = ON ]
michael@0 1499 then
michael@0 1500 Echo "$1 ($2/$3) ?"
michael@0 1501 Echo "YES!"
michael@0 1502 return 0
michael@0 1503 fi
michael@0 1504 A=""
michael@0 1505 while [ 1 ]
michael@0 1506 do
michael@0 1507
michael@0 1508 Echo "$1 ($2/$3) ?"
michael@0 1509 read A
michael@0 1510 if [ -n "$A" ]
michael@0 1511 then
michael@0 1512 if [ $A = $2 ]
michael@0 1513 then
michael@0 1514 return 0
michael@0 1515 elif [ $A = $3 ]
michael@0 1516 then
michael@0 1517 return 1
michael@0 1518 fi
michael@0 1519 fi
michael@0 1520 done
michael@0 1521 return 0
michael@0 1522 }
michael@0 1523
michael@0 1524 ################################### Warning ############################
michael@0 1525 # global shell function, Asks the user a "... continue? (y/n)" question,
michael@0 1526 # and exits when the user answers with no
michael@0 1527 # NOTE -y will answer the warnings always with yes
michael@0 1528 ########################################################################
michael@0 1529 Warning ()
michael@0 1530 {
michael@0 1531 ask "WARNING: $0: \n $* continue " "y" "n" || Exit
michael@0 1532 }
michael@0 1533
michael@0 1534 ################################### Debug ############################
michael@0 1535 # global shell function, when option -d Debugging output is written
michael@0 1536 ########################################################################
michael@0 1537 Debug()
michael@0 1538 {
michael@0 1539 if [ $O_DEBUG = ON ]
michael@0 1540 then
michael@0 1541 Echo "DEBUG: (`date +%H:%M`) $0: $*"
michael@0 1542 fi
michael@0 1543 }
michael@0 1544
michael@0 1545 ################################### line ###############################
michael@0 1546 # global shell function, supposed to make output more readable...
michael@0 1547 ########################################################################
michael@0 1548 line()
michael@0 1549 {
michael@0 1550 Echo
michael@0 1551 #Echo "======================================================================="
michael@0 1552 #Echo
michael@0 1553 }
michael@0 1554
michael@0 1555 ################################### opt_usage ##########################
michael@0 1556 # global shell function, tells user about available options
michael@0 1557 ########################################################################
michael@0 1558 opt_usage()
michael@0 1559 {
michael@0 1560 if [ $O_OPTIONS = "ON" ]
michael@0 1561 then
michael@0 1562 Echo
michael@0 1563 line
michael@0 1564 Echo
michael@0 1565 Echo " -y answer all questions with y - use at your own risk..."
michael@0 1566 Echo " -s silent (only usefull with -y)"
michael@0 1567 Echo " -h, -? - you guessed right - displays this text"
michael@0 1568 Echo " -d debug"
michael@0 1569 Echo " -f <filename> - write the (error)output to filename"
michael@0 1570 Echo " -fcronfile produces the resultfiles in the same locations"
michael@0 1571 Echo " as would have been produced with -cron"
michael@0 1572 Echo " -m <mailinglist> - send filename to mailinglist (csl "
michael@0 1573 Echo " example sonmi,nelsonb,wtc) only useful with -f"
michael@0 1574 Echo " -ml <mailinglist> - send link to filename to mailinglist "
michael@0 1575 Echo " (csl example sonmi,nelsonb,wtc) only useful with -f"
michael@0 1576 Echo " -cron equivalient to -y -s -d -f \$RESULTDIR/\$HOST.nssqa"
michael@0 1577 Echo " -t run on a tinderbox build (included -cron)"
michael@0 1578 if [ `basename $0` = nssqa ] ; then
michael@0 1579 Echo " -l <mozroot> run on a local build"
michael@0 1580 Echo " -ln <mozroot> copy a networkbuild to a local directory "
michael@0 1581 Echo " mozroot, used for networkindipendend QA "
michael@0 1582 Echo " -lt try to copy a networkbuild to a local directory, if"
michael@0 1583 Echo " not possible run on the network
michael@0 1584 Echo " used for networkindipendend QA
michael@0 1585 fi
michael@0 1586 #
michael@0 1587 # special strings
michael@0 1588 fi
michael@0 1589
michael@0 1590 }
michael@0 1591
michael@0 1592 ################################### glob_usage #########################
michael@0 1593 # global shell function, how to use the calling script (parameters, options)
michael@0 1594 ########################################################################
michael@0 1595 glob_usage()
michael@0 1596 {
michael@0 1597 line
michael@0 1598 Echo $1
michael@0 1599 Echo
michael@0 1600 if [ $O_OPTIONS = "ON" ]
michael@0 1601 then
michael@0 1602 Echo "usage $0 [options] nssversion builddate"
michael@0 1603 else
michael@0 1604 Echo "usage $0 nssversion builddate"
michael@0 1605 fi
michael@0 1606
michael@0 1607 Echo " for example: $0 30b 0926"
michael@0 1608 Echo " $0 31 1002"
michael@0 1609 opt_usage
michael@0 1610 Echo
michael@0 1611 Exit "$1"
michael@0 1612 }
michael@0 1613
michael@0 1614 tell()
michael@0 1615 {
michael@0 1616 if [ $O_SILENT = OFF ]
michael@0 1617 then
michael@0 1618 line
michael@0 1619 pwd
michael@0 1620 ls -CF
michael@0 1621 line
michael@0 1622 fi
michael@0 1623 if [ $O_FILE = ON ]
michael@0 1624 then
michael@0 1625 line
michael@0 1626 pwd >>$FILENAME
michael@0 1627 ls -CF >>$FILENAME
michael@0 1628 line
michael@0 1629 fi
michael@0 1630 }
michael@0 1631
michael@0 1632 if [ $O_INIT = "ON" ]
michael@0 1633 then
michael@0 1634 glob_init $*
michael@0 1635 fi
michael@0 1636 EARLY_EXIT=FALSE

mercurial