PageRenderTime 27ms CodeModel.GetById 14ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/security/nss/tests/jssqa

http://github.com/zpao/v8monkey
Shell | 220 lines | 125 code | 38 blank | 57 comment | 7 complexity | 023ee050a91ae82c0ed18ae6568343e5 MD5 | raw file
  1#! /bin/sh  
  2
  3########################################################################
  4#
  5# /u/sonmi/bin/jssqa
  6#
  7# this script is supposed to automatically run - now a sanity test, later QA for 
  8# JSS on all required Unix and Windows (NT and 2000) platforms
  9#
 10# parameters
 11# ----------
 12#   jssversion  (supported: 31, tip)
 13#   builddate   (default - today)
 14#
 15# options
 16# -------
 17#   -y answer all questions with y - use at your own risk...ignores warnings
 18#   -s silent (only usefull with -y)
 19#   -h, -? - you guessed right - displays this text
 20#   -d debug
 21#   -f <filename> - write the (error)output to filename
 22#   -cron equivalient to -y -s -d -f $RESULTDIR/$HOST.nssqa
 23#
 24########################################################################
 25
 26O_OPTIONS=ON            # accept options (see above for listing)
 27WIN_WAIT_FOREVER=OFF    # don't wait for the NSS testdir
 28PRODUCT_TO_TEST="JSS"
 29JSS_NSPR_DIR="/share/builds/components/nspr20/v4.1.2"
 30JSS_NSS_DIR="/share/builds/components/nss/NSS_3_3_1_RTM"
 31JSS_NSS_UX_SRC_DIR="nss331/builds/20010928.2.331-RTM/booboo_Solaris8"
 32JSS_NSS_NT_SRC_DIR="nss331/builds/20010928.2.331-RTM/blowfish_NT4.0_Win95"
 33JSS_NSS_SRC_DIR=$JSS_NSS_UX_SRC_DIR
 34NATIVE_FLAG=""
 35
 36. `dirname $0`/header   # utilities, shellfunctions etc, global to NSS and JSS QA
 37
 38if [ -z "$O_TBX" -o "$O_TBX" != "ON" ] ; then
 39    is_running ${TMP}/jssqa
 40                        # checks if the file exists, if yes Exits, if not
 41                        # creates to implement a primitive locking mechanism
 42fi
 43
 44INTERNAL_TOKEN="NSS Certificate DB"
 45SIGTEST_INTERNAL_TOKEN="Internal Key Storage Token"
 46
 47################################ jss_init #########################
 48# 
 49# Most of the procedure is setting up the test environment.
 50# set all necessary dir and file variables, set all paths, copy the shared libs 
 51# Put all the shared libraries into a lib directory, <libdir>.
 52# including the libjss3.so that was built by the build process.
 53# set LD_LIBRARY PATH and CLASSPATH
 54# The xpclass.jar produced by the JSS build needs to be in the classpath.
 55# The classpath must also include the current directory so we can run our test
 56# programs.
 57################################################################################
 58
 59jss_init()
 60{
 61  Debug "Jss init"
 62  #correct all directories that the header has set...
 63  NTDIST=`echo $NTDIST | sed -e 's/nss/jss/g'`
 64  UXDIST=`echo $UXDIST | sed -e 's/nss/jss/g'`
 65  RESULTDIR=`echo $RESULTDIR | sed -e 's/nss/jss/g'`
 66  mkdir -p ${RESULTDIR} 2>/dev/null
 67  JSS_LOGFILE=${RESULTDIR}/${HOST}.txt
 68  FILENAME=$JSS_LOGFILE
 69  O_FILE=ON
 70
 71  MOZILLA_ROOT=`echo $MOZILLA_ROOT | sed -e 's/nss/jss/g'`
 72
 73  JSS_SAMPLES="$MOZILLA_ROOT/security/jss/samples"
 74  JSS_CLASSPATH=`echo $MOZILLA_ROOT | 
 75      sed -e "s/jss$NSSVER.builds/jss$NSSVER\/ships/g" -e "s/mozilla/jss\/${QAYEAR}${BUILDDATE}/"`
 76  Debug "JSS_CLASSPATH=$JSS_CLASSPATH"
 77  Debug "JSS_SAMPLES=$JSS_SAMPLES"
 78
 79  if [ ! -d $JSS_SAMPLES ] ; then
 80      if [ "$O_WIN" = "ON" -a "$WIN_WAIT_FOREVER" = "ON" ]
 81      then
 82          WaitForever $JSS_SAMPLES/TestKeyGen.java 1
 83      else
 84          Exit "Test directory $JSS_SAMPLES does not exist"
 85      fi
 86  fi
 87
 88  PWFILE="$JSS_SAMPLES/passwd"
 89  EMPTYFILE="$JSS_SAMPLES/emptyfile"
 90  rm $PWFILE $EMPTYFILE 2>/dev/null
 91  echo "jss" >$PWFILE
 92  echo "" >$EMPTYFILE
 93  echo "" >>$EMPTYFILE
 94  echo "" >>$EMPTYFILE
 95
 96  INIT_PATH=$PATH
 97  INIT_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
 98}
 99
100
101jss_mode_init()
102{
103  OBJDIR=`cd ${TESTSCRIPTDIR}/common; gmake objdir_name`
104
105  LOCALDIST_BIN=`echo $LOCALDIST_BIN | sed -e 's/nss/jss/g'`
106  LOCALDIST_LIB=$LOCALDIST_BIN/../lib
107  debug_dirs
108
109  #make testdir/libdir
110
111  JSS_LIBDIR=${RESULTDIR}/${HOST}.libdir/${OBJDIR}
112  mkdir -p ${JSS_LIBDIR} 2>/dev/null
113  Debug "JSS_LIBDIR=$JSS_LIBDIR"
114
115  #Put all the shared libraries into a lib directory
116  Debug "copy all needed libs to ${JSS_LIBDIR}"
117  cp $JSS_NSPR_DIR/${OBJDIR}/lib/* ${JSS_LIBDIR}
118  cp $JSS_NSS_DIR/${OBJDIR}/lib/* ${JSS_LIBDIR}
119  cp $LOCALDIST_LIB/libjss3.*  ${JSS_LIBDIR}
120  #FIXME uncomment above
121
122  if [ $O_DEBUG = ON ] ; then
123      Debug "ls $JSS_LIBDIR"
124      ls $JSS_LIBDIR
125  fi
126
127  #LD_LIBRARY_PATH=$INIT_LD_LIBRARY_PATH:${JSS_LIBDIR}
128  LD_LIBRARY_PATH=${JSS_LIBDIR} #remove to avoid HP coredump
129  CLASSPATH="$JSS_CLASSPATH/xpclass.jar:."
130
131  SHLIB_PATH=${LD_LIBRARY_PATH}
132  LIBPATH=${LD_LIBRARY_PATH}
133
134  PATH=$JSS_NSPR_DIR/${OBJDIR}/bin:$JSS_NSS_DIR/${OBJDIR}//bin:$INIT_PATH
135  Debug "PATH $PATH"
136  Debug "LD_LIBRARY_PATH $LD_LIBRARY_PATH"
137  Debug "CLASSPATH=$CLASSPATH"
138
139  export CLASSPATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH
140  export TESTSCRIPTDIR COMMON
141  export_dirs
142}
143
144  
145################################ jss_test #########################
146# 
147# go into the build tree. cd to mozilla/security/jss/samples.
148# Create NSS directories in this directory with modutil and set the password
149#
150#6. Create an alias for the "java" and "javac" commands. You'll need to set
151#it to whatever version of the JDK you used to build on this platform. For
152#example, 
153      #alias java /share/builds/components/cms_jdk/AIX/1.3.0/jre/bin/java
154        #alias javac /share/builds/components/cms_jdk/AIX/1.3.0/bin/javac
155# instead $JAVA and $JAVAC
156# 7. Compile the tests.
157#####################################################################
158jss_test()
159{
160  O_FILE=OFF
161  Debug "JSS main test"
162  #set -x
163  cd $JSS_SAMPLES
164
165  Debug "Cleaning  $JSS_SAMPLES"
166  rm cert7.db key3.db 2>/dev/null
167
168  Debug "echo | modutil -dbdir . -create -force"
169  echo | modutil -dbdir . -create -force
170  Debug "modutil returned $?"
171
172  modutil -dbdir . -list
173
174  Debug "echo | modutil -dbdir . -changepw \"$INTERNAL_TOKEN\" -newpwfile $PWFILE -force"
175  modutil -dbdir . -changepw "$INTERNAL_TOKEN" -newpwfile $PWFILE  -force <$EMPTYFILE
176  #modutil -dbdir . -changepw "$INTERNAL_TOKEN" -pwfile $PWFILE -newpwfile $PWFILE <$EMPTYFILE
177  Debug "modutil returned $?"
178
179  Debug "$JAVAC TestKeyGen.java"
180  $JAVAC TestKeyGen.java
181  Debug "$JAVAC TestKeyGen.java returned $?"
182
183  Debug "$JAVAC SigTest.java"
184  $JAVAC SigTest.java
185  Debug "$JAVAC SigTest.java returned $?"
186          
187  echo "Starting new jss test on $HOST"  
188  date
189
190  # Run the actual tests
191
192  Debug "$JAVA $NATIVE_FLAG TestKeyGen ." 
193  $JAVA $NATIVE_FLAG TestKeyGen . 
194  Debug "$JAVA TestKeyGen returned $?"
195
196  Debug "$JAVA $NATIVE_FLAG SigTest . \"$SIGTEST_INTERNAL_TOKEN\""
197  $JAVA $NATIVE_FLAG SigTest . "$SIGTEST_INTERNAL_TOKEN"
198  Debug "$JAVA SigTest returned $?"
199
200  O_FILE=ON
201}
202
203jss_init
204jss_mode_init
205
206if [ "$O_CRON" = "ON" -o "$O_WIN" = "ON" ]
207then
208    jss_test >>$JSS_LOGFILE  2>&1
209else
210    jss_test 2>&1 | tee -a $JSS_LOGFILE
211fi
212BUILD_OPT=1; export BUILD_OPT; Debug "BUILD_OPT $BUILD_OPT"
213jss_mode_init
214if [ "$O_CRON" = "ON" -o "$O_WIN" = "ON" ]
215then
216    jss_test >>$JSS_LOGFILE  2>&1
217else
218    jss_test 2>&1 | tee -a $JSS_LOGFILE
219fi
220Exit "jssqa completed. Done `uname -n` $QA_OS_STRING"