/
header
1636 lines (1519 loc) · 50.2 KB
/
header
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /bin/sh
########################################################################
#
# /u/sonmi/bin/header - /u/svbld/bin/init/nss/header
#
# variables, utilities and shellfunctions global to NSS QA
# needs to work on all Unix platforms
#
# included from (don't expect this to be up to date)
# --------------------------------------------------
# qa_stat
# mksymlinks
# nssqa
#
# parameters
# ----------
# nssversion (supported: 30b, 31, 332, tip 32)
# builddate (default - today)
#
# options
# -------
# -y answer all questions with y - use at your own risk... ignores warnings
# -s silent (only usefull with -y)
# -h, -? - you guessed right - displays this text
# -d debug
# -f <filename> - write the (error)output to filename
# -fcronfile produces the resultfiles in the same locations
# as would have been produced with -cron
# -m <mailinglist> - send filename to mailinglist (csl) only useful
# with -f
# -ml <mailinglist> - send link to filename to mailinglist (csl)
# only useful with -f
# -cron equivalient to -y -s -d -f $RESULTDIR/$HOST.<scriptname>
# -t run on a tinderbox build that means: local, from the startlocation
# -l <mozroot directory> run on a local build mozroot
# -ln <mozroot> copy a networkbuild to a local directory mozroot,
# used for networkindipendend QA
# -lt try to copy a networkbuild to a local directory, if not possible
# run on the network
# used for networkindipendend QA
#
# special strings
# ---------------
# FIXME ... known problems, search for this string
# NOTE .... unexpected behavior
#
# moduls (not yet)
# ----------------
# --# INIT
# --# USERCOM
# --# UTILS
#
# FIXME - split in init / usercom / utils
#
########################################################################
#------------------------------# INIT #------------------------------
# below the option flags get initialized
if [ -z "$QASCRIPT_DIR" ]
then
QASCRIPT_DIR=`dirname $0`
if [ "$QASCRIPT_DIR" = '.' ]
then
QASCRIPT_DIR=`pwd`
fi
fi
export QASCRIPT_DIR
O_HWACC=OFF
if [ -z "$O_ALWAYS_YES" ] ; then
O_ALWAYS_YES=OFF # turned on by -y answer all questions with y
fi
if [ -z "$O_INIT" ] # header is global, some including scripts may not
then # want the init to run, the others don't need to bother
O_INIT=ON
fi
if [ -z "$O_PARAM" ] # header is global, some including scripts may not
then # require parameters, the others don't need to bother
O_PARAM=ON
fi
if [ -z "$O_OPTIONS" ] # header is global, some including scripts may not
then # permit options, they don't need to bother
O_OPTIONS=OFF
fi
O_SILENT=OFF # turned on by -s silent (only usefull with -y)
if [ -z "$O_DEBUG" ] ; then
O_DEBUG=OFF # turned on by -d - calls to Debug produce output when ON
fi
O_FILE=OFF # turned on by -f echo all output to a file $FILENAME
O_CRON=OFF # turned on by -cron cron use only
O_CRONFILE=OFF # turned on by -cron cron and -fcron
O_LOCAL=OFF # turned on by -l* run on a local build in $LOCAL_MOZROOT
O_LN=OFF # turned on by -ln and -lt, test a networkbuild locally
O_MAIL=OFF # turned on by -m - sends email
O_MAIL_LINK=OFF # turned on by -ml - sends email
O_TBX=OFF # turned on by -t run on a tinderbox build
# that means: local, from the startlocation
if [ -z "$DOMSUF" ]
then
DOMSUF=red.iplanet.com
DS_WAS_SET=FALSE
else
DS_WAS_SET=TRUE
fi
TMPFILES=""
WAIT_FOR=600 # if waiting for an event sleep n seconds before rechecking
# recomended value 10 minutes 600
WAIT_TIMES=30 # recheck n times before giving up - recomended 30 - total of 5h
if [ -z "$QAYEAR" ] # may I introduce - the y2k+1 bug? QA for last year
then # might not work
QAYEAR=`date +%Y`
fi
if [ -z "$TMP" ]
then
if [ -z "$TEMP" ]
then
TMP="/tmp"
else
TMP=$TEMP
fi
fi
if [ ! -w "$TMP" ]
then
echo "Can't write to tmp directory $TMP - exiting"
echo "Can't write to tmp directory $TMP - exiting" >&2
exit 1
fi
KILLPIDS="$TMP/killpids.$$"
export KILLERPIDS
TMPFILES="$TMPFILES $KILLPIDS"
KILL_SELFSERV=OFF # if sourcing script sets this to on cleanup will also
# kill the running selfserv processes
# Set the masterbuilds
if [ -z "$UX_MASTERBUILD" ]
then
UX_MASTERBUILD=booboo_Solaris8
#if [ ! -d $UX_MASTERBUILD ] ; then
#UX_MASTERBUILD=booboo_Solaris8_forte6
#fi
UX_MB_WAS_SET=FALSE
else
UX_MB_WAS_SET=TRUE
fi
if [ -z "$NT_MASTERBUILD" ]
then
NT_MASTERBUILD=blowfish_NT4.0_Win95
NT_MB_WAS_SET=FALSE # in this case later functions can override if
# they find a different build that looks like NT
else
NT_MB_WAS_SET=TRUE
fi
if [ -z "$MASTERBUILD" ]
then
MASTERBUILD=$UX_MASTERBUILD
fi
# Set the default build
if [ -z "$BUILDNUMBER" ]
then
BUILDNUMBER=1
fi
export BUILDNUMBER
O_LDIR=OFF #local QA dir for NT, temporary
if [ -z "$WIN_WAIT_FOREVER" ] # header is global, some including scripts
then # want the init to wait forever for directories to
# appear (windows only) if OFF exit, if ON wait forever
WIN_WAIT_FOREVER=OFF
fi
# NOTE: following variables have to change
# from release to release
if [ -z "$BC_MASTER" ] # master directory for backwardscompatibility testing
then
RH="NO"
grep 7.1 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES"
grep 7.2 /etc/redhat-release > /dev/null 2>/dev/null && RH="YES"
if [ "$RH" = "YES" ]
then # NSS-3-3-1RTM
BC_UX_MASTER=nss331/builds/20010928.2.331-RTM/booboo_Solaris8
BC_NT_MASTER=nss331/builds/20010928.2.331-RTM/blowfish_NT4.0_Win95
else # NSS-3-2-2RTM
BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
fi
BC_MASTER=$BC_UX_MASTER
BC_MASTER_WAS_SET=FALSE
else
BC_MASTER_WAS_SET=TRUE
fi
BC_RELEASE=3.2
export BC_RELEASE
EARLY_EXIT=TRUE #before the report file has been created, causes Exit to
#create it
UX_D0=/share/builds/mccrel3/nss
################################### glob_init ##########################
# global shell function, main initialisation function
########################################################################
glob_init()
{
if [ $O_PARAM = "ON" ] ; then
eval_opts $* # parse parameters and options - set flags
fi
# if running from cron HOST needs to be known early,
init_host # so the output file name can be constructed.
Debug "Setting up environment...( $QASCRIPT_DIR/set_environment) "
. $QASCRIPT_DIR/set_environment #finds out if we are running on Windows
Debug "OPerating system: $os_name $os_full"
umask 0
init_dirs
init_files
init_vars
}
################################### init_vars ###########################
# global shell function, sets the environment variables, part of init
########################################################################
init_vars()
{
if [ -z "$LOGNAME" ]
then
if [ $O_WIN = "ON" ]
then
LOGNAME=$USERNAME
else
LOGNAME=$USER
fi
if [ -z "$LOGNAME" ]
then
LOGNAME=$UNAME
if [ -z "$LOGNAME" ]
then
LOGNAME=`basename $HOME`
fi
fi
fi
if [ -z "$LOGNAME" ]
then
Exit "Can't determine current user"
fi
case $HOST in
iws-perf)
O_HWACC=ON
HWACC_LIST="rainbow ncipher"
#MODUTIL="-add rainbow -libfile /usr/lib/libcryptoki22.so"
export HWACC_LIST
;;
*)
O_HWACC=OFF
;;
esac
export O_HWACC
}
########################################################################
# functions below deal with setting up the directories and PATHs for
# all different flavors of OS (Unix, Linux, NT MKS, NT Cygnus) and QA
# (Standard, local tinderbox)
########################################################################
########################## find_nt_masterbuild #########################
# global shell function, sets the nt masterbuild directories, part of init
########################################################################
find_nt_masterbuild()
{
NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD}
if [ "${NT_MB_WAS_SET}" = "FALSE" -a ! -d $NT_MASTERDIR ] ; then
if [ -d ${DAILY_BUILD}/*NT4* ] ; then
NT_MASTERBUILD=` cd ${DAILY_BUILD}; ls -d *NT4* `
Debug "NT_MASTERBUILD $NT_MASTERBUILD"
NT_MASTERDIR=${DAILY_BUILD}/${NT_MASTERBUILD}
fi
fi
Debug "NT_MASTERDIR $NT_MASTERDIR"
}
################################### set_daily_build_dirs ###########################
# global shell function, sets directories
########################################################################
set_daily_build_dirs()
{
if [ "$O_LOCAL" = "ON" -a "$O_LN" = "OFF" ] ; then
DAILY_BUILD=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are
# set to the LOCAL_MOZROOT, since it is not sure
# if ../.. (DAILY_BUILD) even exists
LOCALDIST=${LOCAL_MOZROOT}/dist
elif [ "$O_TBX" = "ON" ] ; then
DAILY_BUILD="$TBX_DAILY_BUILD"
LOCALDIST=${UXDIST}
else
DAILY_BUILD=${NSS_VER_DIR}/builds/${QAYEAR}${BUILDDATE}.${BUILDNUMBER}
LOCALDIST=${DAILY_BUILD}/${MASTERBUILD}/mozilla/dist
fi
}
map_os64()
{
IS_64=""
case `uname -s` in
#OSF1) has been done already - always 64 bit
SunOS)
MAPPED_OS=Solaris*8
IS_64=`(isainfo -v | grep 64)>/dev/null 2>/dev/null && echo 64 bit`
if [ "$O_TBX" = "OFF" ] ; then
set_osdir
if [ -n "$IS_64" ]
then #Wait for the 64 bit build to finish...
Debug Testing build for $MAPPED_OS in $OSDIR
Wait ${OSDIR}/SVbuild.InProgress.1 0
fi
fi
;;
AIX)
IS_64=`lslpp -l | grep "bos.64bit"> /dev/null && echo 64 bit`
;;
HP-UX)
IS_64=`getconf KERNEL_BITS | grep 64 >/dev/null && echo 64 bit`
;;
esac
Debug "Mapped OS to $MAPPED_OS"
}
################################### copy_to_local ########################
# global shell function, copies the necessary directories from the
# daily build aerea to the local disk
########################################################################
copy_to_local()
{
Debug "Copy network directories to local directories"
C2L_ERROR=0
if [ ! -d ${LOCAL_MOZROOT}/dist ] ; then
mkdir -p ${LOCAL_MOZROOT}/dist || C2L_ERROR=1
fi
if [ ! -d ${LOCAL_MOZROOT}/security/nss ] ; then
mkdir -p ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=2
fi
if [ $C2L_ERROR != 0 ] ; then
Exit "copy_to_local: Can t make necesssary directories ($C2L_ERROR ) "
fi
if [ ! -d ${LOCAL_MOZROOT}/security/nss/tests ] ; then
cp -r ${TESTSCRIPTDIR} ${LOCAL_MOZROOT}/security/nss || C2L_ERROR=1
fi
if [ ! -d ${LOCAL_MOZROOT}/security/coreconf ] ; then
cp -r ${MOZILLA_ROOT}/security/coreconf ${LOCAL_MOZROOT}/security || C2L_ERROR=2
fi
NO_DIRS=0;
if [ "$O_WIN" = "ON" ] ; then
OS_TARGET=WINNT;export OS_TARGET
fi
unset BUILD_OPT;export BUILD_OPT;
unset USE_64;export USE_64;
#FIXME only tested on 64 bit Solaris and only got 32 bit builds
while [ $NO_DIRS -lt 4 ] ; do
# first time thru: Debug 32 bit NT
set_objdir
Debug "Copying ${OBJDIR}..."
if [ ! -d ${LOCAL_MOZROOT}/dist/${OBJDIR} ] ; then
cp -r ${LOCALDIST}/${OBJDIR} ${LOCAL_MOZROOT}/dist || C2L_ERROR=3
fi
NO_DIRS=`expr $NO_DIRS + 1`
if [ $NO_DIRS = 1 ] ; then # 2nd time: OPT 32 bit NT
BUILD_OPT=1; export BUILD_OPT;
elif [ $NO_DIRS = 2 ] ; then # 3rd time: OPT, either 64 bit or Win95 or force exit
if [ "$O_WIN" = "ON" ] ; then
OS_TARGET=WIN95;export OS_TARGET
else
map_os64
if [ -z "$IS_64" ] ; then #32 bit platform
NO_DIRS=4
else
USE_64=1; export USE_64
fi
fi
elif [ $NO_DIRS = 3 ] ; then # 4th time: Debug either 64 bit or Win95
unset BUILD_OPT;export BUILD_OPT;
fi
done
if [ $C2L_ERROR != 0 ] ; then
Exit "copy_to_local: Can t copy necesssary directories ($C2L_ERROR ) "
fi
unset TESTSCRIPTDIR
unset TESTDIR
unset RESULTDIR
O_LN=OFF #from here on pretend it is regular -l local QA FIXME, might cause
#problems with the backwardcompatibility tests
Debug "Successfully copied network directories to local directories"
}
################################### local_dirs ###########################
# global shell function, sets the directories for local QA
########################################################################
local_dirs()
{
Debug "Set directories for local QA"
#if [ "$O_WIN" = "ON" ] ; then
#win_set_tmp
#fi
NSS_VER_DIR=${LOCAL_MOZROOT} # on local builds NSS_VER_DIR and DAILY_BUILD are
# set to the LOCAL_MOZROOT, since it is not sure
# if ../../../.. (NSS_VER_DIR) even exists
if [ -z "${RESULTDIR}" ] ; then # needs to be local as well
Debug "Setting RESULTDIR for local QA"
RESULTDIR="${LOCAL_MOZROOT}/tests_results/security/${HOST}-`date +%Y%m%d-%H.%M`"
fi
set_daily_build_dirs
UX_MASTERDIR=`dirname ${LOCAL_MOZROOT}`
NT_MASTERDIR=$UX_MASTERDIR
MOZILLA_ROOT=${LOCAL_MOZROOT}
UXDIST=${MOZILLA_ROOT}/dist
NTDIST=${UXDIST}
if [ -z "${TESTDIR}" ] ; then
Debug "Setting TESTDIR for local QA"
TESTDIR=${RESULTDIR}
fi
if [ -n "$TESTDIR" ] ; then
if [ ! -d $TESTDIR ] ; then
Debug "Making TESTDIR for local QA"
mkdir -p $TESTDIR
fi
fi
export TESTDIR
Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
TESTSCRIPTDIR=${LOCAL_MOZROOT}/security/nss/tests
COMMON=${TESTSCRIPTDIR}/common
set_objdir
debug_dirs
export_dirs
}
################################### tbx_dirs ###########################
# global shell function, sets the directories for tinderbox QA
########################################################################
tbx_dirs()
{
Debug "Set directories for tinderbox"
if [ "$O_WIN" = "ON" ] ; then
win_set_d1 # we need the NSS_VER_DIR later
else
NSS_VER_DIR="$UX_D0"/nss$NSSVER
fi
if [ -z "${RESULTDIR}" ] ; then # needs to be different for tinderbox
Debug "Setting RESULTDIR for tinderbox"
TBX_NOBITS=""
echo $QASCRIPT_DIR | grep 64 >/dev/null && TBX_NOBITS=64
TRD="${HOST}${TBX_NOBITS}-`date +%Y%m%d-%H.%M`"
RESULTDIR="${NSS_VER_DIR}/tinderbox/tests_results/security/${TRD}"
if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
URL="sbs-rel.nscp.aoltw.net"
else
URL="cindercone.red.iplanet.com"
fi
if [ "$O_WIN" = "ON" ] ; then
RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${UX_D0}/nsstip/tinderbox/tests_results/security/${TRD}\">QA</a>"
else
RESULTDIRURL="<a title=\"QA Results\" href=\"http://${URL}${RESULTDIR}\">QA</a>"
fi
Debug "RESULTDIRURL TinderboxPrint:$RESULTDIRURL"
fi
TBX_DAILY_BUILD=`cd ../../../../..;pwd`
NSS_VER_DIR="${TBX_DAILY_BUILD}/../.."
TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tinderbox | sed -e 's/ .*//g'`
if [ -z "$TBX_LOGFILE_DIR" ] ; then
TBX_LOGFILE_DIR=`ls ${NSS_VER_DIR}/logs/tbx | sed -e 's/ .*//g'`
TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tbx/${TBX_LOGFILE_DIR}"
else
TBX_LOGFILE_DIR="${NSS_VER_DIR}/logs/tinderbox/${TBX_LOGFILE_DIR}"
fi
Debug "Set TBX_LOGFILE_DIR ${TBX_LOGFILE_DIR}"
set_daily_build_dirs
UX_MASTERDIR=`cd ../../../..;pwd`
NT_MASTERDIR=$UX_MASTERDIR
MOZILLA_ROOT=$UX_MASTERDIR/mozilla
UXDIST=${MOZILLA_ROOT}/dist
NTDIST=${UXDIST}
if [ -z "${TESTDIR}" ] ; then
Debug "Setting TESTDIR for tinderbox"
TESTDIR=${RESULTDIR}
fi
if [ -n "$TESTDIR" ] ; then
if [ ! -d $TESTDIR ] ; then
Debug "Making TESTDIR for tinderbox"
mkdir -p $TESTDIR
fi
fi
Debug "Making QAstatus file"
echo "QA running" >${TESTDIR}/QAstatus
export TESTDIR
Debug "RESULTDIR $RESULTDIR TESTDIR $TESTDIR"
TESTSCRIPTDIR=`pwd`
COMMON=${TESTSCRIPTDIR}/common
set_objdir
debug_dirs
export_dirs
}
################################### init_mcom ###########################
# global shell function, sets domain specific variables for AOL's
# domains according to Bishakha's instructions
########################################################################
init_mcom()
{
Debug "Running in mcom or netscape domain - changing directories..."
if [ "${UX_MB_WAS_SET}" = "FALSE" ] ; then #in case it was set
# before script was called use these values
UX_MASTERBUILD=spd04_Solaris8
fi
if [ "${NT_MB_WAS_SET}" = "FALSE" ] ; then
NT_MASTERBUILD=spd06_NT4
fi
MASTERBUILD=$UX_MASTERBUILD
if [ "${BC_MASTER_WAS_SET}" = "FALSE" ] ; then
BC_UX_MASTER=nss322/builds/20010820.1/y2sun2_Solaris8
BC_NT_MASTER=nss322/builds/20010820.1/blowfish_NT4.0_Win95
BC_MASTER=$BC_UX_MASTER
fi
UX_D0=/share/builds/sbsrel2/nss
URL="sbs-rel.nscp.aoltw.net"
}
################################### init_dirs ###########################
# global shell function, sets the directories for standard QA
# calls special functions for tinderbox, windows or local QA, part of init
########################################################################
init_dirs()
{
if [ ${DOMSUF} = "mcom.com" -o ${DOMSUF} = "netscape.com" -o ${DOMSUF} = "nscp.aoltw.net" ] ; then
init_mcom
fi
if [ $O_WIN = "ON" ] ; then
win_set_tmp
write_to_tmpfile
MASTERBUILD=$NT_MASTERBUILD
BC_MASTER=$BC_NT_MASTER
fi
if [ "$O_LOCAL" = "ON" -a $O_LN = "OFF" ] ; then # if it is a LN we need to know
# all the directories off the network first to copy them
local_dirs # O_LOCAL alone assumes that all the directories are already there
return
elif [ "$O_TBX" = "ON" ] ; then
tbx_dirs
return
elif [ "$O_WIN" = "ON" ] ; then
win_set_d1
else
NSS_VER_DIR="$UX_D0"/nss$NSSVER
fi
#set -x
set_daily_build_dirs
if [ -z "${BCDIST}" ] ; then
#BCDIST=/share/builds/mccrel3/nss/${BC_MASTER}/mozilla/dist
BCDIST=${NSS_VER_DIR}/../${BC_MASTER}/mozilla/dist
if [ ! -d $BCDIST -a `basename $0` != jssqa ] ; then
ask "Backward compatibility directory $BCDIST does not exist, continue" "y" "n" || Exit
fi
fi
UX_MASTERDIR=${DAILY_BUILD}/${UX_MASTERBUILD}
find_nt_masterbuild
if [ "$O_WIN" = "ON" ]
then
MOZILLA_ROOT=${NT_MASTERDIR}/mozilla
else
MOZILLA_ROOT=${UX_MASTERDIR}/mozilla
fi
UXDIST=${UX_MASTERDIR}/mozilla/dist
NTDIST=${NT_MASTERDIR}/mozilla/dist
if [ -z "${RESULTDIR}" ] ; then
RESULTDIR=${UX_MASTERDIR}/mozilla/tests_results/security
fi
if [ -n "$PRODUCT_TO_TEST" -a "$PRODUCT_TO_TEST" = "JSS" ] ; then
if [ "$O_WIN" = "ON" ] ; then
JSS_NSS_SRC_DIR=$JSS_NSS_NT_SRC_DIR
fi
TESTSCRIPTDIR=${NSS_VER_DIR}/../${JSS_NSS_SRC_DIR}/mozilla/security/nss/tests
else
TESTSCRIPTDIR=${MOZILLA_ROOT}/security/nss/tests
fi
if [ ! -d $TESTSCRIPTDIR -a `basename $0` != jssqa ] ; then
if [ "$O_WIN" = "ON" -a "$WIN_WAIT_FOREVER" = "ON" ]
then
WaitForever $TESTSCRIPTDIR/all.sh 1
else
Exit "Test directory $TESTSCRIPTDIR does not exist"
fi
fi
COMMON=${TESTSCRIPTDIR}/common
if [ "$O_LOCAL" = "ON" -a $O_LN = "ON" ] ; then # if it is a LN we need to know
# all the directories off the network first to copy them
copy_to_local
local_dirs
fi
#set +x
set_objdir
debug_dirs
export_dirs
}
debug_dirs()
{
Debug "NTDIST $NTDIST"
Debug "UXDIST $UXDIST"
Debug "TESTSCRIPTDIR $TESTSCRIPTDIR"
Debug "RESULTDIR $RESULTDIR"
Debug "TMP $TMP"
Debug "LOCALDIST_BIN $LOCALDIST_BIN"
Debug "COMMON $COMMON"
Debug "MOZILLA_ROOT $MOZILLA_ROOT"
Debug "BCDIST $BCDIST"
}
export_dirs()
{
export NSS_VER_DIR DAILY_BUILD NTDIST UXDIST RESULTDIR TESTSCRIPTDIR BCDIST
export UX_MASTERDIR NT_MASTERDIR COMMON MOZILLA_ROOT
}
set_osdir()
{
OSDIR=${DAILY_BUILD}/*${MAPPED_OS}*
}
################################### init_files ###########################
# global shell function, sets filenames, initializes files, part of init
########################################################################
init_files()
{
if [ $O_CRONFILE = "ON" ]
then
Debug "attempting to create resultfiles"
if [ "$O_TBX" = "ON" ] ; then
NEWFILENAME=${TBX_LOGFILE_DIR}/qa.log
if [ ! -w ${TBX_LOGFILE_DIR} ] ; then
Exit "can't touch $NEWFILENAME"
fi
else
NEWFILENAME=$RESULTDIR/$HOST.`basename $0`
fi
if [ ! -d $RESULTDIR ]
then
mkdir -p $RESULTDIR || Exit "Error: can't make $RESULTDIR"
fi
if [ ! -w $RESULTDIR ] ; then
Exit "can't touch $NEWFILENAME"
fi
Debug "About to touch $NEWFILENAME "
touch $NEWFILENAME || Exit "Error: can't touch $NEWFILENAME"
if [ "$O_TBX" = "ON" ] ; then
echo "QA results in $RESULTDIR" >>$NEWFILENAME || Exit "Error: can't write to $NEWFILENAME"
fi
Debug "About to cat $FILENAME >>$NEWFILENAME "
cat $FILENAME >>$NEWFILENAME || Exit "Error: can't append $FILENAME to $NEWFILENAME"
TMPFILES="$TMPFILES $FILENAME"
FILENAME=$NEWFILENAME
Debug "Writing output to $FILENAME"
fi
}
################################### write_to_tmpfile ##########################
# global shell function, for NT and cron operation, first a tmpfile
# needs to be created
########################################################################
write_to_tmpfile()
{
O_CRONFILE=ON
O_FILE=ON
FILENAME=${TMP}/nsstmp.$$ # for now write to the temporary file
# since we don't know the hostname yet
# will be inserted to the real file later
TMPFILES="$TMPFILES nsstmp.$$"
touch $FILENAME || Exit "Error: can't touch $FILENAME"
Debug "Writing output to $FILENAME"
}
############################# turn_on_cronoptions ######################
# global shell function, turns on options needed for cron and tinderbox
########################################################################
turn_on_cronoptions()
{
O_CRON=ON
O_SILENT=ON
O_DEBUG=ON # FIXME take out!
O_ALWAYS_YES=ON
write_to_tmpfile
}
########################## test_mozroot ##########################
# global shell function, determines if the variable LOCAL_MOZROOT is set,
# and is usable as mozilla root diretory for a local QA
###################################################################
test_mozroot()
{
PWD=`pwd`
Debug "LOCAL_MOZROOT = $LOCAL_MOZROOT"
case "$LOCAL_MOZROOT" in
[0-9-]*|tip)
glob_usage "Error: -"$1" requires a directoryname to follow (start with a letter) "
;;
\.\.)
LOCAL_MOZROOT=`dirname $PWD`
;;
\.)
LOCAL_MOZROOT=$PWD
;;
\.\/*)
LOCAL_MOZROOT=`echo $LOCAL_MOZROOT | sed -e "s/^\.//"`
LOCAL_MOZROOT="${PWD}${LOCAL_MOZROOT}"
;;
\.\.\/*)
LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
;;
\/*|[a-zA-Z]:\/*)
;;
?*)
LOCAL_MOZROOT="${PWD}/${LOCAL_MOZROOT}"
;;
*)
glob_usage "Error: -"$1" requires a directoryname to follow"
;;
esac
Debug "Reformated MOZROOT to $LOCAL_MOZROOT"
if [ "$1" = "ln" ] ; then
LOCAL_MOZROOT_PARENT=`dirname $LOCAL_MOZROOT`
if [ ! -d $LOCAL_MOZROOT_PARENT -o ! -w $LOCAL_MOZROOT_PARENT -o \
! -x $LOCAL_MOZROOT_PARENT ] ; then
Exit "Error: Can't create $LOCAL_MOZROOT (permissions)"
fi
if [ ! -d "$LOCAL_MOZROOT" ] ; then
mkdir $LOCAL_MOZROOT ||
Exit "Error: Can't create mozroot $LOCAL_MOZROOT (mkdir failed)"
else
ask "mozroot $LOCAL_MOZROOT exists - continue (y will remove dir) ?" \
"y" "n" || Exit
rm -rf $LOCAL_MOZROOT/dist $LOCAL_MOZROOT/security $LOCAL_MOZROOT/tests_results ||
Exit "Error: Can't clean mozroot $LOCAL_MOZROOT"
fi
fi
if [ ! -d "$LOCAL_MOZROOT" ] ; then
glob_usage "Error: mozilla root $LOCAL_MOZROOT not a valid directory"
fi
}
################################### eval_opts ##########################
# global shell function, evapuates options and parameters, sets flags
# variables and defaults
########################################################################
eval_opts()
{
while [ -n "$1" ]
do
case $1 in
-cron)
turn_on_cronoptions
;;
-T*|-t*)
O_TBX=ON
turn_on_cronoptions
O_SILENT=OFF #FIXME debug only
;;
-S*|-s*)
O_SILENT=ON
;;
-Y*|-y)
Debug "Option -y dedectet"
O_ALWAYS_YES=ON
;;
-d*|-D)
O_DEBUG=ON
#set -x
;;
-ml|-ML)
O_MAIL_LINK=ON
shift
MAILINGLIST=$1
if [ -z "$MAILINGLIST" ]
then
glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
fi
Debug "Sending link to result to $MAILINGLIST"
;;
-m|-M)
O_MAIL=ON
shift
MAILINGLIST=$1
if [ -z "$MAILINGLIST" ]
then
glob_usage "Error: -m requires a mailinglist to follow, for example sonmi,wtc,nelsonb "
fi
Debug "Sending result to $MAILINGLIST"
;;
-fcron*|-F[Cc][Rr][Oo][Nn]*)
write_to_tmpfile
;;
-f|-F)
O_FILE=ON
shift
FILENAME=$1
if [ -z "$FILENAME" ]
then
glob_usage "Error: -f requires a filename to follow"
fi
#rm -f $FILENAME 2>/dev/null
touch $FILENAME || Exit "Error: can't touch $FILENAME"
#NOTE we append rather that creating
Debug "Writing output to $FILENAME"
;;
-h|-help|"-?")
glob_usage
;;
-ln)
if [ `basename $0` != nssqa ] ; then
glob_usage "Error: Can't handle option $1"
fi
O_LOCAL=ON
O_LN=ON
shift
LOCAL_MOZROOT=$1
test_mozroot ln
;;
-lt)
if [ `basename $0` != nssqa ] ; then
glob_usage "Error: Can't handle option $1"
fi
O_LN=ON
O_LOCAL=ON
;;
-l)
if [ `basename $0` != nssqa ] ; then
glob_usage "Error: Can't handle option $1"
fi
O_LOCAL=ON
shift
LOCAL_MOZROOT=$1
test_mozroot l
;;
-p)
shift
PORT=$1
export PORT
;;
-*)
glob_usage "Error: Can't handle option $1"
;;
tip|3.|3..)
NSSVER=$1
if [ -z "$NSSVER" ] ; then
glob_usage "Error: illegal parameter"
fi
;;
[01][0-9][0123][0-9])
BUILDDATE=$1
if [ -z "$BUILDDATE" ] ; then
glob_usage "Error: illegal parameter"
fi
;;
?*)
glob_usage "Error: Can't handle parameter $1"
;;
esac
shift
done
if [ -z "$PORT" -a "$O_TBX" = "ON" ] ; then
PORT=8444
export PORT
if [ -z "$NSSVER" ] ; then
NSSVER="tip"
Debug "NSS Version: Parameters missing - defaulting to tip!"
fi
elif [ -z "$NSSVER" ] ; then
NSSVER="tip"
Debug "NSS Version: Parameters missing - defaulting to tip!"
fi
if [ -z "$BUILDDATE" ] ; then
BUILDDATE=`date +%m%d`
Debug "Builddate: Parameters missing - defaulting to today!"
fi
Debug "Builddate $BUILDDATE NssVersion $NSSVER"
export BUILDDATE NSSVER
export O_CRON O_SILENT O_DEBUG O_ALWAYS_YES O_TBX
}
win_set_tmp()
{
TMP=`echo "$TMP" | sed -e 's/ /\/t/g' -e 's//\/b/' -e 's/\\\/\//g'`
Debug "TMP reformated to $TMP"
}
######################### win_set_d1 ################################
# global shell function, interactively finds the directories in case
# windows can't get to the default
########################################################################
win_set_d1()
{
Debug "set Windows Directories..."
#win_set_tmp
if [ "$O_CYGNUS" = ON ]
then
NSS_VER_DIR=/cygdrive/w/nss/nss$NSSVER
else
NSS_VER_DIR=w:/nss/nss$NSSVER
fi
if [ ! -w $NSS_VER_DIR ]
then
Echo "Windows special... can't write in $NSS_VER_DIR"
if [ "$O_CYGNUS" = ON ]
then
NSS_VER_DIR=/cygdrive/u/nss/nss$NSSVER
else
NSS_VER_DIR="u:/nss/nss$NSSVER"
fi
else
Debug "NSS_VER_DIR set to $NSS_VER_DIR"
return
fi
while [ ! -w $NSS_VER_DIR ]
do
if [ "$O_CRONFILE" = "ON" ]
then
Exit "cant write in $NSS_VER_DIR"
fi
Warning "cant write in $NSS_VER_DIR"
Echo "input start directory (u:/nss, d:/src/nss, f:/shared/nss) "
read D
if [ -n "$D" ]
then
NSS_VER_DIR=$D/nss$NSSVER
fi
done
Debug "NSS_VER_DIR set to $NSS_VER_DIR"
}
########################### init_host ##################################
# global shell function, sets required variables HOST and DOMSUF, and asks
# the user if it has been set right
########################################################################
set_host()
{
init_host
}
init_host()
{
if [ `basename $0` != nssqa ] ; then
return
fi
init_host_done=0
if [ $DS_WAS_SET = FALSE ] #give chance to overwrite, espec. for NT
then
Debug "Domainname was not set..."
DOMSUF=`domainname 2>/dev/null`
if [ -z "$DOMSUF" ]
then
Debug "domainname command did not work ..."