diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /security/nss/tests/multinit | |
parent | Initial commit. (diff) | |
download | thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.tar.xz thunderbird-9e3c08db40b8916968b9f30096c7be3f00ce9647.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'security/nss/tests/multinit')
-rwxr-xr-x | security/nss/tests/multinit/multinit.sh | 158 | ||||
-rw-r--r-- | security/nss/tests/multinit/multinit.txt | 79 |
2 files changed, 237 insertions, 0 deletions
diff --git a/security/nss/tests/multinit/multinit.sh b/security/nss/tests/multinit/multinit.sh new file mode 100755 index 0000000000..6ec605f0e8 --- /dev/null +++ b/security/nss/tests/multinit/multinit.sh @@ -0,0 +1,158 @@ +#! /bin/sh +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +######################################################################## +# +# mozilla/security/nss/tests/multinit/multinit.sh +# +# Script to test NSS multinit +# +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +######################################################################## + +############################## multinit_init ############################## +# local shell function to initialize this script +######################################################################## +multinit_init() +{ + SCRIPTNAME=multinit.sh # sourced - $0 would point to all.sh + + if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for + CLEANUP="${SCRIPTNAME}" # cleaning this script will do it + fi + + if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then + cd ../common + . ./init.sh + fi + if [ ! -r $CERT_LOG_FILE ]; then # we need certificates here + cd ../cert + . ./cert.sh + fi + SCRIPTNAME=multinit.sh + + html_head "MULTI Tests" + + grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || { + Exit 11 "Fatal - S/MIME of cert.sh needs to pass first" + } + + # set up our directories + MULTINITDIR=${HOSTDIR}/multinit + MULTINITDIR_1=${MULTINITDIR}/dir1 + MULTINITDIR_2=${MULTINITDIR}/dir2 + MULTINITDIR_3=${MULTINITDIR}/dir3 + R_MULINITDIR=../multinit + R_MULTINITDIR_1=${R_MULTINITDIR}/dir1 + R_MULTINITDIR_2=${R_MULTINITDIR}/dir2 + R_MULTINITDIR_3=${R_MULTINITDIR}/dir3 + # first create them all + mkdir -p ${MULTINITDIR} + mkdir -p ${MULTINITDIR_1} + mkdir -p ${MULTINITDIR_2} + mkdir -p ${MULTINITDIR_3} + # now copy them fro alice, bob, and dave + cd ${MULTINITDIR} + cp ${P_R_ALICEDIR}/* ${MULTINITDIR_1}/ + cp ${P_R_BOBDIR}/* ${MULTINITDIR_2}/ + cp ${P_R_DAVEDIR}/* ${MULTINITDIR_3}/ + # finally delete the RootCerts module to keep the certificate noice in the + # summary lines down + echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_1} + echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_2} + echo | modutil -delete RootCerts -dbdir ${MULTINITDIR_3} + MULTINIT_TESTS=${QADIR}/multinit/multinit.txt +} + + +############################## multinit_main ############################## +# local shell function to test basic signed and enveloped messages +# from 1 --> 2" +######################################################################## +multinit_main() +{ + html_head "Multi init interface testing" + exec < ${MULTINIT_TESTS} + while read order commands shutdown_type dirs readonly testname + do + if [ "$order" != "#" ]; then + read tag expected_result + + # handle the case where we expect different results based on + # the database type. + if [ "$tag" != "all" ]; then + read tag2 expected_result2 + if [ "$NSS_DEFAULT_DB_TYPE" == "$tag2" ]; then + expected_result=$expected_result2 + fi + fi + + # convert shutdown type to option flags + shutdown_command=""; + if [ "$shutdown_type" == "old" ]; then + shutdown_command="--oldStype" + fi + + # convert read only to option flags + ro_command=""; + case $readonly in + all) ro_command="--main_readonly --lib1_readonly --lib2_readonly";; + libs) ro_command="--lib1_readonly --lib2_readonly";; + main) ro_command="--main_readonly";; + lib1) ro_command="--lib1_readonly";; + lib2) ro_command="--lib2_readonly";; + none) ;; + *) ;; + esac + + # convert commands to option flags + main_command=`echo $commands | sed -e 's;,.*$;;'` + lib1_command=`echo $commands | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'` + lib2_command=`echo $commands | sed -e 's;^.*,;;'` + + # convert db's to option flags + main_db=`echo $dirs | sed -e 's;,.*$;;'` + lib1_db=`echo $dirs | sed -e 's;,.*,;+&+;' -e 's;^.*+,;;' -e 's;,+.*$;;'` + lib2_db=`echo $dirs | sed -e 's;^.*,;;'` + + # show us the command we are executing + 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 + + # execute the command an collect the result. Most of the user + # visible output goes to stderr, so it's not captured by the pipe + 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=;;'` + + # show what we got and what we expected for diagnostic purposes + echo "actual = |$actual_result|" + echo "expected = |$expected_result|" + test "$actual_result" == "$expected_result" + html_msg $? 0 "$testname" + fi + done +} + +############################## multinit_cleanup ########################### +# local shell function to finish this script (no exit since it might be +# sourced) +######################################################################## +multinit_cleanup() +{ + html "</TABLE><BR>" + cd ${QADIR} + . common/cleanup.sh +} + +################## main ################################################# + +multinit_init +multinit_main +multinit_cleanup diff --git a/security/nss/tests/multinit/multinit.txt b/security/nss/tests/multinit/multinit.txt new file mode 100644 index 0000000000..d5296dc0e2 --- /dev/null +++ b/security/nss/tests/multinit/multinit.txt @@ -0,0 +1,79 @@ +# +# This file defines the tests for multiple initialization of NSS in +# different libraries. +# +# Test description lines control the parameters for the multinit test program. +# +# Init order: Upper case/digits indicate an init call, lower case indicate +# a shutdown call. +# M,m-Main 1,i-lib1, 2,z-lib2 +# Main calls the traditional NSS init calls (simulating the main application) +# lib1 and lib2 call NSS_InitContext(). +# +# All functions call NSS_ShutdownContext unless 'main shutdown type' is set to +# 'old', in which case main will call the traditional NSS_Shutdown(). +# +# Commands: comma separated list of commands to execute. These simulate +# executing commands from either a library or main. In each cycle, multinit +# will do one initialize or shutdown, then execute all the commands +# for any of the libraries or main that is currently initialized. The same +# command is executed in each cycle that it's library is initialized. +# +# Commands are given in order or 'main','lib1','lib2'. Valid commands are: +# none - don't execute any commands for this library (or main). +# list_certs - list all the visible certs in the system. +# list_slots - list all the slots in the system. +# key_slot - list the current default key slot. +# +# Main Shutdown Type - which kind of shutdown does main call. See Init order. +# +# Directories - which directory should each init open. Listed in order of: +# (main init directory),(lib1 init directory),(lib2 init directory). +# +# RO - Which databases to open up read only, valid values are: +# all - main, lib1, and lib2 +# none - open all directories R/W +# libs - lib1 & lib2 +# main, lib1, lib2 - their respective directories only. +# +# Test description lines are followed by their expected summary output. +# output lines are of the form: +# +# tag expected output. +# +# where tag is one of +# all - applies to all database types +# sql - expected output for sql databases +# dbm - expected output for dbm databases +# +# if you do not specify all, you must have one line each for sql and dbm +# +# main +# init main,lib1,lib2 shutdown main,lib1,lib2 Test Case name +# order commands type directories RO +# ------ ------------------------ --- ----------- ----- -------------- + 1M2zmi list_slots,list_certs,none new dir1,dir2,dir3 all Progressive init +all 1C<Bob>uuuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCCMS<NSS Generic Crypto Services>ttS<Main>ttS<Lib1>ttC<Alice>uuuC<Bob>pupupuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCC2S<NSS Generic Crypto Services>ttS<Lib2>ttS<Main>ttS<Lib1>ttC<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCZS<NSS Generic Crypto Services>ttS<Lib2>ttS<Main>ttS<Lib1>ttC<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCNC<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCI + 1M2zmi list_certs,none,none old dir1,dir2,dir3 all Progressive init - oldStyle +all 1MC<Alice>uuuC<Bob>pupupuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCC2C<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCZC<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCNIE0xffffe09a + 12Mizm none,list_certs,none new dir1,dir2,dir3 all Sequenced init +all 1C<Bob>uuuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCC2C<Bob>uuuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCMC<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCIZN + 12Mizm none,list_certs,none old dir1,dir2,dir3 all Sequenced init - old Style +all 1C<Bob>uuuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCC2C<Bob>uuuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCMC<Alice>uuuC<Bob>pupupuC<Dave>pupupuC<Eve>pppC<NSS Test CA>CTCCIZN + 1Mi2mz none,list_certs,list_slots new dir1,dir2,dir3 all Overlap shutdown +all 1C<Bob>uuuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCCMC<Alice>uuuC<Bob>pupupuC<Dave>pppC<Eve>pppC<NSS Test CA>CTCCI2S<NSS Generic Crypto Services>ttS<Lib2>ttS<Main>ttS<Lib1>ttNS<NSS Generic Crypto Services>ttS<Lib2>ttS<Main>ttS<Lib1>ttZ + 1Mi2mz none,key_slot,none new dir1,dir2,dir3 all Keyslot test +all 1S<Lib1>ttMS<Main>ttI2NZ + M12miz none,key_slot,none new dir1,dir2,dir3 all Main init first +all M1S<Main>tt2S<Main>ttNS<Main>ttIZ + M12miz key_slot,none,none old dir1,dir2,dir3 all Main init first - old Style +all MS<Main>tt1S<Main>tt2S<Main>ttNIE0xffffe09aZE0xffffe09a + M12miz list_slots,none,none new dir1,dir1,dir2 all Loading the same directory twice +all MS<NSS Generic Crypto Services>ttS<Main>tt1S<NSS Generic Crypto Services>ttS<Main>tt2S<NSS Generic Crypto Services>ttS<Lib2>ttS<Main>ttNIZ + M12miz list_slots,none,none new dir1,dir1,dir2 libs Loading the same directory twice - r/w then ro +all MS<NSS Generic Crypto Services>ttS<Main>tf1S<NSS Generic Crypto Services>ttS<Main>tf2S<NSS Generic Crypto Services>ttS<Lib2>ttS<Main>tfNIZ + M12miz list_slots,none,none new dir1,dir1,dir2 main Loading the same directory twice - ro then r/w +sql MS<NSS Generic Crypto Services>ttS<Main>tt1S<NSS Generic Crypto Services>ttS<Lib1>tfS<Main>tt2S<NSS Generic Crypto Services>ttS<Lib2>tfS<Lib1>tfS<Main>ttNIZ +dbm MS<NSS Generic Crypto Services>ttS<Main>tt1S<NSS Generic Crypto Services>ttS<Main>tt2S<NSS Generic Crypto Services>ttS<Lib2>tfS<Main>ttNIZ + M12miM1zim key_slot,none,none old dir1,dir2,dir3 all Properly detect shutdown of a closed handle +all MS<Main>tt1S<Main>tt2S<Main>ttNIE0xffffe09aMS<Main>tt1S<Main>ttZE0xffffe09aS<Main>ttIS<Main>ttN |