michael@0: #! /bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ######################################################################## michael@0: # michael@0: # mozilla/security/nss/tests/multinit/multinit.sh michael@0: # michael@0: # Script to test NSS multinit michael@0: # michael@0: # needs to work on all Unix and Windows platforms michael@0: # michael@0: # special strings michael@0: # --------------- michael@0: # FIXME ... known problems, search for this string michael@0: # NOTE .... unexpected behavior michael@0: # michael@0: ######################################################################## michael@0: michael@0: ############################## multinit_init ############################## michael@0: # local shell function to initialize this script michael@0: ######################################################################## michael@0: multinit_init() michael@0: { michael@0: SCRIPTNAME=multinit.sh # sourced - $0 would point to all.sh michael@0: michael@0: if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for michael@0: CLEANUP="${SCRIPTNAME}" # cleaning this script will do it michael@0: fi michael@0: michael@0: if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then michael@0: cd ../common michael@0: . ./init.sh michael@0: fi michael@0: if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here michael@0: cd ../cert michael@0: . ./cert.sh michael@0: fi michael@0: SCRIPTNAME=multinit.sh michael@0: michael@0: html_head "MULTI Tests" michael@0: michael@0: grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || { michael@0: Exit 11 "Fatal - S/MIME of cert.sh needs to pass first" michael@0: } michael@0: michael@0: # set up our directories michael@0: MULTINITDIR=${HOSTDIR}/multinit michael@0: MULTINITDIR_1=${MULTINITDIR}/dir1 michael@0: MULTINITDIR_2=${MULTINITDIR}/dir2 michael@0: MULTINITDIR_3=${MULTINITDIR}/dir3 michael@0: R_MULINITDIR=../multinit michael@0: R_MULTINITDIR_1=${R_MULTINITDIR}/dir1 michael@0: R_MULTINITDIR_2=${R_MULTINITDIR}/dir2 michael@0: R_MULTINITDIR_3=${R_MULTINITDIR}/dir3 michael@0: # first create them all michael@0: mkdir -p ${MULTINITDIR} michael@0: mkdir -p ${MULTINITDIR_1} michael@0: mkdir -p ${MULTINITDIR_2} michael@0: mkdir -p ${MULTINITDIR_3} michael@0: # now copy them fro alice, bob, and dave michael@0: cd ${MULTINITDIR} michael@0: cp ${P_R_ALICEDIR}/* ${MULTINITDIR_1}/ michael@0: cp ${P_R_BOBDIR}/* ${MULTINITDIR_2}/ michael@0: cp ${P_R_DAVEDIR}/* ${MULTINITDIR_3}/ michael@0: # finally delete the RootCerts module to keep the certificate noice in the michael@0: # summary lines down michael@0: echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_1} michael@0: echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_2} michael@0: echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_3} michael@0: MULTINIT_TESTS=${QADIR}/multinit/multinit.txt michael@0: } michael@0: michael@0: michael@0: ############################## multinit_main ############################## michael@0: # local shell function to test basic signed and enveloped messages michael@0: # from 1 --> 2" michael@0: ######################################################################## michael@0: multinit_main() michael@0: { michael@0: html_head "Multi init interface testing" michael@0: exec < ${MULTINIT_TESTS} michael@0: while read order commands shutdown_type dirs readonly testname michael@0: do michael@0: if [ "$order" != "#" ]; then michael@0: read tag expected_result michael@0: michael@0: # handle the case where we expect different results based on michael@0: # the database type. michael@0: if [ "$tag" != "all" ]; then michael@0: read tag2 expected_result2 michael@0: if [ "$NSS_DEFAULT_DB_TYPE" == "$tag2" ]; then michael@0: expected_result=$expected_result2 michael@0: fi michael@0: fi michael@0: michael@0: # convert shutdown type to option flags michael@0: shutdown_command=""; michael@0: if [ "$shutdown_type" == "old" ]; then michael@0: shutdown_command="--oldStype" michael@0: fi michael@0: michael@0: # convert read only to option flags michael@0: ro_command=""; michael@0: case $readonly in michael@0: all) ro_command="--main_readonly --lib1_readonly --lib2_readonly";; michael@0: libs) ro_command="--lib1_readonly --lib2_readonly";; michael@0: main) ro_command="--main_readonly";; michael@0: lib1) ro_command="--lib1_readonly";; michael@0: lib2) ro_command="--lib2_readonly";; michael@0: none) ;; michael@0: *) ;; michael@0: esac michael@0: michael@0: # convert commands to option flags michael@0: main_command=`echo $commands | sed -e 's;,.*$;;'` michael@0: lib1_command=`echo $commands | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'` michael@0: lib2_command=`echo $commands | sed -e 's;^.*,;;'` michael@0: michael@0: # convert db's to option flags michael@0: main_db=`echo $dirs | sed -e 's;,.*$;;'` michael@0: lib1_db=`echo $dirs | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'` michael@0: lib2_db=`echo $dirs | sed -e 's;^.*,;;'` michael@0: michael@0: # show us the command we are executing michael@0: 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 michael@0: michael@0: # execute the command an collect the result. Most of the user michael@0: # visible output goes to stderr, so it's not captured by the pipe michael@0: 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=;;'` michael@0: michael@0: # show what we got and what we expected for diagnostic purposes michael@0: echo "actual = |$actual_result|" michael@0: echo "expected = |$expected_result|" michael@0: test "$actual_result" == "$expected_result" michael@0: html_msg $? 0 "$testname" michael@0: fi michael@0: done michael@0: } michael@0: michael@0: ############################## multinit_cleanup ########################### michael@0: # local shell function to finish this script (no exit since it might be michael@0: # sourced) michael@0: ######################################################################## michael@0: multinit_cleanup() michael@0: { michael@0: html "
" michael@0: cd ${QADIR} michael@0: . common/cleanup.sh michael@0: } michael@0: michael@0: ################## main ################################################# michael@0: michael@0: multinit_init michael@0: multinit_main michael@0: multinit_cleanup