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