1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/tests/multinit/multinit.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,158 @@ 1.4 +#! /bin/sh 1.5 +# 1.6 +# This Source Code Form is subject to the terms of the Mozilla Public 1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.9 + 1.10 +######################################################################## 1.11 +# 1.12 +# mozilla/security/nss/tests/multinit/multinit.sh 1.13 +# 1.14 +# Script to test NSS multinit 1.15 +# 1.16 +# needs to work on all Unix and Windows platforms 1.17 +# 1.18 +# special strings 1.19 +# --------------- 1.20 +# FIXME ... known problems, search for this string 1.21 +# NOTE .... unexpected behavior 1.22 +# 1.23 +######################################################################## 1.24 + 1.25 +############################## multinit_init ############################## 1.26 +# local shell function to initialize this script 1.27 +######################################################################## 1.28 +multinit_init() 1.29 +{ 1.30 + SCRIPTNAME=multinit.sh # sourced - $0 would point to all.sh 1.31 + 1.32 + if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for 1.33 + CLEANUP="${SCRIPTNAME}" # cleaning this script will do it 1.34 + fi 1.35 + 1.36 + if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then 1.37 + cd ../common 1.38 + . ./init.sh 1.39 + fi 1.40 + if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here 1.41 + cd ../cert 1.42 + . ./cert.sh 1.43 + fi 1.44 + SCRIPTNAME=multinit.sh 1.45 + 1.46 + html_head "MULTI Tests" 1.47 + 1.48 + grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || { 1.49 + Exit 11 "Fatal - S/MIME of cert.sh needs to pass first" 1.50 + } 1.51 + 1.52 + # set up our directories 1.53 + MULTINITDIR=${HOSTDIR}/multinit 1.54 + MULTINITDIR_1=${MULTINITDIR}/dir1 1.55 + MULTINITDIR_2=${MULTINITDIR}/dir2 1.56 + MULTINITDIR_3=${MULTINITDIR}/dir3 1.57 + R_MULINITDIR=../multinit 1.58 + R_MULTINITDIR_1=${R_MULTINITDIR}/dir1 1.59 + R_MULTINITDIR_2=${R_MULTINITDIR}/dir2 1.60 + R_MULTINITDIR_3=${R_MULTINITDIR}/dir3 1.61 + # first create them all 1.62 + mkdir -p ${MULTINITDIR} 1.63 + mkdir -p ${MULTINITDIR_1} 1.64 + mkdir -p ${MULTINITDIR_2} 1.65 + mkdir -p ${MULTINITDIR_3} 1.66 + # now copy them fro alice, bob, and dave 1.67 + cd ${MULTINITDIR} 1.68 + cp ${P_R_ALICEDIR}/* ${MULTINITDIR_1}/ 1.69 + cp ${P_R_BOBDIR}/* ${MULTINITDIR_2}/ 1.70 + cp ${P_R_DAVEDIR}/* ${MULTINITDIR_3}/ 1.71 + # finally delete the RootCerts module to keep the certificate noice in the 1.72 + # summary lines down 1.73 + echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_1} 1.74 + echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_2} 1.75 + echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_3} 1.76 + MULTINIT_TESTS=${QADIR}/multinit/multinit.txt 1.77 +} 1.78 + 1.79 + 1.80 +############################## multinit_main ############################## 1.81 +# local shell function to test basic signed and enveloped messages 1.82 +# from 1 --> 2" 1.83 +######################################################################## 1.84 +multinit_main() 1.85 +{ 1.86 + html_head "Multi init interface testing" 1.87 + exec < ${MULTINIT_TESTS} 1.88 + while read order commands shutdown_type dirs readonly testname 1.89 + do 1.90 + if [ "$order" != "#" ]; then 1.91 + read tag expected_result 1.92 + 1.93 + # handle the case where we expect different results based on 1.94 + # the database type. 1.95 + if [ "$tag" != "all" ]; then 1.96 + read tag2 expected_result2 1.97 + if [ "$NSS_DEFAULT_DB_TYPE" == "$tag2" ]; then 1.98 + expected_result=$expected_result2 1.99 + fi 1.100 + fi 1.101 + 1.102 + # convert shutdown type to option flags 1.103 + shutdown_command=""; 1.104 + if [ "$shutdown_type" == "old" ]; then 1.105 + shutdown_command="--oldStype" 1.106 + fi 1.107 + 1.108 + # convert read only to option flags 1.109 + ro_command=""; 1.110 + case $readonly in 1.111 + all) ro_command="--main_readonly --lib1_readonly --lib2_readonly";; 1.112 + libs) ro_command="--lib1_readonly --lib2_readonly";; 1.113 + main) ro_command="--main_readonly";; 1.114 + lib1) ro_command="--lib1_readonly";; 1.115 + lib2) ro_command="--lib2_readonly";; 1.116 + none) ;; 1.117 + *) ;; 1.118 + esac 1.119 + 1.120 + # convert commands to option flags 1.121 + main_command=`echo $commands | sed -e 's;,.*$;;'` 1.122 + lib1_command=`echo $commands | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'` 1.123 + lib2_command=`echo $commands | sed -e 's;^.*,;;'` 1.124 + 1.125 + # convert db's to option flags 1.126 + main_db=`echo $dirs | sed -e 's;,.*$;;'` 1.127 + lib1_db=`echo $dirs | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'` 1.128 + lib2_db=`echo $dirs | sed -e 's;^.*,;;'` 1.129 + 1.130 + # show us the command we are executing 1.131 + echo ${PROFILETOOL} ${BINDIR}/multinit --order $order --main_command $main_command --lib1_command $lib1_command --lib2_command $lib2_command $shutdown_command --main_db $main_db --lib1_db $lib1_db --lib2_db $lib2_db $ro_command --main_token_name "Main" --lib1_token_name "Lib1" --lib2_token_name "Lib2" --verbose --summary 1.132 + 1.133 + # execute the command an collect the result. Most of the user 1.134 + # visible output goes to stderr, so it's not captured by the pipe 1.135 + actual_result=`${PROFILETOOL} ${BINDIR}/multinit --order $order --main_command $main_command --lib1_command $lib1_command --lib2_command $lib2_command $shutdown_command --main_db $main_db --lib1_db $lib1_db --lib2_db $lib2_db $ro_command --main_token_name "Main" --lib1_token_name "Lib1" --lib2_token_name "Lib2" --verbose --summary | grep "^result=" | sed -e 's;^result=;;'` 1.136 + 1.137 + # show what we got and what we expected for diagnostic purposes 1.138 + echo "actual = |$actual_result|" 1.139 + echo "expected = |$expected_result|" 1.140 + test "$actual_result" == "$expected_result" 1.141 + html_msg $? 0 "$testname" 1.142 + fi 1.143 + done 1.144 +} 1.145 + 1.146 +############################## multinit_cleanup ########################### 1.147 +# local shell function to finish this script (no exit since it might be 1.148 +# sourced) 1.149 +######################################################################## 1.150 +multinit_cleanup() 1.151 +{ 1.152 + html "</TABLE><BR>" 1.153 + cd ${QADIR} 1.154 + . common/cleanup.sh 1.155 +} 1.156 + 1.157 +################## main ################################################# 1.158 + 1.159 +multinit_init 1.160 +multinit_main 1.161 +multinit_cleanup