security/nss/tests/multinit/multinit.sh

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 #! /bin/sh
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 ########################################################################
michael@0 8 #
michael@0 9 # mozilla/security/nss/tests/multinit/multinit.sh
michael@0 10 #
michael@0 11 # Script to test NSS multinit
michael@0 12 #
michael@0 13 # needs to work on all Unix and Windows platforms
michael@0 14 #
michael@0 15 # special strings
michael@0 16 # ---------------
michael@0 17 # FIXME ... known problems, search for this string
michael@0 18 # NOTE .... unexpected behavior
michael@0 19 #
michael@0 20 ########################################################################
michael@0 21
michael@0 22 ############################## multinit_init ##############################
michael@0 23 # local shell function to initialize this script
michael@0 24 ########################################################################
michael@0 25 multinit_init()
michael@0 26 {
michael@0 27 SCRIPTNAME=multinit.sh # sourced - $0 would point to all.sh
michael@0 28
michael@0 29 if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
michael@0 30 CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
michael@0 31 fi
michael@0 32
michael@0 33 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
michael@0 34 cd ../common
michael@0 35 . ./init.sh
michael@0 36 fi
michael@0 37 if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here
michael@0 38 cd ../cert
michael@0 39 . ./cert.sh
michael@0 40 fi
michael@0 41 SCRIPTNAME=multinit.sh
michael@0 42
michael@0 43 html_head "MULTI Tests"
michael@0 44
michael@0 45 grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || {
michael@0 46 Exit 11 "Fatal - S/MIME of cert.sh needs to pass first"
michael@0 47 }
michael@0 48
michael@0 49 # set up our directories
michael@0 50 MULTINITDIR=${HOSTDIR}/multinit
michael@0 51 MULTINITDIR_1=${MULTINITDIR}/dir1
michael@0 52 MULTINITDIR_2=${MULTINITDIR}/dir2
michael@0 53 MULTINITDIR_3=${MULTINITDIR}/dir3
michael@0 54 R_MULINITDIR=../multinit
michael@0 55 R_MULTINITDIR_1=${R_MULTINITDIR}/dir1
michael@0 56 R_MULTINITDIR_2=${R_MULTINITDIR}/dir2
michael@0 57 R_MULTINITDIR_3=${R_MULTINITDIR}/dir3
michael@0 58 # first create them all
michael@0 59 mkdir -p ${MULTINITDIR}
michael@0 60 mkdir -p ${MULTINITDIR_1}
michael@0 61 mkdir -p ${MULTINITDIR_2}
michael@0 62 mkdir -p ${MULTINITDIR_3}
michael@0 63 # now copy them fro alice, bob, and dave
michael@0 64 cd ${MULTINITDIR}
michael@0 65 cp ${P_R_ALICEDIR}/* ${MULTINITDIR_1}/
michael@0 66 cp ${P_R_BOBDIR}/* ${MULTINITDIR_2}/
michael@0 67 cp ${P_R_DAVEDIR}/* ${MULTINITDIR_3}/
michael@0 68 # finally delete the RootCerts module to keep the certificate noice in the
michael@0 69 # summary lines down
michael@0 70 echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_1}
michael@0 71 echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_2}
michael@0 72 echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_3}
michael@0 73 MULTINIT_TESTS=${QADIR}/multinit/multinit.txt
michael@0 74 }
michael@0 75
michael@0 76
michael@0 77 ############################## multinit_main ##############################
michael@0 78 # local shell function to test basic signed and enveloped messages
michael@0 79 # from 1 --> 2"
michael@0 80 ########################################################################
michael@0 81 multinit_main()
michael@0 82 {
michael@0 83 html_head "Multi init interface testing"
michael@0 84 exec < ${MULTINIT_TESTS}
michael@0 85 while read order commands shutdown_type dirs readonly testname
michael@0 86 do
michael@0 87 if [ "$order" != "#" ]; then
michael@0 88 read tag expected_result
michael@0 89
michael@0 90 # handle the case where we expect different results based on
michael@0 91 # the database type.
michael@0 92 if [ "$tag" != "all" ]; then
michael@0 93 read tag2 expected_result2
michael@0 94 if [ "$NSS_DEFAULT_DB_TYPE" == "$tag2" ]; then
michael@0 95 expected_result=$expected_result2
michael@0 96 fi
michael@0 97 fi
michael@0 98
michael@0 99 # convert shutdown type to option flags
michael@0 100 shutdown_command="";
michael@0 101 if [ "$shutdown_type" == "old" ]; then
michael@0 102 shutdown_command="--oldStype"
michael@0 103 fi
michael@0 104
michael@0 105 # convert read only to option flags
michael@0 106 ro_command="";
michael@0 107 case $readonly in
michael@0 108 all) ro_command="--main_readonly --lib1_readonly --lib2_readonly";;
michael@0 109 libs) ro_command="--lib1_readonly --lib2_readonly";;
michael@0 110 main) ro_command="--main_readonly";;
michael@0 111 lib1) ro_command="--lib1_readonly";;
michael@0 112 lib2) ro_command="--lib2_readonly";;
michael@0 113 none) ;;
michael@0 114 *) ;;
michael@0 115 esac
michael@0 116
michael@0 117 # convert commands to option flags
michael@0 118 main_command=`echo $commands | sed -e 's;,.*$;;'`
michael@0 119 lib1_command=`echo $commands | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'`
michael@0 120 lib2_command=`echo $commands | sed -e 's;^.*,;;'`
michael@0 121
michael@0 122 # convert db's to option flags
michael@0 123 main_db=`echo $dirs | sed -e 's;,.*$;;'`
michael@0 124 lib1_db=`echo $dirs | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'`
michael@0 125 lib2_db=`echo $dirs | sed -e 's;^.*,;;'`
michael@0 126
michael@0 127 # show us the command we are executing
michael@0 128 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 129
michael@0 130 # execute the command an collect the result. Most of the user
michael@0 131 # visible output goes to stderr, so it's not captured by the pipe
michael@0 132 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 133
michael@0 134 # show what we got and what we expected for diagnostic purposes
michael@0 135 echo "actual = |$actual_result|"
michael@0 136 echo "expected = |$expected_result|"
michael@0 137 test "$actual_result" == "$expected_result"
michael@0 138 html_msg $? 0 "$testname"
michael@0 139 fi
michael@0 140 done
michael@0 141 }
michael@0 142
michael@0 143 ############################## multinit_cleanup ###########################
michael@0 144 # local shell function to finish this script (no exit since it might be
michael@0 145 # sourced)
michael@0 146 ########################################################################
michael@0 147 multinit_cleanup()
michael@0 148 {
michael@0 149 html "</TABLE><BR>"
michael@0 150 cd ${QADIR}
michael@0 151 . common/cleanup.sh
michael@0 152 }
michael@0 153
michael@0 154 ################## main #################################################
michael@0 155
michael@0 156 multinit_init
michael@0 157 multinit_main
michael@0 158 multinit_cleanup

mercurial