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