3
# ***** BEGIN LICENSE BLOCK *****
4
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
6
# The contents of this file are subject to the Mozilla Public License Version
7
# 1.1 (the "License"); you may not use this file except in compliance with
8
# the License. You may obtain a copy of the License at
9
# http://www.mozilla.org/MPL/
11
# Software distributed under the License is distributed on an "AS IS" basis,
12
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
# for the specific language governing rights and limitations under the
16
# The Original Code is the Netscape security libraries.
18
# The Initial Developer of the Original Code is
19
# Netscape Communications Corporation.
20
# Portions created by the Initial Developer are Copyright (C) 1994-2000
21
# the Initial Developer. All Rights Reserved.
24
# Dr Vipul Gupta <vipul.gupta@sun.com>, Sun Microsystems Laboratories
26
# Alternatively, the contents of this file may be used under the terms of
27
# either the GNU General Public License Version 2 or later (the "GPL"), or
28
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
# in which case the provisions of the GPL or the LGPL are applicable instead
30
# of those above. If you wish to allow use of your version of this file only
31
# under the terms of either the GPL or the LGPL, and not to allow others to
32
# use your version of this file under the terms of the MPL, indicate your
33
# decision by deleting the provisions above and replace them with the notice
34
# and other provisions required by the GPL or the LGPL. If you do not delete
35
# the provisions above, a recipient may use your version of this file under
36
# the terms of any one of the MPL, the GPL or the LGPL.
38
# ***** END LICENSE BLOCK *****
40
########################################################################
42
# mozilla/security/nss/tests/multinit/multinit.sh
44
# Script to test NSS multinit
46
# needs to work on all Unix and Windows platforms
50
# FIXME ... known problems, search for this string
51
# NOTE .... unexpected behavior
53
########################################################################
55
############################## multinit_init ##############################
56
# local shell function to initialize this script
57
########################################################################
60
SCRIPTNAME=multinit.sh # sourced - $0 would point to all.sh
62
if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
63
CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
66
if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
70
if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here
74
SCRIPTNAME=multinit.sh
76
html_head "MULTI Tests"
78
grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || {
79
Exit 11 "Fatal - S/MIME of cert.sh needs to pass first"
82
# set up our directories
83
MULTINITDIR=${HOSTDIR}/multinit
84
MULTINITDIR_1=${MULTINITDIR}/dir1
85
MULTINITDIR_2=${MULTINITDIR}/dir2
86
MULTINITDIR_3=${MULTINITDIR}/dir3
87
R_MULINITDIR=../multinit
88
R_MULTINITDIR_1=${R_MULTINITDIR}/dir1
89
R_MULTINITDIR_2=${R_MULTINITDIR}/dir2
90
R_MULTINITDIR_3=${R_MULTINITDIR}/dir3
91
# first create them all
92
mkdir -p ${MULTINITDIR}
93
mkdir -p ${MULTINITDIR_1}
94
mkdir -p ${MULTINITDIR_2}
95
mkdir -p ${MULTINITDIR_3}
96
# now copy them fro alice, bob, and dave
98
cp ${P_R_ALICEDIR}/* ${MULTINITDIR_1}/
99
cp ${P_R_BOBDIR}/* ${MULTINITDIR_2}/
100
cp ${P_R_DAVEDIR}/* ${MULTINITDIR_3}/
101
# finally delete the RootCerts module to keep the certificate noice in the
103
echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_1}
104
echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_2}
105
echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_3}
106
MULTINIT_TESTS=${QADIR}/multinit/multinit.txt
110
############################## multinit_main ##############################
111
# local shell function to test basic signed and enveloped messages
113
########################################################################
116
html_head "Multi init interface testing"
117
exec < ${MULTINIT_TESTS}
118
while read order commands shutdown_type dirs readonly testname
120
if [ "$order" != "#" ]; then
121
read tag expected_result
123
# handle the case where we expect different results based on
125
if [ "$tag" != "all" ]; then
126
read tag2 expected_result2
127
if [ "$NSS_DEFAULT_DB_TYPE" == "$tag2" ]; then
128
expected_result=$expected_result2
132
# convert shutdown type to option flags
134
if [ "$shutdown_type" == "old" ]; then
135
shutdown_command="--oldStype"
138
# convert read only to option flags
141
all) ro_command="--main_readonly --lib1_readonly --lib2_readonly";;
142
libs) ro_command="--lib1_readonly --lib2_readonly";;
143
main) ro_command="--main_readonly";;
144
lib1) ro_command="--lib1_readonly";;
145
lib2) ro_command="--lib2_readonly";;
150
# convert commands to option flags
151
main_command=`echo $commands | sed -e 's;,.*$;;'`
152
lib1_command=`echo $commands | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'`
153
lib2_command=`echo $commands | sed -e 's;^.*,;;'`
155
# convert db's to option flags
156
main_db=`echo $dirs | sed -e 's;,.*$;;'`
157
lib1_db=`echo $dirs | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'`
158
lib2_db=`echo $dirs | sed -e 's;^.*,;;'`
160
# show us the command we are executing
161
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
163
# execute the command an collect the result. Most of the user
164
# visible output goes to stderr, so it's not captured by the pipe
165
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=;;'`
167
# show what we got and what we expected for diagnostic purposes
168
echo "actual = |$actual_result|"
169
echo "expected = |$expected_result|"
170
test "$actual_result" == "$expected_result"
171
html_msg $? 0 "$testname"
176
############################## multinit_cleanup ###########################
177
# local shell function to finish this script (no exit since it might be
179
########################################################################
187
################## main #################################################