3
########################################################################
5
# /u/sonmi/bin/header - /u/svbld/bin/init/nss/header
7
# variables, utilities and shellfunctions global to NSS QA
8
# needs to work on all Unix platforms
10
# included from (don't expect this to be up to date)
11
# --------------------------------------------------
18
# nssversion (supported: 30b, 31, 332, tip 32)
19
# builddate (default - today)
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
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
32
# -ml <mailinglist> - send link to filename to mailinglist (csl)
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
41
# used for networkindipendend QA
45
# FIXME ... known problems, search for this string
46
# NOTE .... unexpected behavior
54
# FIXME - split in init / usercom / utils
56
########################################################################
58
#------------------------------# INIT #------------------------------
60
# below the option flags get initialized
62
if [ -z "$QASCRIPT_DIR" ]
64
QASCRIPT_DIR=`dirname $0`
65
if [ "$QASCRIPT_DIR" = '.' ]
73
if [ -z "$O_ALWAYS_YES" ] ; then
74
O_ALWAYS_YES=OFF # turned on by -y answer all questions with y
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
81
if [ -z "$O_PARAM" ] # header is global, some including scripts may not
82
then # require parameters, the others don't need to bother
85
if [ -z "$O_OPTIONS" ] # header is global, some including scripts may not
86
then # permit options, they don't need to bother
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
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
106
DOMSUF=red.iplanet.com
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
118
if [ -z "$QAYEAR" ] # may I introduce - the y2k+1 bug? QA for last year
119
then # might not work
134
echo "Can't write to tmp directory $TMP - exiting"
135
echo "Can't write to tmp directory $TMP - exiting" >&2
139
KILLPIDS="$TMP/killpids.$$"
141
TMPFILES="$TMPFILES $KILLPIDS"
143
KILL_SELFSERV=OFF # if sourcing script sets this to on cleanup will also
144
# kill the running selfserv processes
146
# Set the masterbuilds
147
if [ -z "$UX_MASTERBUILD" ]
149
UX_MASTERBUILD=booboo_Solaris8
150
#if [ ! -d $UX_MASTERBUILD ] ; then
151
#UX_MASTERBUILD=booboo_Solaris8_forte6
157
if [ -z "$NT_MASTERBUILD" ]
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
165
if [ -z "$MASTERBUILD" ]
167
MASTERBUILD=$UX_MASTERBUILD
170
# Set the default build
171
if [ -z "$BUILDNUMBER" ]
176
O_LDIR=OFF #local QA dir for NT, temporary
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
184
# NOTE: following variables have to change
185
# from release to release
186
if [ -z "$BC_MASTER" ] # master directory for backwardscompatibility testing
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"
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
197
BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
198
BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
200
BC_MASTER=$BC_UX_MASTER
201
BC_MASTER_WAS_SET=FALSE
203
BC_MASTER_WAS_SET=TRUE
208
EARLY_EXIT=TRUE #before the report file has been created, causes Exit to
211
UX_D0=/share/builds/mccrel3/nss
213
################################### glob_init ##########################
214
# global shell function, main initialisation function
215
########################################################################
218
if [ $O_PARAM = "ON" ] ; then
219
eval_opts $* # parse parameters and options - set flags
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"
232
################################### init_vars ###########################
233
# global shell function, sets the environment variables, part of init
234
########################################################################
250
LOGNAME=`basename $HOME`
256
Exit "Can't determine current user"
261
HWACC_LIST="rainbow ncipher"
262
#MODUTIL="-add rainbow -libfile /usr/lib/libcryptoki22.so"
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
########################################################################
278
########################## find_nt_masterbuild #########################
279
# global shell function, sets the nt masterbuild directories, part of init
280
########################################################################
281
find_nt_masterbuild()
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}
291
Debug "NT_MASTERDIR $NT_MASTERDIR"
294
################################### set_daily_build_dirs ###########################
295
# global shell function, sets directories
296
########################################################################
297
set_daily_build_dirs()
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"
308
DAILY_BUILD=${NSS_VER_DIR}/builds/${QAYEAR}${BUILDDATE}.${BUILDNUMBER}
309
LOCALDIST=${DAILY_BUILD}/${MASTERBUILD}/mozilla/dist
317
#OSF1) has been done already - always 64 bit
320
IS_64=`(isainfo -v | grep 64)>/dev/null 2>/dev/null && echo 64 bit`
321
if [ "$O_TBX" = "OFF" ] ; then
324
then #Wait for the 64 bit build to finish...
325
Debug Testing build for $MAPPED_OS in $OSDIR
326
Wait ${OSDIR}/SVbuild.InProgress.1 0
331
IS_64=`lslpp -l | grep "bos.64bit"> /dev/null && echo 64 bit`
334
IS_64=`getconf KERNEL_BITS | grep 64 >/dev/null && echo 64 bit`
337
Debug "Mapped OS to $MAPPED_OS"
342
################################### copy_to_local ########################
343
# global shell function, copies the necessary directories from the
344
# daily build aerea to the local disk
345
########################################################################
348
Debug "Copy network directories to local directories"
350
if [ ! -d ${LOCAL_MOZROOT}/dist ] ; then
351
mkdir -p ${LOCAL_MOZROOT}/dist || C2L_ERROR=1
353
if [ ! -d ${LOCAL_MOZROOT}/security/nss ] ; then
354
mkdir -p ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=2
356
if [ $C2L_ERROR != 0 ] ; then
357
Exit "copy_to_local: Can t make necesssary directories ($C2L_ERROR ) "
359
if [ ! -d ${LOCAL_MOZROOT}/security/nss/tests ] ; then
360
cp -r ${TESTSCRIPTDIR} ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=1
362
if [ ! -d ${LOCAL_MOZROOT}/security/coreconf ] ; then
363
cp -r ${MOZILLA_ROOT}/security/coreconf ${LOCAL_MOZROOT}/security || C2L_ERROR=2
367
if [ "$O_WIN" = "ON" ] ; then
368
OS_TARGET=WINNT;export OS_TARGET
370
unset BUILD_OPT;export BUILD_OPT;
371
unset USE_64;export USE_64;
372
#FIXME only tested on 64 bit Solaris and only got 32 bit builds
373
while [ $NO_DIRS -lt 4 ] ; do
374
# first time thru: Debug 32 bit NT
376
Debug "Copying ${OBJDIR}..."
377
if [ ! -d ${LOCAL_MOZROOT}/dist/${OBJDIR} ] ; then
378
cp -r ${LOCALDIST}/${OBJDIR} ${LOCAL_MOZROOT}/dist || C2L_ERROR=3
380
NO_DIRS=`expr $NO_DIRS + 1`
381
if [ $NO_DIRS = 1 ] ; then # 2nd time: OPT 32 bit NT
382
BUILD_OPT=1; export BUILD_OPT;
383
elif [ $NO_DIRS = 2 ] ; then # 3rd time: OPT, either 64 bit or Win95 or force exit
384
if [ "$O_WIN" = "ON" ] ; then
385
OS_TARGET=WIN95;export OS_TARGET
388
if [ -z "$IS_64" ] ; then #32 bit platform
391
USE_64=1; export USE_64
394
elif [ $NO_DIRS = 3 ] ; then # 4th time: Debug either 64 bit or Win95
395
unset BUILD_OPT;export BUILD_OPT;
400
if [ $C2L_ERROR != 0 ] ; then
401
Exit "copy_to_local: Can t copy necesssary directories ($C2L_ERROR ) "
406
O_LN=OFF #from here on pretend it is regular -l local QA FIXME, might cause
407
#problems with the backwardcompatibility tests
408
Debug "Successfully copied network directories to local directories"
411
################################### local_dirs ###########################
412
# global shell function, sets the directories for local QA
413
########################################################################
416
Debug "Set directories for local QA"
417
#if [ "$O_WIN" = "ON" ] ; then
420
NSS_VER_DIR=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are
421
# set to the LOCAL_MOZROOT, since it is not sure
422
# if ../../../.. (NSS_VER_DIR) even exists
423
if [ -z "${RESULTDIR}" ] ; then # needs to be local as well
424
Debug "Setting RESULTDIR for local QA"
425
RESULTDIR="${LOCAL_MOZROOT}/tests_results/security/${HOST}-`date +%Y%m%d-%H.%M`"
428
UX_MASTERDIR=`dirname ${LOCAL_MOZROOT}`
429
NT_MASTERDIR=$UX_MASTERDIR
430
MOZILLA_ROOT=${LOCAL_MOZROOT}
432
UXDIST=${MOZILLA_ROOT}/dist
435
if [ -z "${TESTDIR}" ] ; then
436
Debug "Setting TESTDIR for local QA"
439
if [ -n "$TESTDIR" ] ; then
440
if [ ! -d $TESTDIR ] ; then
441
Debug "Making TESTDIR for local QA"
446
Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
448
TESTSCRIPTDIR=${LOCAL_MOZROOT}/security/nss/tests
449
COMMON=${TESTSCRIPTDIR}/common
457
################################### tbx_dirs ###########################
458
# global shell function, sets the directories for tinderbox QA
459
########################################################################
462
Debug "Set directories for tinderbox"
463
if [ "$O_WIN" = "ON" ] ; then
464
win_set_d1 # we need the NSS_VER_DIR later
466
NSS_VER_DIR="$UX_D0"/nss$NSSVER
468
if [ -z "${RESULTDIR}" ] ; then # needs to be different for tinderbox
469
Debug "Setting RESULTDIR for tinderbox"
471
echo $QASCRIPT_DIR | grep 64 >/dev/null && TBX_NOBITS=64
472
TRD="${HOST}${TBX_NOBITS}-`date +%Y%m%d-%H.%M`"
473
RESULTDIR="${NSS_VER_DIR}/tinderbox/tests_results/security/${TRD}"
474
if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
475
URL="sbs-rel.nscp.aoltw.net"
477
URL="cindercone.red.iplanet.com"
479
if [ "$O_WIN" = "ON" ] ; then
480
RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${UX_D0}/nsstip/tinderbox/tests_results/security/${TRD}\">QA</a>"
482
RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${RESULTDIR}\">QA</a>"
484
Debug "RESULTDIRURL TinderboxPrint:$RESULTDIRURL"
486
TBX_DAILY_BUILD=`cd ../../../../..;pwd`
487
NSS_VER_DIR="${TBX_DAILY_BUILD}/../.."
488
TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tinderbox | sed -e 's/ .*//g'`
489
if [ -z "$TBX_LOGFILE_DIR" ] ; then
490
TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tbx | sed -e 's/ .*//g'`
491
TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tbx/${TBX_LOGFILE_DIR}"
493
TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tinderbox/${TBX_LOGFILE_DIR}"
495
Debug "Set TBX_LOGFILE_DIR ${TBX_LOGFILE_DIR}"
498
UX_MASTERDIR=`cd ../../../..;pwd`
499
NT_MASTERDIR=$UX_MASTERDIR
500
MOZILLA_ROOT=$UX_MASTERDIR/mozilla
502
UXDIST=${MOZILLA_ROOT}/dist
505
if [ -z "${TESTDIR}" ] ; then
506
Debug "Setting TESTDIR for tinderbox"
509
if [ -n "$TESTDIR" ] ; then
510
if [ ! -d $TESTDIR ] ; then
511
Debug "Making TESTDIR for tinderbox"
515
Debug "Making QAstatus file"
516
echo "QA running" >${TESTDIR}/QAstatus
518
Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
521
COMMON=${TESTSCRIPTDIR}/common
528
################################### init_mcom ###########################
529
# global shell function, sets domain specific variables for AOL's
530
# domains according to Bishakha's instructions
531
########################################################################
534
Debug "Running in mcom or netscape domain - changing directories..."
535
if [ "${UX_MB_WAS_SET}" = "FALSE" ] ; then #in case it was set
536
# before script was called use these values
537
UX_MASTERBUILD=spd04_Solaris8
539
if [ "${NT_MB_WAS_SET}" = "FALSE" ] ; then
540
NT_MASTERBUILD=spd06_NT4
543
MASTERBUILD=$UX_MASTERBUILD
544
if [ "${BC_MASTER_WAS_SET}" = "FALSE" ] ; then
545
BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
546
BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
547
BC_MASTER=$BC_UX_MASTER
549
UX_D0=/share/builds/sbsrel2/nss
550
URL="sbs-rel.nscp.aoltw.net"
552
################################### init_dirs ###########################
553
# global shell function, sets the directories for standard QA
554
# calls special functions for tinderbox, windows or local QA, part of init
555
########################################################################
558
if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
561
if [ $O_WIN = "ON" ] ; then
564
MASTERBUILD=$NT_MASTERBUILD
565
BC_MASTER=$BC_NT_MASTER
567
if [ "$O_LOCAL" = "ON" -a $O_LN = "OFF" ] ; then # if it is a LN we need to know
568
# all the directories off the network first to copy them
569
local_dirs # O_LOCAL alone assumes that all the directories are already there
571
elif [ "$O_TBX" = "ON" ] ; then
574
elif [ "$O_WIN" = "ON" ] ; then
577
NSS_VER_DIR="$UX_D0"/nss$NSSVER
583
if [ -z "${BCDIST}" ] ; then
584
#BCDIST=/share/builds/mccrel3/nss/${BC_MASTER}/mozilla/dist
585
BCDIST=${NSS_VER_DIR}/../${BC_MASTER}/mozilla/dist
586
if [ ! -d $BCDIST -a `basename $0` != jssqa ] ; then
587
ask "Backward compatibility directory $BCDIST does not exist, continue" "y" "n" || Exit
591
UX_MASTERDIR=${DAILY_BUILD}/${UX_MASTERBUILD}
594
if [ "$O_WIN" = "ON" ]
596
MOZILLA_ROOT=${NT_MASTERDIR}/mozilla
598
MOZILLA_ROOT=${UX_MASTERDIR}/mozilla
601
UXDIST=${UX_MASTERDIR}/mozilla/dist
602
NTDIST=${NT_MASTERDIR}/mozilla/dist
604
if [ -z "${RESULTDIR}" ] ; then
605
RESULTDIR=${UX_MASTERDIR}/mozilla/tests_results/security
608
if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
610
if [ "$O_WIN" = "ON" ] ; then
611
JSS_NSS_SRC_DIR=$JSS_NSS_NT_SRC_DIR
613
TESTSCRIPTDIR=${NSS_VER_DIR}/../${JSS_NSS_SRC_DIR}/mozilla/security/nss/tests
615
TESTSCRIPTDIR=${MOZILLA_ROOT}/security/nss/tests
618
if [ ! -d $TESTSCRIPTDIR -a `basename $0` != jssqa ] ; then
619
if [ "$O_WIN" = "ON" -a "$WIN_WAIT_FOREVER" = "ON" ]
621
WaitForever $TESTSCRIPTDIR/all.sh 1
623
Exit "Test directory $TESTSCRIPTDIR does not exist"
627
COMMON=${TESTSCRIPTDIR}/common
628
if [ "$O_LOCAL" = "ON" -a $O_LN = "ON" ] ; then # if it is a LN we need to know
629
# all the directories off the network first to copy them
643
Debug "NTDIST $NTDIST"
644
Debug "UXDIST $UXDIST"
645
Debug "TESTSCRIPTDIR $TESTSCRIPTDIR"
646
Debug "RESULTDIR $RESULTDIR"
648
Debug "LOCALDIST_BIN $LOCALDIST_BIN"
649
Debug "COMMON $COMMON"
650
Debug "MOZILLA_ROOT $MOZILLA_ROOT"
651
Debug "BCDIST $BCDIST"
656
export NSS_VER_DIR DAILY_BUILD NTDIST UXDIST RESULTDIR TESTSCRIPTDIR BCDIST
657
export UX_MASTERDIR NT_MASTERDIR COMMON MOZILLA_ROOT
662
OSDIR=${DAILY_BUILD}/*${MAPPED_OS}*
665
################################### init_files ###########################
666
# global shell function, sets filenames, initializes files, part of init
667
########################################################################
670
if [ $O_CRONFILE = "ON" ]
672
Debug "attempting to create resultfiles"
673
if [ "$O_TBX" = "ON" ] ; then
674
NEWFILENAME=${TBX_LOGFILE_DIR}/qa.log
675
if [ ! -w ${TBX_LOGFILE_DIR} ] ; then
676
Exit "can't touch $NEWFILENAME"
679
NEWFILENAME=$RESULTDIR/$HOST.`basename $0`
681
if [ ! -d $RESULTDIR ]
683
mkdir -p $RESULTDIR || Exit "Error: can't make $RESULTDIR"
685
if [ ! -w $RESULTDIR ] ; then
686
Exit "can't touch $NEWFILENAME"
688
Debug "About to touch $NEWFILENAME "
689
touch $NEWFILENAME || Exit "Error: can't touch $NEWFILENAME"
690
if [ "$O_TBX" = "ON" ] ; then
691
echo "QA results in $RESULTDIR" >>$NEWFILENAME || Exit "Error: can't write to $NEWFILENAME"
693
Debug "About to cat $FILENAME >>$NEWFILENAME "
694
cat $FILENAME >>$NEWFILENAME || Exit "Error: can't append $FILENAME to $NEWFILENAME"
695
TMPFILES="$TMPFILES $FILENAME"
696
FILENAME=$NEWFILENAME
697
Debug "Writing output to $FILENAME"
702
################################### write_to_tmpfile ##########################
703
# global shell function, for NT and cron operation, first a tmpfile
704
# needs to be created
705
########################################################################
710
FILENAME=${TMP}/nsstmp.$$ # for now write to the temporary file
711
# since we don't know the hostname yet
712
# will be inserted to the real file later
713
TMPFILES="$TMPFILES nsstmp.$$"
714
touch $FILENAME || Exit "Error: can't touch $FILENAME"
715
Debug "Writing output to $FILENAME"
718
############################# turn_on_cronoptions ######################
719
# global shell function, turns on options needed for cron and tinderbox
720
########################################################################
721
turn_on_cronoptions()
725
O_DEBUG=ON # FIXME take out!
730
########################## test_mozroot ##########################
731
# global shell function, determines if the variable LOCAL_MOZROOT is set,
732
# and is usable as mozilla root diretory for a local QA
733
###################################################################
737
Debug "LOCAL_MOZROOT = $LOCAL_MOZROOT"
738
case "$LOCAL_MOZROOT" in
740
glob_usage "Error: -"$1" requires a directoryname to follow (start with a letter) "
743
LOCAL_MOZROOT=`dirname $PWD`
749
LOCAL_MOZROOT=`echo $LOCAL_MOZROOT | sed -e "s/^\.//"`
750
LOCAL_MOZROOT="${PWD}${LOCAL_MOZROOT}"
753
LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
758
LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
761
glob_usage "Error: -"$1" requires a directoryname to follow"
764
Debug "Reformated MOZROOT to $LOCAL_MOZROOT"
765
if [ "$1" = "ln" ] ; then
766
LOCAL_MOZROOT_PARENT=`dirname $LOCAL_MOZROOT`
767
if [ ! -d $LOCAL_MOZROOT_PARENT -o ! -w $LOCAL_MOZROOT_PARENT -o \
768
! -x $LOCAL_MOZROOT_PARENT ] ; then
769
Exit "Error: Can't create $LOCAL_MOZROOT (permissions)"
771
if [ ! -d "$LOCAL_MOZROOT" ] ; then
772
mkdir $LOCAL_MOZROOT ||
773
Exit "Error: Can't create mozroot $LOCAL_MOZROOT (mkdir failed)"
775
ask "mozroot $LOCAL_MOZROOT exists - continue (y will remove dir) ?" \
777
rm -rf $LOCAL_MOZROOT/dist $LOCAL_MOZROOT/security $LOCAL_MOZROOT/tests_results ||
778
Exit "Error: Can't clean mozroot $LOCAL_MOZROOT"
781
if [ ! -d "$LOCAL_MOZROOT" ] ; then
782
glob_usage "Error: mozilla root $LOCAL_MOZROOT not a valid directory"
786
################################### eval_opts ##########################
787
# global shell function, evapuates options and parameters, sets flags
788
# variables and defaults
789
########################################################################
801
O_SILENT=OFF #FIXME debug only
807
Debug "Option -y dedectet"
818
if [ -z "$MAILINGLIST" ]
820
glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
822
Debug "Sending link to result to $MAILINGLIST"
828
if [ -z "$MAILINGLIST" ]
830
glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
832
Debug "Sending result to $MAILINGLIST"
834
-fcron*|-F[Cc][Rr][Oo][Nn]*)
841
if [ -z "$FILENAME" ]
843
glob_usage "Error: -f requires a filename to follow"
845
#rm -f $FILENAME 2>/dev/null
846
touch $FILENAME || Exit "Error: can't touch $FILENAME"
847
#NOTE we append rather that creating
848
Debug "Writing output to $FILENAME"
854
if [ `basename $0` != nssqa ] ; then
855
glob_usage "Error: Can't handle option $1"
864
if [ `basename $0` != nssqa ] ; then
865
glob_usage "Error: Can't handle option $1"
871
if [ `basename $0` != nssqa ] ; then
872
glob_usage "Error: Can't handle option $1"
885
glob_usage "Error: Can't handle option $1"
889
if [ -z "$NSSVER" ] ; then
890
glob_usage "Error: illegal parameter"
893
[01][0-9][0123][0-9])
895
if [ -z "$BUILDDATE" ] ; then
896
glob_usage "Error: illegal parameter"
900
glob_usage "Error: Can't handle parameter $1"
906
if [ -z "$PORT" -a "$O_TBX" = "ON" ] ; then
909
if [ -z "$NSSVER" ] ; then
911
Debug "NSS Version: Parameters missing - defaulting to tip!"
913
elif [ -z "$NSSVER" ] ; then
915
Debug "NSS Version: Parameters missing - defaulting to tip!"
917
if [ -z "$BUILDDATE" ] ; then
918
BUILDDATE=`date +%m%d`
919
Debug "Builddate: Parameters missing - defaulting to today!"
922
Debug "Builddate $BUILDDATE NssVersion $NSSVER"
923
export BUILDDATE NSSVER
924
export O_CRON O_SILENT O_DEBUG O_ALWAYS_YES O_TBX
929
TMP=`echo "$TMP" | sed -e 's/ /\/t/g' -e 's//\/b/' -e 's/\\\/\//g'`
930
Debug "TMP reformated to $TMP"
933
######################### win_set_d1 ################################
934
# global shell function, interactively finds the directories in case
935
# windows can't get to the default
936
########################################################################
939
Debug "set Windows Directories..."
941
if [ "$O_CYGNUS" = ON ]
943
NSS_VER_DIR=/cygdrive/w/nss/nss$NSSVER
945
NSS_VER_DIR=w:/nss/nss$NSSVER
947
if [ ! -w $NSS_VER_DIR ]
949
Echo "Windows special... can't write in $NSS_VER_DIR"
950
if [ "$O_CYGNUS" = ON ]
952
NSS_VER_DIR=/cygdrive/u/nss/nss$NSSVER
954
NSS_VER_DIR="u:/nss/nss$NSSVER"
957
Debug "NSS_VER_DIR set to $NSS_VER_DIR"
961
while [ ! -w $NSS_VER_DIR ]
963
if [ "$O_CRONFILE" = "ON" ]
965
Exit "cant write in $NSS_VER_DIR"
967
Warning "cant write in $NSS_VER_DIR"
968
Echo "input start directory (u:/nss, d:/src/nss, f:/shared/nss) "
972
NSS_VER_DIR=$D/nss$NSSVER
975
Debug "NSS_VER_DIR set to $NSS_VER_DIR"
978
########################### init_host ##################################
979
# global shell function, sets required variables HOST and DOMSUF, and asks
980
# the user if it has been set right
981
########################################################################
988
if [ `basename $0` != nssqa ] ; then
994
if [ $DS_WAS_SET = FALSE ] #give chance to overwrite, espec. for NT
996
Debug "Domainname was not set..."
997
DOMSUF=`domainname 2>/dev/null`
1000
Debug "domainname command did not work ..."
1001
DOMSUF=`echo $HOST | grep '\.' | sed -e "s/[^\.]*\.//"`
1005
Debug "Domainname not part of the hostname"
1006
DOMSUF=`cat /etc/defaultdomain 2>/dev/null`
1009
Debug "Domainname needs to be hardcoded to red.iplanet.com"
1010
DOMSUF="red.iplanet.com"
1017
Debug "HOSTNAME $HOST contains Dot"
1018
HOST=`echo $HOST | sed -e "s/\..*//"`
1026
Debug "HOSTNAME $HOST contains Dot"
1027
HOST=`echo $HOST | sed -e "s/\..*//"`
1031
if [ $O_DEBUG = "ON" ]
1033
while [ $init_host_done -eq 0 ]
1036
ask "DOMSUF=$DOMSUF, HOST=$HOST - OK", "y" "n" &&
1038
if [ $init_host_done -eq 0 ]
1040
Echo "input DOMSUF: "
1056
Debug "HOST: $HOST, DOMSUF: $DOMSUF"
1059
#-----------------------------# UTILS #----------------------------------
1061
########################### qa_stat_get_sysinfo ########################
1062
# local shell function, tries to determine the QA operating system
1063
########################################################################
1064
qa_stat_get_sysinfo()
1068
GET_SYSINFO="rsh $1"
1074
QA_SYS=`$GET_SYSINFO uname -sr`
1075
echo $QA_SYS | grep Linux >/dev/null &&
1076
QA_RHVER=`$GET_SYSINFO cat /etc/redhat-release`
1077
if [ -n "$QA_RHVER" ]
1079
QA_OS=`echo $REM_SYS $QA_RHVER | sed -e "s/Red Hat /RH /" \
1084
ISAINFO=`$GET_SYSINFO isainfo -v`
1085
IS_64=`echo $ISAINFO | grep 64 >/dev/null && \
1087
IS_I386=`echo $ISAINFO | grep i386 >/dev/null && \
1089
if [ -n "$IS_I386" ] ; then IS_64="$IS_I386"; fi;
1090
if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
1093
IS_64=`$GET_SYSINFO getconf KERNEL_BITS |
1094
grep 64 >/dev/null && echo 64 bit`
1095
if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
1098
IS_64=`$GET_SYSINFO lslpp -l |
1099
grep "bos.64bit"> /dev/null && echo 64 bit`
1100
if [ -z "$IS_64" ] ; then IS_64="32 bit"; fi;
1103
QA_OS=`echo "$REM_SYS $QA_SYS $IS_64"`
1105
if [ "$O_SILENT" != ON ] ; then
1108
QA_OS_STRING=`echo $QA_OS | sed -e "s/^[_ ]//" -e "s/ /_/g"`
1111
################################### set_objdir #########################
1112
# global shell function, sets the object directories and DIST
1113
########################################################################
1116
Debug "set object dir"
1117
OBJDIR=`cd ${TESTSCRIPTDIR}/common; gmake objdir_name`
1118
OS_ARCH=`cd ${TESTSCRIPTDIR}/common; gmake os_arch`
1120
#at this point $MASTERBUILD needs to be either NT or unix
1122
set_daily_build_dirs
1123
LOCALDIST_BIN=${LOCALDIST}/${OBJDIR}/bin
1126
if [ -z "${TEST_LEVEL}" ] ; then
1129
bc ${TEST_LEVEL} #set the path for the backward compatibility test
1131
PATH_CONTAINS_BIN="TRUE"
1132
export PATH_CONTAINS_BIN
1134
export OBJDIR OS_ARCH LOCALDIST LOCALDIST_BIN DIST PATH
1137
########################### bc #########################################
1138
# global shell function , sets paths for the backward compatibility test
1139
########################################################################
1142
if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
1143
TESTDIR=${RESULTDIR}
1145
DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary
1148
DON_T_SET_PATHS="TRUE"
1152
TESTDIR=${RESULTDIR}
1153
if [ "$O_WIN" = "ON" -a "$O_CYGNUS" != ON ] ; then
1154
PATH="$TESTSCRIPTDIR;$LOCALDIST_BIN;$BASEPATH"
1156
PATH=$TESTSCRIPTDIR:$LOCALDIST_BIN:$BASEPATH
1159
DON_T_SET_PATHS="FALSE" #let init.sh override - FIXME - check if necessary
1162
if [ "$O_LOCAL" = "ON" ] ; then
1163
Exit "FIXME Can't run backwardcompatibility tests locally yet"
1165
TESTSCRIPTDIR=${BCDIST}/../security/nss/tests
1166
COMMON=${TESTSCRIPTDIR}/common
1167
TESTDIR=${RESULTDIR}/bct
1168
BC_ACTION="backward compatibility of binaries in $BC_MASTER to new libs"
1169
BCDIST_BIN=${BCDIST}/${OBJDIR}/bin
1170
LD_LIBRARY_PATH=${LOCALDIST}/${OBJDIR}/lib
1171
if [ "$O_WIN" = "ON" ] ; then
1172
if [ "$O_CYGNUS" = ON ] ; then
1173
PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH:$LD_LIBRARY_PATH
1175
PATH="$TESTSCRIPTDIR;$BCDIST_BIN;$BASEPATH;$LD_LIBRARY_PATH"
1178
PATH=$TESTSCRIPTDIR:$BCDIST_BIN:$BASEPATH
1180
Debug "1st stage of backward compatibility test"
1183
if [ -n "$TESTDIR" ] ; then
1184
if [ ! -d $TESTDIR ] ; then
1189
SHLIB_PATH=${LD_LIBRARY_PATH}
1190
LIBPATH=${LD_LIBRARY_PATH}
1192
Debug "LD_LIBRARY_PATH $LD_LIBRARY_PATH"
1193
export PATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH
1194
export DON_T_SET_PATHS BC_ACTION
1195
export TESTSCRIPTDIR COMMON
1198
########################### Ps #########################################
1199
# global shell function , attempts a platform specific ps
1200
########################################################################
1203
#AIX, OSF ps -ef, solaris /usr/5bin/ps -ef, win ps -ef but no user id
1206
if [ $os_name = "SunOS" ]
1214
########################### kill_by_name ################################
1215
# global shell function , kills the process whose name is given as
1217
########################################################################
1220
for PID in `Ps | grep "$1" | grep -v grep | \
1221
sed -e "s/^ *//g" -e "s/^[^ ]* //" -e "s/^ *//g" -e "s/ .*//g"`
1223
if [ $O_WIN = "ON" -a $O_CYGNUS = "ON" ]
1225
ask "Do you want to kill Process $PID (`Ps | grep $PID | \
1226
grep -v grep | awk '{ print $1, $2, $6, $7, $8, $9 }' | \
1227
sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \
1231
kill -9 $PID 2>/dev/null
1234
ask "Do you want to kill Process $PID (`Ps | grep $PID | \
1235
grep -v grep | awk '{ print $1, $2, $8, $9, $10, $11 }' | \
1236
sed -e "s/[0-9]:[0-6][0-9]//g" | grep $PID `)" \
1240
kill -9 $PID 2>/dev/null
1246
############################### early_exit ###################################
1247
# global shell function , attempts a little more usefull user notification
1248
# of a complete failure
1249
########################################################################
1255
DOCDIR=`dirname $0`/../doc
1257
if [ -f $DOCDIR/QAerror.html ]
1259
Debug "Found QA errorheader"
1260
rm ${FILENAME}.err 2>/dev/null
1261
cp $DOCDIR/QAerror.html ${FILENAME}.err
1262
echo "$1" >>${FILENAME}.err
1263
echo '</font></b></h1>' >>${FILENAME}.err
1264
if [ -n "$FILENAME" -a -f "$FILENAME" ]
1266
cat $FILENAME | sed -e "s/^/<br>/" >>${FILENAME}.err
1268
echo '</body></html>' >>${FILENAME}.err
1269
cat ${FILENAME}.err | $RMAIL $MAILINGLIST
1271
rm ${FILENAME}.err 2>/dev/null
1272
#echo "cat ${FILENAME}.err | $RMAIL $MAILINGLIST "
1276
############################### Exit ###################################
1277
# global shell function , central exiting point
1278
# cleanup: temporary files, kill the remaining selfservers if sourcing
1279
# script sets KILL_SELFSERV
1280
########################################################################
1284
if [ "$O_CRON" = "OFF" ]
1288
if [ -f "${KILLPIDS}" ]
1290
Debug "Attempting to kill background processes...`cat ${KILLPIDS}`"
1291
kill `cat "${KILLPIDS}"`
1293
kill -9 `cat "${KILLPIDS}"`
1295
if [ -n "${TMPFILES}" ]
1297
Debug "rm -f ${TMPFILES}"
1298
rm -f $TMPFILES 2>/dev/null
1300
O_ALWAYS_YES=ON # set to non-interactive - don't ask anymore questions here
1301
if [ $KILL_SELFSERV = "ON" ]
1303
kill_by_name selfserv
1305
if [ $O_MAIL_LINK = "ON" -a $O_FILE = "ON" ]
1307
if [ $EARLY_EXIT = TRUE ] #before the report file has been created
1311
head -3 $FILENAME >$ML_FILE
1312
echo "Content-Type: text/plain; charset=us-ascii; format=flowed
1313
Content-Transfer-Encoding: 7bit
1316
echo $HREF_TMP_HTML_FILE >>$ML_FILE
1317
cat $ML_FILE | $RMAIL $MAILINGLIST
1320
#FIXME - early exit etc
1321
elif [ $O_MAIL = "ON" -a $O_FILE = "ON" ]
1323
if [ $EARLY_EXIT = TRUE ] #before the report file has been created
1326
elif [ -n "$FILENAME" -a -f "$FILENAME" ]
1328
cat $FILENAME | $RMAIL $MAILINGLIST
1330
#rm $FILENAME 2>/dev/null
1331
elif [ $O_MAIL = "ON" -a $EARLY_EXIT = TRUE ]
1334
rm $FILENAME 2>/dev/null
1336
#chmod a+rw ${RESULTDIR} ${RESULTDIR}/* ${RESULTDIR}/*/* &
1337
if [ -n "$O_TBX" -a "$O_TBX" = "ON" ] ; then
1338
rm ${TESTDIR}/QAstatus
1340
if [ "$1" = "killed... cleaning up..." ] ; then
1341
echo "QA killed" >${TESTDIR}/QAstatus
1342
elif [ "$TBX_EXIT" = 0 ] ; then
1343
echo "QA passed" >${TESTDIR}/QAstatus
1345
echo "QA failed" >${TESTDIR}/QAstatus
1355
trap "rm -f ${TMPFILES} 2>/dev/null; Exit 'killed... cleaning up...'" 2 3 15
1357
################################ Wait ##################################
1358
# global shell function to wait for an event to happen, 1st parameter
1359
# filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait
1360
# for it to be created.
1361
# uses the variables WAIT_FOR and WAIT_TIMES
1362
# WAIT_FOR: if waiting for an event sleep n seconds before rechecking
1363
# recomended value 10 minutes 600
1364
# WAIT_TIMES: recheck n times before giving up to prevent endless loop
1365
# recomended 30 - total of 5h
1366
########################################################################
1371
Debug "Waiting for $1"
1372
while [ $i -lt $WAIT_TIMES ]
1375
if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to
1379
if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist
1383
Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds zzzz..."
1386
TOTAL=`expr $WAIT_TIMES \* $WAIT_FOR / 60`
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... "
1390
################################ WaitForever ##################################
1391
# global shell function to wait for an event to happen, 1st parameter
1392
# filename to watch, 2nd parameter 0 - wait for it to disappear, 1 wait
1393
# for it to be created.
1394
# because we daon't have any relyable cron on NT...
1395
########################################################################
1400
Debug "Waiting for $1"
1405
if [ -f "$1" -a $2 -eq 1 ] # if file exists and is supposed to
1409
if [ ! -f "$1" -a $2 -eq 0 ] # not exists and not supposed to exist
1413
Debug "Waiting for $1, loop #$i, about to sleep $WAIT_FOR seconds Total $TOTAL"
1415
TOTAL=`expr $i \* $WAIT_FOR / 60`
1416
if [ -n "$MAX_FOREVER" ] # we are cheating. Forever can be very short...
1418
if [ "$TOTAL" -gt "$MAX_FOREVER" ]
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... "
1425
################################### is_running #########################
1426
# global shell function , implements primitive locking mechanism
1427
# filename is passed as a parameter, if filename.* exists we assume calling
1428
# script is running already and exit, otherwise filename.processid is
1430
########################################################################
1433
Debug "Testing if $0 is already running... file ${1} - ${1}.$$"
1436
Exit "$0 seems to be running already ($1 exists) - Exiting"
1438
TMPFILES="$TMPFILES ${1}.$$"
1439
echo "running $0 on `date` PID $$" >${1}.$$
1440
Debug "wrote \"running $0 on `date` PID $$\" to ${1}.$$"
1444
#---------------------------# USERCOM #---------------------------------
1445
############################## Echo #####################################
1446
# global shell function , depending on the options the output gets written
1447
# to a file, or is being discarded
1448
# FIXME \n and \c are mistreates by differnet shells, and linux has /bin/echo
1449
# instead of /usr/bin/echo
1450
########################################################################
1453
if [ $O_SILENT = OFF ]
1460
echo "$*" >>$FILENAME
1464
################################### ask ################################
1465
# global shell function, Asks the a question, and gives the returns 0
1466
# on the 1st choice, 1 on the 2nd choice
1474
# -y O_ALWAYS_YES will assume a first choice always (not neccessaryly "y")
1477
# 0 - User picked 1st choice
1478
# 1 - User picked 2nd choice
1481
# ask "Would you like to continue" "y" "n" || Exit
1482
# will produce the string "Would you like to continue (y/n) ?",
1483
# read input from keyboard (or assume a yes with option -y)
1484
# - on a yes it will return 0, on a no it will return 1, the
1485
# shell interprets it as error and the || Exit will be executed
1487
# NOTE: NEVER use "n" as the second parameter - it will mess up -y
1488
# don't ask "Continue" "n" "y" || Exit # it will Exit on a "y"
1490
########################################################################
1498
if [ $O_ALWAYS_YES = ON ]
1524
################################### Warning ############################
1525
# global shell function, Asks the user a "... continue? (y/n)" question,
1526
# and exits when the user answers with no
1527
# NOTE -y will answer the warnings always with yes
1528
########################################################################
1531
ask "WARNING: $0: \n $* continue " "y" "n" || Exit
1534
################################### Debug ############################
1535
# global shell function, when option -d Debugging output is written
1536
########################################################################
1539
if [ $O_DEBUG = ON ]
1541
Echo "DEBUG: (`date +%H:%M`) $0: $*"
1545
################################### line ###############################
1546
# global shell function, supposed to make output more readable...
1547
########################################################################
1551
#Echo "======================================================================="
1555
################################### opt_usage ##########################
1556
# global shell function, tells user about available options
1557
########################################################################
1560
if [ $O_OPTIONS = "ON" ]
1565
Echo " -y answer all questions with y - use at your own risk..."
1566
Echo " -s silent (only usefull with -y)"
1567
Echo " -h, -? - you guessed right - displays this text"
1569
Echo " -f <filename> - write the (error)output to filename"
1570
Echo " -fcronfile produces the resultfiles in the same locations"
1571
Echo " as would have been produced with -cron"
1572
Echo " -m <mailinglist> - send filename to mailinglist (csl "
1573
Echo " example sonmi,nelsonb,wtc) only useful with -f"
1574
Echo " -ml <mailinglist> - send link to filename to mailinglist "
1575
Echo " (csl example sonmi,nelsonb,wtc) only useful with -f"
1576
Echo " -cron equivalient to -y -s -d -f \$RESULTDIR/\$HOST.nssqa"
1577
Echo " -t run on a tinderbox build (included -cron)"
1578
if [ `basename $0` = nssqa ] ; then
1579
Echo " -l <mozroot> run on a local build"
1580
Echo " -ln <mozroot> copy a networkbuild to a local directory "
1581
Echo " mozroot, used for networkindipendend QA "
1582
Echo " -lt try to copy a networkbuild to a local directory, if"
1583
Echo " not possible run on the network
1584
Echo " used for networkindipendend QA
1592
################################### glob_usage #########################
1593
# global shell function, how to use the calling script (parameters, options)
1594
########################################################################
1600
if [ $O_OPTIONS = "ON" ]
1602
Echo "usage $0 [options] nssversion builddate"
1604
Echo "usage $0 nssversion builddate"
1607
Echo " for example: $0 30b 0926"
1616
if [ $O_SILENT = OFF ]
1632
if [ $O_INIT = "ON" ]