diff options
author | sonmi%netscape.com <devnull@localhost> | 2001-02-28 22:12:47 +0000 |
---|---|---|
committer | sonmi%netscape.com <devnull@localhost> | 2001-02-28 22:12:47 +0000 |
commit | d99c8edb6ef5b8f87e84f03313d9a530b5eba19d (patch) | |
tree | 5eee6e1599a6e7839a0ff067bc93563549fd2db4 | |
parent | 7cec4c478ecf26caf6a0f681276960f53f1fc1aa (diff) | |
download | nss-hg-d99c8edb6ef5b8f87e84f03313d9a530b5eba19d.tar.gz |
complete restructuring and cleanup of the QA suites.
bug 65000 and 68878
-rwxr-xr-x | security/nss/tests/all.sh | 141 | ||||
-rwxr-xr-x | security/nss/tests/cipher/cipher.sh | 311 | ||||
-rw-r--r-- | security/nss/tests/cipher/cipher.txt | 29 | ||||
-rwxr-xr-x | security/nss/tests/common/cleanup.sh | 48 | ||||
-rw-r--r-- | security/nss/tests/common/init.sh | 361 | ||||
-rwxr-xr-x | security/nss/tests/perf/perf.sh | 79 | ||||
-rwxr-xr-x | security/nss/tests/sdr/sdr.sh | 166 | ||||
-rwxr-xr-x | security/nss/tests/smime/smime.sh | 459 | ||||
-rwxr-xr-x | security/nss/tests/ssl/ssl.sh | 667 |
9 files changed, 1171 insertions, 1090 deletions
diff --git a/security/nss/tests/all.sh b/security/nss/tests/all.sh index da38e7137..961c9e061 100755 --- a/security/nss/tests/all.sh +++ b/security/nss/tests/all.sh @@ -1,51 +1,116 @@ #!/bin/sh # -# Run all our tests -# -ALL_SH_BASEPATH=$PATH #to avoid that PATH is being appended every time -export ALL_SH_BASEPATH #init is sourced -CURDIR=`pwd` -TESTS="sdr ssl cipher smime perf" -cd common -. ./init.sh -export MOZILLA_ROOT -export COMMON -export DIST -export SECURITY_ROOT -export TESTDIR -export OBJDIR -export HOSTDIR - -LOGFILE=${HOSTDIR}/output.log -export LOGFILE -touch ${LOGFILE} +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# +######################################################################## +# +# mozilla/security/nss/tests/all.sh +# +# Script to start all available NSS QA suites on one machine +# this script is called or sourced by nssqa which runs on all required +# platforms +# +# needs to work on all Unix and Windows platforms +# +# currently available NSS QA suites: +# -------------------------------------------------- +# cert.sh - exercises certutil and creates certs necessary for all +# other tests +# ssl.sh - tests SSL V2 SSL V3 and TLS +# smime.sh - S/MIME testing +# sdr.sh - test NSS SDR +# cipher.sh - test NSS ciphers +# perf.sh - Nightly performance measurments +# tools.sh - Tests the majority of the NSS tools +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +# NOTE: +# ----- +# Unlike the old QA this is based on files sourcing each other +# This is done to save time, since a great portion of time is lost +# in calling and sourcing the same things multiple times over the +# network. Also, this way all scripts have all shell function available +# and a completely common environment +# +# file tells the test suite that the output is going to a log, so any +# forked() children need to redirect their output to prevent them from +# being over written. +# I need to test how this works with the sourced scripts now... +# +######################################################################## + +#FIXME - all will be sourced by the wrapper wrapper will do cleanup etc + +TESTS="cert ssl sdr cipher smime perf" #tools is temporarily disabled + #since it fails on a few platforms +SCRIPTNAME=all.sh +CLEANUP="${SCRIPTNAME}" +cd `dirname $0` #FIXME - if sourced + +#all.sh is the one that always needs to source the init - just to be consistant +if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then + cd common + . init.sh +fi if [ -z "O_CRON" -o "$O_CRON" != "ON" ] then - tail -f ${LOGFILE} & - TAILPID=$! - trap "kill ${TAILPID}; exit" 2 + tail -f ${LOGFILE} & + TAILPID=$! fi for i in ${TESTS} do - echo "Running Tests for $i" -# -# All tells the test suite to run through all their tests. -# file tells the test suite that the output is going to a log, so any -# forked() children need to redirect their output to prevent them from -# being over written. - - (cd ${CURDIR}/$i ; ./${i}.sh all file >> ${LOGFILE} 2>&1) -# cd ${CURDIR}/$i ; ./${i}.sh + SCRIPTNAME=${i}.sh + echo "Running Tests for $i" + (cd ${QADIR}/$i ; . $SCRIPTNAME all file >> ${LOGFILE} 2>&1) done + +SCRIPTNAME=all.sh + if [ -z "O_CRON" -o "$O_CRON" != "ON" ] then - kill ${TAILPID} - if [ -n "$os_name" -a "$os_name" = "Windows" ] - then - echo "MKS special - killing the tail -f" - kill `ps | grep "tail -f ${LOGFILE}" | grep -v grep | - sed -e "s/^ *//" -e "s/ *//"` - fi + kill ${TAILPID} + if [ -n "$os_name" -a "$os_name" = "Windows" ] + then + echo "MKS special - killing the tail -f" + kill `ps | grep "tail -f ${LOGFILE}" | grep -v grep | + sed -e "s/^ *//" -e "s/ *//"` + fi fi + +. ${QADIR}/common/cleanup.sh diff --git a/security/nss/tests/cipher/cipher.sh b/security/nss/tests/cipher/cipher.sh index 556a46100..9a688bb19 100755 --- a/security/nss/tests/cipher/cipher.sh +++ b/security/nss/tests/cipher/cipher.sh @@ -1,211 +1,110 @@ #! /bin/ksh # -# This is just a quick script so we can still run our testcases. -# Longer term we need a scriptable test environment.. +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. # -. ../common/init.sh -CURDIR=`pwd` - -CIPHERDIR=${HOSTDIR}/cipher -CIPHERTESTDIR=${CURDIR}/../../cmd/bltest - -echo "<HTML><BODY>" >> ${RESULTS} - -#temporary files -TMP=${TMP-/tmp} - -#TEMPFILES="${NOISE_FILE}" - # -# should also try to kill any running server +######################################################################## # -#trap "rm -f ${TEMPFILES}; exit" 2 3 - -mkdir -p ${CIPHERDIR} - -echo "<TABLE BORDER=1><TR><TH COLSPAN=3>Cipher Tests</TH></TR>" >> ${RESULTS} -echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} - -echo "bltest -T -m des_ecb -E -d ${CIPHERTESTDIR}" -bltest -T -m des_ecb -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"DES ECB Encrypt"} -fi -echo "bltest -T -m des_ecb -D -d ${CIPHERTESTDIR}" -bltest -T -m des_ecb -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"DES ECB Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>DES ECB</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>DES ECB</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m des_cbc -E -d ${CIPHERTESTDIR}" -bltest -T -m des_cbc -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"DES CBC Encrypt"} -fi -echo "bltest -T -m des_cbc -D -d ${CIPHERTESTDIR}" -bltest -T -m des_cbc -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"DES CBC Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>DES CBC</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>DES CBC</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m des3_ecb -E -d ${CIPHERTESTDIR}" -bltest -T -m des3_ecb -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"3DES ECB Encrypt"} -fi -echo "bltest -T -m des3_ecb -D -d ${CIPHERTESTDIR}" -bltest -T -m des3_ecb -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"3DES ECB Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>3DES ECB</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>3DES ECB</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m des3_cbc -E -d ${CIPHERTESTDIR}" -bltest -T -m des3_cbc -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"3DES CBC Encrypt"} -fi -echo "bltest -T -m des3_cbc -D -d ${CIPHERTESTDIR}" -bltest -T -m des3_cbc -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"3DES CBC Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>3DES CBC</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>3DES CBC</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m rc2_ecb -E -d ${CIPHERTESTDIR}" -bltest -T -m rc2_ecb -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RC2 ECB Encrypt"} -fi -echo "bltest -T -m rc2_ecb -D -d ${CIPHERTESTDIR}" -bltest -T -m rc2_ecb -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RC2 ECB Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>RC2 ECB</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>RC2 ECB</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m rc2_cbc -E -d ${CIPHERTESTDIR}" -bltest -T -m rc2_cbc -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RC2 CBC Encrypt"} -fi -echo "bltest -T -m rc2_cbc -D -d ${CIPHERTESTDIR}" -bltest -T -m rc2_cbc -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RC2 CBC Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>RC2 CBC</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>RC2 CBC</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m rc4 -E -d ${CIPHERTESTDIR}" -bltest -T -m rc4 -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RC4 Encrypt"} -fi -echo "bltest -T -m rc4 -D -d ${CIPHERTESTDIR}" -bltest -T -m rc4 -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RC4 Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>RC4</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>RC4</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m rsa -E -d ${CIPHERTESTDIR}" -bltest -T -m rsa -E -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RSA Encrypt"} -fi -echo "bltest -T -m rsa -D -d ${CIPHERTESTDIR}" -bltest -T -m rsa -D -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"RSA Encrypt"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>RSA</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>RSA</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m dsa -S -d ${CIPHERTESTDIR}" -bltest -T -m dsa -S -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"DSA Sign"} -fi -echo "bltest -T -m dsa -V -d ${CIPHERTESTDIR}" -bltest -T -m dsa -V -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"DSA Verify"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>DSA</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>DSA</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m md2 -H -d ${CIPHERTESTDIR}" -bltest -T -m md2 -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"MD2 Hash"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>MD2</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>MD2</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m md5 -H -d ${CIPHERTESTDIR}" -bltest -T -m md5 -H -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"MD5 Hash"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>MD5</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>MD5</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "bltest -T -m sha1 -H -d ${CIPHERTESTDIR}" -bltest -T -m sha1 -H -d ${CIPHERTESTDIR} -if [ $? -ne 0 ]; then - CIPHERFAILED=${CIPHERFAILED-"SHA1 Hash"} -fi -if [ -n "${CIPHERFAILED}" ]; then - echo "<TR><TD>SHA1</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>SHA1</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "</TABLE><BR>" >> ${RESULTS} - -#rm -f ${TEMPFILES} -cd ${CURDIR} - -echo "</BODY></HTML>" >> ${RESULTS} +# mozilla/security/nss/tests/cipher/cipher.sh +# +# Script to test NSS ciphers +# +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +######################################################################## + +############################## cipher_init ############################# +# local shell function to initialize this script +######################################################################## +cipher_init() +{ + SCRIPTNAME="cipher.sh" + if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for + CLEANUP="${SCRIPTNAME}" # cleaning this script will do it + fi + if [ -z "${INIT_SOURCED}" ] ; then + cd ../common + . init.sh + fi + SCRIPTNAME="cipher.sh" + html_head "Cipher Tests" + + CIPHERDIR=${HOSTDIR}/cipher + CIPHERTESTDIR=${QADIR}/../cmd/bltest + + CIPHER_TXT=${QADIR}/cipher/cipher.txt + + mkdir -p ${CIPHERDIR} + + cd ${CIPHERTESTDIR} +} + +############################## cipher_main ############################# +# local shell function to test NSS ciphers +######################################################################## +cipher_main() +{ + cat ${CIPHER_TXT} | while read EXP_RET PARAM TESTNAME + do + if [ -n "$EXP_RET" -a "$EXP_RET" != "#" ] ; then + PARAM=`echo $PARAM | sed -e "s/_-/ -/g"` + TESTNAME=`echo $TESTNAME | sed -e "s/_/ /g"` + echo "$SCRIPTNAME: $TESTNAME --------------------------------" + echo "bltest -T -m $PARAM -d ." + + bltest -T -m $PARAM -d . + html_msg $? $EXP_RET "$TESTNAME" + fi + done +} + +############################## cipher_cleanup ############################ +# local shell function to finish this script (no exit since it might be +# sourced) +######################################################################## +cipher_cleanup() +{ + html "</TABLE><BR>" + cd ${QADIR} + . common/cleanup.sh +} + +################## main ################################################# + +cipher_init +cipher_main +cipher_cleanup diff --git a/security/nss/tests/cipher/cipher.txt b/security/nss/tests/cipher/cipher.txt new file mode 100644 index 000000000..e9f4e9e9b --- /dev/null +++ b/security/nss/tests/cipher/cipher.txt @@ -0,0 +1,29 @@ +# +# This file defines the cipher tests +# +# expected +# return bltest Test Case name +# value params +# ------- ---------- --------------- + 0 des_ecb_-E DES_ECB_Encrypt + 0 des_ecb_-D DES_ECB_Decrypt + 0 des_cbc_-E DES_CBC_Encrypt + 0 des_cbc_-D DES_CBC_Decrypt + 0 des3_ecb_-E DES3_ECB_Encrypt + 0 des3_ecb_-D DES3_ECB_Decrypt + 0 des3_cbc_-E DES3_CBC_Encrypt + 0 des3_cbc_-D DES3_CBC_Decrypt + 0 rc2_ecb_-E RC2_ECB_Encrypt + 0 rc2_ecb_-D RC2_ECB_Decrypt + 0 rc2_cbc_-E RC2_CBC_Encrypt + 0 rc2_cbc_-D RC2_CBC_Decrypt + 0 rc4_-E RC4_Encrypt + 0 rc4_-D RC4_Decrypt + 0 rsa_-E RSA_Encrypt + 0 rsa_-D RSA_Decrypt + 0 dsa_-S DSA_Sign + 0 dsa_-V DSA_Verify + 0 md2_-H MD2_Hash + 0 md5_-H MD5_Hash + 0 sha1_-H SHA1_Hash + diff --git a/security/nss/tests/common/cleanup.sh b/security/nss/tests/common/cleanup.sh new file mode 100755 index 000000000..57d71dc48 --- /dev/null +++ b/security/nss/tests/common/cleanup.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# +######################################################################## +# +# mozilla/security/nss/tests/common/cleanup.sh +# +# Script to clean up after NSS QA suites +# needs to work on all Unix and Windows platforms +# +######################################################################## + + +if [ -z "${CLEANUP}" -o "${CLEANUP}" = "${SCRIPTNAME}" ]; then + html "</BODY></HTML>" + rm -f ${TEMPFILES} 2>/dev/null +fi diff --git a/security/nss/tests/common/init.sh b/security/nss/tests/common/init.sh index f801f17e8..e09b2e42d 100644 --- a/security/nss/tests/common/init.sh +++ b/security/nss/tests/common/init.sh @@ -1,103 +1,302 @@ #! /bin/sh # -# Initialize a bunch of variables that may tests would be interested in +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. # # +######################################################################## +# +# mozilla/security/nss/tests/common/init.sh +# +# initialization for NSS QA, can be included multiple times +# from all.sh and the individual scripts +# +# variables, utilities and shellfunctions global to NSS QA +# needs to work on all Unix and Windows platforms +# +# included from (don't expect this to be up to date) +# -------------------------------------------------- +# all.sh +# ssl.sh +# sdr.sh +# cipher.sh +# perf.sh +# cert.sh +# smime.sh +# tools.sh +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +# NOTE: +# ----- +# Unlike the old QA this is based on files sourcing each other +# This is done to save time, since a great portion of time is lost +# in calling and sourcing the same things multiple times over the +# network. Also, this way all scripts have all shell function available +# and a completely common environment +# +######################################################################## -mozilla_root=`(cd ../../../..; pwd)` -MOZILLA_ROOT=${MOZILLA_ROOT-$mozilla_root} -common=`(cd ../common; pwd)` -COMMON=${TEST_COMMON-$common} +if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then -qascript_dir=`(cd ..; pwd)` -QASCRIPT_DIR=${QASCRIPT_DIR-$qascript_dir} -export QASCRIPT_DIR + Exit() + { + if [ -n "$1" ] ; then + echo "$SCRIPTNAME: Exit: $*" + html_failed "<TR><TD>$*" + fi + echo "</TABLE><BR>" >> ${RESULTS} + if [ -n "${TAILPID}" ]; then + ${KILL} "${TAILPID}" + fi + if [ -n "${SERVERPID}" -a -f "${SERVERPID}" ]; then + ${KILL} `cat ${SERVERPID}` + fi + CLEANUP=${SCRIPTNAME} + cd ${QADIR} + . common/cleanup.sh + case $1 in + [0-4][0-9]|[0-9]) + exit $1; + ;; + *) + exit 1 + ;; + esac + } -DIST=${DIST-${MOZILLA_ROOT}/dist} -SECURITY_ROOT=${SECURITY_ROOT-${MOZILLA_ROOT}/security/nss} -TESTDIR=${TESTDIR-${MOZILLA_ROOT}/tests_results/security} -OBJDIR=`cd ../common; gmake objdir_name` -OS_ARCH=`cd ../common; gmake os_arch` + html() ######################### write the results.html file + { # 3 functions so we can put targets in the output.log easier + echo $* >>${RESULTS} + } + html_passed() + { + html "$* ${HTML_PASSED}" + } + html_failed() + { + html "$* ${HTML_FAILED}" + } + html_head() + { + html "<TABLE BORDER=1><TR><TH COLSPAN=3>$*</TH></TR>" + html "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" + echo "$SCRIPTNAME: $* ===============================" + } + html_msg() + { + if [ "$1" -ne "$2" ] ; then + html_failed "<TR><TD>$3" + if [ -n "$4" ] ; then + echo "$SCRIPTNAME: $3 $4 FAILED" + fi + else + html_passed "<TR><TD>$3" + if [ -n "$4" ] ; then + echo "$SCRIPTNAME: $3 $4 PASSED" + fi + fi + } -if [ ${OS_ARCH} = "WINNT" ]; then - PATH=${DIST}/${OBJDIR}/bin\;${DIST}/${OBJDIR}/lib\;$PATH -else - PATH=${DIST}/${OBJDIR}/bin:${DIST}/${OBJDIR}/lib:$PATH -fi -PATH=`perl $QASCRIPT_DIR/path_uniq -d ';' "$PATH"` -export PATH - -LD_LIBRARY_PATH=${DIST}/${OBJDIR}/lib -SHLIB_PATH=${DIST}/${OBJDIR}/lib -LIBPATH=${DIST}/${OBJDIR}/lib -export LD_LIBRARY_PATH SHLIB_PATH LIBPATH -#echo "LD_LIBRARY_PATH SHLIB_PATH LIBPATH=$LD_LIBRARY_PATH" - -if [ ! -d ${TESTDIR} ]; then - echo "Creating ${TESTDIR}" - mkdir -p ${TESTDIR} -fi + SCRIPTNAME=init.sh -if [ -z "${HOST}" ]; then - echo "HOST environment variable is not defined."; exit 1 -fi -if [ -z "${DOMSUF}" ]; then - DOMSUF=`domainname` - export DOMSUF - if [ -z "${DOMSUF}" ]; then - echo "DOMSUF environment variable is not defined."; exit 1 - fi -fi + mozilla_root=`(cd ../../../..; pwd)` + MOZILLA_ROOT=${MOZILLA_ROOT-$mozilla_root} + + qadir=`(cd ..; pwd)` + QADIR=${QADIR-$qadir} -#if [ ! -s "${HOSTDIR}" ]; then -s means different things to different tests... -if [ ! -d "${HOSTDIR}" ]; then - #echo "No hostdir" - if [ -f ${TESTDIR}/${HOST} ]; then - version=`cat ${TESTDIR}/${HOST}` - else - version=1 + common=${QADIR}/common + COMMON=${TEST_COMMON-$common} + export COMMON + + DIST=${DIST-${MOZILLA_ROOT}/dist} + SECURITY_ROOT=${SECURITY_ROOT-${MOZILLA_ROOT}/security/nss} + TESTDIR=${TESTDIR-${MOZILLA_ROOT}/tests_results/security} + OBJDIR=`(cd $COMMON; gmake objdir_name)` + OS_ARCH=`(cd $COMMON; gmake os_arch)` + OS_NAME=`uname -s | sed -e "s/-[0-9]*\.[0-9]*//"` + + if [ "${OS_ARCH}" = "WINNT" -a "$OS_NAME" != "CYGWIN_NT" ]; then + PATH=${DIST}/${OBJDIR}/bin\;${DIST}/${OBJDIR}/lib\;$PATH + PATH=`perl ../path_uniq -d ';' "$PATH"` + else + PATH=${DIST}/${OBJDIR}/bin:${DIST}/${OBJDIR}/lib:$PATH + PATH=`perl ../path_uniq -d ':' "$PATH"` fi - if [ -z "${version}" ]; then # for some starnge reason this file - # gets truncated at times... - for w in `ls -d ${TESTDIR}/${HOST}.[0-9]* 2>/dev/null | - sort -t '.' -n | sed -e "s/.*${HOST}.//"` ; do - version=`expr $w + 1` - done - if [ -z "${version}" ]; then - version=1 - fi - fi - expr $version + 1 > ${TESTDIR}/${HOST} - - HOSTDIR=${TESTDIR}/${HOST}'.'$version -fi -if [ ! -d ${HOSTDIR} ]; then - mkdir -p ${HOSTDIR} -fi + LD_LIBRARY_PATH=${DIST}/${OBJDIR}/lib + SHLIB_PATH=${DIST}/${OBJDIR}/lib + LIBPATH=${DIST}/${OBJDIR}/lib -RESULTS=${HOSTDIR}/results.html -if [ ! -f "${RESULTS}" ]; then + if [ ! -d "${TESTDIR}" ]; then + echo "$SCRIPTNAME init: Creating ${TESTDIR}" + mkdir -p ${TESTDIR} + fi - cp ${COMMON}/results_header.html ${RESULTS} - echo "<H4>Platform: ${OBJDIR}<BR>" >> ${RESULTS} - echo "Test Run: ${HOST}.$version</H4>" >> ${RESULTS} - echo "<HR><BR>" >> ${RESULTS} + case $HOST in + *\.*) + HOST=`echo $HOST | sed -e "s/\..*//"` + ;; + ?*) + ;; + *) + echo "$SCRIPTNAME: HOST environment variable is not defined." + exit 1 #does not need to be Exit, very early in script + ;; + esac - echo "********************************************" - echo " Platform: ${OBJDIR}" - echo " Results: ${HOST}.$version" - echo "********************************************" -fi + if [ -z "${DOMSUF}" ]; then + DOMSUF=`domainname` + if [ -z "${DOMSUF}" ]; then + echo "$SCRIPTNAME: DOMSUF environment variable is not defined." + exit 1 #does not need to be Exit, very early in script + fi + fi + +#NOTE - this HOSTDIR migh not be set at the time of this test!!! +# the original had a -s maybe meant -z???? - first replaced it with -d +#which worked, but resulted in [ ! -d "" ] which doesn't make a lot of sense + + if [ -z "${HOSTDIR}" ]; then + if [ -f "${TESTDIR}/${HOST}" ]; then + version=`cat ${TESTDIR}/${HOST}` + else + version=1 + fi + if [ -z "${version}" ]; then # for some strange reason this file + # gets truncated at times... Windos + for w in `ls -d ${TESTDIR}/${HOST}.[0-9]* 2>/dev/null | + sort -t '.' -n | sed -e "s/.*${HOST}.//"` ; do + version=`expr $w + 1` + done + if [ -z "${version}" ]; then + version=1 + fi + fi + expr $version + 1 > ${TESTDIR}/${HOST} + HOSTDIR=${TESTDIR}/${HOST}'.'$version + + mkdir -p ${HOSTDIR} + fi -KILL="kill" -if [ ${OS_ARCH} = "Linux" ]; then + if [ -z "${RESULTS}" ]; then + RESULTS=${HOSTDIR}/results.html + fi + if [ ! -f "${RESULTS}" ]; then + cp ${COMMON}/results_header.html ${RESULTS} + html "<H4>Platform: ${OBJDIR}<BR>" + html "Test Run: ${HOST}.$version</H4>" + html "<HR><BR>" + html "<HTML><BODY>" + + echo "********************************************" + echo " Platform: ${OBJDIR}" + echo " Results: ${HOST}.$version" + echo "********************************************" + fi + if [ -z "${LOGFILE}" ]; then + LOGFILE=${HOSTDIR}/output.log + fi + if [ ! -f "${LOGFILE}" ]; then + touch ${LOGFILE} + fi + + KILL="kill" + if [ "${OS_ARCH}" = "Linux" ]; then SLEEP="sleep 30" -fi + fi + if [ `uname -s` = "SunOS" ]; then + PS="/usr/5bin/ps" + else + PS="ps" + fi + + + CURDIR=`pwd` + + HTML_FAILED='</TD><TD bgcolor=red>Failed</TD><TR>' + HTML_PASSED='</TD><TD bgcolor=lightGreen>Passed</TD><TR>' -export KILL + CU_ACTION='Unknown certutil action' -INIT_SOURCED=TRUE + # would like to preserve some tmp files, also easier to see if there + # are "leftovers" - another possibility ${HOSTDIR}/tmp + TMP=${HOSTDIR} #TMP=${TMP-/tmp} + + CADIR=${HOSTDIR}/CA + SERVERDIR=${HOSTDIR}/server + CLIENTDIR=${HOSTDIR}/client + ALICEDIR=${HOSTDIR}/alicedir + BOBDIR=${HOSTDIR}/bobdir + DAVEDIR=${HOSTDIR}/dave + + PWFILE=${TMP}/tests.pw.$$ + CERTSCRIPT=${TMP}/tests_certs.$$ + NOISE_FILE=${TMP}/tests_noise.$$ + + # we need relative pathnames of these files abd directories, since our + # tools can't handle the unix style absolut pathnames on cygnus + + R_CADIR=../CA + R_SERVERDIR=../server + R_CLIENTDIR=../client + R_ALICEDIR=../alicedir + R_BOBDIR=../bobdir + R_DAVEDIR=../dave + + R_PWFILE=../tests.pw.$$ + R_CERTSCRIPT=../tests_certs.$$ + R_NOISE_FILE=../tests_noise.$$ + + # a new log file, short - fast to search, mostly for tools to + # see if their portion of the cert has succeeded, also for me - + CERT_LOG_FILE=${HOSTDIR}/cert.log #the output.log is so crowded... + + TEMPFILES="${PWFILE} ${CERTSCRIPT} ${NOISE_FILE}" + trap "Exit $0 Signal_caught" 2 3 + + export PATH LD_LIBRARY_PATH SHLIB_PATH LIBPATH + export DOMSUF + export KILL SLEEP PS + export MOZILLA_ROOT SECURITY_ROOT DIST TESTDIR OBJDIR HOSTDIR QADIR + export LOGFILE SCRIPTNAME + + + SCRIPTNAME=$0 + INIT_SOURCED=TRUE #whatever one does - NEVER export this one please +fi diff --git a/security/nss/tests/perf/perf.sh b/security/nss/tests/perf/perf.sh index 07416084b..403588afe 100755 --- a/security/nss/tests/perf/perf.sh +++ b/security/nss/tests/perf/perf.sh @@ -1,31 +1,80 @@ #! /bin/sh # +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# ######################################################################## # -# mozilla/security/nss/tests/perf +# mozilla/security/nss/tests/perf/perf.sh # # script run from the nightly NSS QA to measure nss performance +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior # ######################################################################## # -. ../common/init.sh -CURDIR=`pwd` - -#echo "<HTML><BODY>" >> ${RESULTS} - -#SONMI_DEBUG=ON # for now save all tmp files +############################## perf_init ############################## +# local shell function to initialize this script +######################################################################## +perf_init() +{ + SCRIPTNAME="perf.sh" + if [ -z "${INIT_SOURCED}" ] ; then + cd ../common + . init.sh + fi + SCRIPTNAME="perf.sh" + PERFDIR=${HOSTDIR}/perf + mkdir -p ${PERFDIR} +} +perf_init +RSAPERF_OUT=`rsaperf -i 300 -s -n none` +RSAPERF_OUT=`echo $RSAPERF_OUT | sed \ + -e "s/^/RSAPERF: $OBJDIR /" \ + -e 's/microseconds/us/' \ + -e 's/milliseconds/ms/' \ + -e 's/seconds/s/' \ + -e 's/ minutes, and /_min_/'` -PERFDIR=${HOSTDIR}/perf +echo "$RSAPERF_OUT" -mkdir -p ${PERFDIR} -RSAPERF_OUT=`rsaperf -i 300 -s -n none` -RSAPERF_OUT=`echo $RSAPERF_OUT | sed -e "s/^/RSAPERF: $OBJDIR /" \ - -e 's/microseconds/us/' -e 's/milliseconds/ms/' -e 's/seconds/s/' \ - -e 's/ minutes, and /_min_/'` -echo "$RSAPERF_OUT" +#FIXME #export RSAPERF_OUT # #perl -e ' @@ -33,6 +82,6 @@ echo "$RSAPERF_OUT" #@rsaperf=split(/ /, $ENV{RSAPERF_OUT}); #echo "${RSAPERF_OUT}" | read IT_NUM T1 T2 TOT_TIM TOT_TIM_U \ - #T3 T4 T5 AVRG_TIM AVRG_TIM_U + #T3 T4 T5 AVRG_TIM AVRG_TIM_U #300 iterations in 8.881 seconds one operation every 29606 microseconds diff --git a/security/nss/tests/sdr/sdr.sh b/security/nss/tests/sdr/sdr.sh index df1b1693e..98a16a457 100755 --- a/security/nss/tests/sdr/sdr.sh +++ b/security/nss/tests/sdr/sdr.sh @@ -1,71 +1,121 @@ -#! /bin/sh +#! /bin/sh # -# This is just a quick script so we can still run our testcases. -# Longer term we need a scriptable test environment.. +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. # -. ../common/init.sh - -VALUEDIR=`dirname $RESULTS` - -CURDIR=`pwd` - -#temporary files -VALUE1=$VALUEDIR/tests.v1.$$ -VALUE2=$VALUEDIR/tests.v2.$$ - # -# should also try to kill any running server +######################################################################## +# +# mozilla/security/nss/tests/sdr/sdr.sh # -#trap "rm -f ${TEMPFILES}; exit" 2 3 - leave this line for now, in case we - #need other cleanup +# Script to start test basic functionallity of NSS sdr +# +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +######################################################################## + +############################## sdr_init ################################ +# local shell function to initialize this script +######################################################################## +sdr_init() +{ + SCRIPTNAME=sdr.sh + if [ -z "${CLEANUP}" ] ; then + CLEANUP="${SCRIPTNAME}" + fi + + if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then + cd ../common + . init.sh + fi + SCRIPTNAME=sdr.sh + + #temporary files + VALUE1=$HOSTDIR/tests.v1.$$ + VALUE2=$HOSTDIR/tests.v2.$$ -T1=Test1 -T2="The quick brown fox jumped over the lazy dog" + T1="Test1" + T2="The quick brown fox jumped over the lazy dog" -SDRDIR=${HOSTDIR}/SDR -if [ ! -d ${SDRDIR} ]; then - mkdir -p ${SDRDIR} -fi + SDRDIR=${HOSTDIR}/SDR + if [ ! -d ${SDRDIR} ]; then + mkdir -p ${SDRDIR} + fi -cd ${SDRDIR} -echo "<TABLE BORDER=1><TR><TH COLSPAN=3>SDR Tests</TH></TR>" >> ${RESULTS} -echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} -echo "********************** Creating an SDR key/Encrypt **********************" -echo "sdrtest -d . -o ${VALUE1} -t Test1" -sdrtest -d . -o ${VALUE1} -t Test1 + cd ${SDRDIR} + html_head "SDR Tests" +} -if [ $? -ne 0 ]; then - echo "<TR><TD>Creating SDR Key</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Creating SDR Key</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi +############################## sdr_main ################################ +# local shell function to test NSS SDR +######################################################################## +sdr_main() +{ + echo "$SCRIPTNAME: Creating an SDR key/Encrypt" + echo "sdrtest -d . -o ${VALUE1} -t Test1" + sdrtest -d . -o ${VALUE1} -t Test1 + html_msg $? 0 "Creating SDR Key" -echo "**************** SDR Encrypt - Second Value ****************" -echo "sdrtest -d . -o ${VALUE2} -t '${T2}'" -sdrtest -d . -o ${VALUE2} -t "${T2}" + echo "$SCRIPTNAME: SDR Encrypt - Second Value" + echo "sdrtest -d . -o ${VALUE2} -t '${T2}'" + sdrtest -d . -o ${VALUE2} -t "${T2}" + html_msg $? 0 "Encrypt - Value 2" -if [ $? -ne 0 ]; then - echo "<TR><TD>Encrypt - Value 2</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Encrypt - Value 2</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi + echo "$SCRIPTNAME: Decrypt - Value 1" + echo "sdrtest -d . -i ${VALUE1} -t Test1" + sdrtest -d . -i ${VALUE1} -t Test1 + html_msg $? 0 "Decrypt - Value 1" -echo "***** Decrypt - Value 1 *****" -echo "sdrtest -d . -i ${VALUE1} -t Test1" -sdrtest -d . -i ${VALUE1} -t Test1 -if [ $? -ne 0 ]; then - echo "<TR><TD>Decrypt - Value 1</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Decrypt - Value 1</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi + echo "$SCRIPTNAME: Decrypt - Value 2" + echo "sdrtest -d . -i ${VALUE2} -t ${T2}" + sdrtest -d . -i ${VALUE2} -t "${T2}" + html_msg $? 0 "Decrypt - Value 2" +} -echo "***** Decrypt - Value 2 *****" -echo "sdrtest -d . -i ${VALUE2} -t ${T2}" -sdrtest -d . -i ${VALUE2} -t "${T2}" -if [ $? -ne 0 ]; then - echo "<TR><TD>Decrypt - Value 2</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Decrypt - Value 2</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi +############################## sdr_cleanup ############################# +# local shell function to finish this script (no exit since it might be +# sourced) +######################################################################## +sdr_cleanup() +{ + html "</TABLE><BR>" + cd ${QADIR} + . common/cleanup.sh +} -echo "</TABLE><BR>" >> ${RESULTS} +sdr_init +sdr_main +sdr_cleanup diff --git a/security/nss/tests/smime/smime.sh b/security/nss/tests/smime/smime.sh index 3019cee54..61a7b8960 100755 --- a/security/nss/tests/smime/smime.sh +++ b/security/nss/tests/smime/smime.sh @@ -1,308 +1,165 @@ #! /bin/sh # -# This is just a quick script so we can still run our testcases. -# Longer term we need a scriptable test environment.. +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ # -. ../common/init.sh -CURDIR=`pwd` - -SMIMEDIR=${HOSTDIR}/smime -CADIR=${SMIMEDIR}/cadir -ALICEDIR=${SMIMEDIR}/alicedir -BOBDIR=${SMIMEDIR}/bobdir - -echo "<HTML><BODY>" >> ${RESULTS} - -SONMI_DEBUG=ON #we see starnge problems on hpux 64 - save all output - # for now - -#temporary files -if [ -n "$SONMI_DEBUG" -a "$SONMI_DEBUG" = "ON" ] -then - TMP=${SMIMEDIR} - PWFILE=${TMP}/tests.pw - CERTSCRIPT=${TMP}/tests_certs - NOISE_FILE=${TMP}/tests_noise - CERTUTILOUT=${TMP}/certutil_out - - TEMPFILES="" -else - TMP=${TMP-/tmp} - PWFILE=${TMP}/tests.pw.$$ - CERTSCRIPT=${TMP}/tests_certs.$$ - NOISE_FILE=${TMP}/tests_noise.$$ - CERTUTILOUT=${TMP}/certutil_out.$$ - - TEMPFILES="${PWFILE} ${CERTSCRIPT} ${NOISE_FILE} ${CERTUTILOUT}" - # - # should also try to kill any running server - # - trap "rm -f ${TEMPFILES}; exit" 2 3 -fi - -mkdir -p ${SMIMEDIR} -mkdir -p ${CADIR} -mkdir -p ${ALICEDIR} -mkdir -p ${BOBDIR} -cd ${CADIR} - -rm ${CERTUTILOUT} 2>/dev/null - -# Generate noise for our CA cert. +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. # -# NOTE: these keys are only suitable for testing, as this whole thing bypasses -# the entropy gathering. Don't use this method to generate keys and certs for -# product use or deployment. +# The Original Code is the Netscape security libraries. # -ps -efl > ${NOISE_FILE} 2>&1 -ps aux >> ${NOISE_FILE} 2>&1 -netstat >> ${NOISE_FILE} 2>&1 -date >> ${NOISE_FILE} 2>&1 - +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. # -# build the TEMP CA used for testing purposes -# -echo "<TABLE BORDER=1><TR><TH COLSPAN=3>Certutil Tests</TH></TR>" >> ${RESULTS} -echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} -echo "********************** Creating a CA Certificate **********************" -echo nss > ${PWFILE} -echo " certutil -N -d ${CADIR} -f ${PWFILE} " -certutil -N -d ${CADIR} -f ${PWFILE} 2>&1 - -echo initialized -echo 5 > ${CERTSCRIPT} -echo 9 >> ${CERTSCRIPT} -echo n >> ${CERTSCRIPT} -echo y >> ${CERTSCRIPT} -echo 3 >> ${CERTSCRIPT} -echo n >> ${CERTSCRIPT} -echo 5 >> ${CERTSCRIPT} -echo 6 >> ${CERTSCRIPT} -echo 7 >> ${CERTSCRIPT} -echo 9 >> ${CERTSCRIPT} -echo n >> ${CERTSCRIPT} -echo "certutil -S -n \"TestCA\" -s \"CN=NSS Test CA, O=BOGUS NSS, L=Mountain View, ST=California, C=US\" -t \"CTu,CTu,CTu\" -v 60 -x -d ${CADIR} -1 -2 -5 -f ${PWFILE} -z ${NOISE_FILE} " -certutil -S -n "TestCA" -s "CN=NSS Test CA, O=BOGUS NSS, L=Mountain View, ST=California, C=US" -t "CTu,CTu,CTu" -v 60 -x -d ${CADIR} -1 -2 -5 -f ${PWFILE} -z ${NOISE_FILE} < ${CERTSCRIPT} 2>&1 - -if [ $? -ne 0 ]; then - echo "<TR><TD>Creating CA Cert</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Creating CA Cert</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi -echo " certutil -L -n \"TestCA\" -r -d ${CADIR} > root.cert" -certutil -L -n "TestCA" -r -d ${CADIR} > root.cert 2>${CERTUTILOUT} -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Export Root"} -fi -cat ${CERTUTILOUT} -rm ${CERTUTILOUT} 2>/dev/null - -echo "**************** Creating Client CA Issued Certificates ****************" -echo " certutil -N -d ${ALICEDIR} -f ${PWFILE} " -certutil -N -d ${ALICEDIR} -f ${PWFILE} 2>&1 -netstat >> ${NOISE_FILE} 2>&1 -date >> ${NOISE_FILE} 2>&1 -cd ${ALICEDIR} -echo "Import the root CA" -echo " certutil -A -n \"TestCA\" -t \"TC,TC,TC\" -f ${PWFILE} -d ${ALICEDIR} -i ${CADIR}/root.cert " -certutil -A -n "TestCA" -t "TC,TC,TC" -f ${PWFILE} -d ${ALICEDIR} -i ${CADIR}/root.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Root"} -fi -echo "Generate a Certificate request" -echo " certutil -R -s \"CN=Alice, E=alice@bogus.com, O=BOGUS Netscape, L=Mountain View, ST=California, C=US\" -d ${ALICEDIR} -f ${PWFILE} -z ${NOISE_FILE} -o req " -certutil -R -s "CN=Alice, E=alice@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US" -d ${ALICEDIR} -f ${PWFILE} -z ${NOISE_FILE} -o req 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Generate Request"} -fi -echo "Sign the Certificate request" -echo "certutil -C -c \"TestCA\" -m 3 -v 60 -d ${CADIR} -f ${PWFILE} -i req -o alice.cert " -certutil -C -c "TestCA" -m 3 -v 60 -d ${CADIR} -i req -o alice.cert -f ${PWFILE} 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Sign Alice's Cert"} -fi -echo "Import the new Cert" -echo "certutil -A -n \"Alice\" -t \"u,u,u\" -d ${ALICEDIR} -f ${PWFILE} -i alice.cert " -certutil -A -n "Alice" -t "u,u,u" -d ${ALICEDIR} -f ${PWFILE} -i alice.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Alice's cert"} -fi -if [ -n "${CERTFAILED}" ]; then - echo "<TR><TD>Creating Alice's email cert</TD><TD bgcolor=red>Failed ($CERTFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Creating Alice's email cert</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -netstat >> ${NOISE_FILE} 2>&1 -date >> ${NOISE_FILE} 2>&1 -echo "certutil -N -d ${BOBDIR} -f " -certutil -N -d ${BOBDIR} -f ${PWFILE} 2>&1 -cd ${BOBDIR} -echo "Import the root CA" -echo " certutil -A -n \"TestCA\" -t \"TC,TC,TC\" -f ${PWFILE} -d ${BOBDIR} -i ${CADIR}/root.cert " -certutil -A -n "TestCA" -t "TC,TC,TC" -f ${PWFILE} -d ${BOBDIR} -i ${CADIR}/root.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Root"} -fi -echo "Generate a Certificate request" -echo " certutil -R -s \"CN=Bob, E=bob@bogus.com, O=BOGUS Netscape, L=Mountain View, ST=California, C=US\" -d ${BOBDIR} -f ${PWFILE} -z ${NOISE_FILE} -o req " -certutil -R -s "CN=Bob, E=bob@bogus.com, O=BOGUS NSS, L=Mountain View, ST=California, C=US" -d ${BOBDIR} -f ${PWFILE} -z ${NOISE_FILE} -o req 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Generate Request"} -fi -echo "Sign the Certificate request" -echo "certutil -C -c "TestCA" -m 4 -v 60 -d ${CADIR} -f ${PWFILE} -i req -o bob.cert " -certutil -C -c "TestCA" -m 4 -v 60 -d ${CADIR} -i req -o bob.cert -f ${PWFILE} 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Sign Bob's cert"} -fi -echo "Import the new Cert" -echo "certutil -A -n \"Bob\" -t \"u,u,u\" -d ${BOBDIR} -f ${PWFILE} -i bob.cert " -certutil -A -n "Bob" -t "u,u,u" -d ${BOBDIR} -f ${PWFILE} -i bob.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Bob's cert"} -fi -if [ -n "${CERTFAILED}" ]; then - echo "<TR><TD>Creating Bob's email cert</TD><TD bgcolor=red>Failed ($CERTFAILED)</TD><TR>" >> ${RESULTS} -else - echo "<TR><TD>Creating Bob's email cert</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -netstat >> ${NOISE_FILE} 2>&1 -date >> ${NOISE_FILE} 2>&1 -cd ${CADIR} -echo "Generate a third cert" -echo "certutil -S -n \"Dave\" -c \"TestCA\" -t \"u,u,u\" -s \"CN=Dave, E=dave@bogus.com, O=BOGUS Netscape, L=Mountain View, ST=California, C=US\" -d ${CADIR} -f ${PWFILE} -z ${NOISE_FILE} -m 5 -v 60 " -certutil -S -n "Dave" -c "TestCA" -t "u,u,u" -s "CN=Dave, E=dave@bogus.com, O=BOGUS Netscape, L=Mountain View, ST=California, C=US" -d ${CADIR} -f ${PWFILE} -z ${NOISE_FILE} -m 5 -v 60 2>&1 - -echo "Import Alices's cert into Bob's db" -echo "certutil -E -t \"u,u,u\" -d ${BOBDIR} -f ${PWFILE} -i ${ALICEDIR}/alice.cert " -certutil -E -t "u,u,u" -d ${BOBDIR} -f ${PWFILE} -i ${ALICEDIR}/alice.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Alice's cert into Bob's db"} -fi -echo "Import Bob's cert into Alice's db" -echo "certutil -E -t \"u,u,u\" -d ${ALICEDIR} -f ${PWFILE} -i ${BOBDIR}/bob.cert " -certutil -E -t "u,u,u" -d ${ALICEDIR} -f ${PWFILE} -i ${BOBDIR}/bob.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Bob's cert into Alice's db"} -fi -echo "Import Dave's cert into Alice's and Bob's dbs" -echo " certutil -L -n \"Dave\" -r -d ${CADIR} > dave.cert" -certutil -L -n "Dave" -r -d ${CADIR} > dave.cert 2>${CERTUTILOUT} -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Export Dave's cert"} -fi -cat ${CERTUTILOUT} -rm ${CERTUTILOUT} 2>/dev/null -echo "certutil -E -t \"u,u,u\" -d ${ALICEDIR} -f ${PWFILE} -i ${CADIR}/dave.cert " -certutil -E -t "u,u,u" -d ${ALICEDIR} -f ${PWFILE} -i ${CADIR}/dave.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Dave's cert into Alice's db"} -fi -echo "certutil -E -t \"u,u,u\" -d ${BOBDIR} -f ${PWFILE} -i ${CADIR}/dave.cert " -certutil -E -t "u,u,u" -d ${BOBDIR} -f ${PWFILE} -i ${CADIR}/dave.cert 2>&1 -if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Dave's cert into Bob's db"} -fi -echo "</TABLE><BR>" >> ${RESULTS} - -echo "********************* S/MIME testing ****************************" -echo "<TABLE BORDER=1><TR><TH COLSPAN=3>S/MIME tests</TH></TR>" >> ${RESULTS} -echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} -cd ${SMIMEDIR} -cp ${CURDIR}/alice.txt ${SMIMEDIR} -# Test basic signed and enveloped messages from 1 --> 2 -echo "cmsutil -S -N Alice -i alice.txt -d ${ALICEDIR} -p nss -o alice.sig" -cmsutil -S -N Alice -i alice.txt -d ${ALICEDIR} -p nss -o alice.sig -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Create Signature Alice"} -fi -echo "cmsutil -D -i alice.sig -d ${BOBDIR} -o alice.data1" -cmsutil -D -i alice.sig -d ${BOBDIR} -o alice.data1 -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Decode Alice's Signature"} -fi -echo "diff alice.txt alice.data1" -diff alice.txt alice.data1 -if [ $? -ne 0 ]; then - echo "Signing attached message Failed ($CMSFAILED)" - echo "<TR><TD>Signing attached message</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "Signing attached message Passed" - echo "<TR><TD>Signing attached message</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi -echo "cmsutil -E -r bob@bogus.com -i alice.txt -d ${ALICEDIR} -p nss -o alice.env" -cmsutil -E -r bob@bogus.com -i alice.txt -d ${ALICEDIR} -p nss -o alice.env -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Create Enveloped Data Alice"} -fi -echo "cmsutil -D -i alice.env -d ${BOBDIR} -p nss -o alice.data1" -cmsutil -D -i alice.env -d ${BOBDIR} -p nss -o alice.data1 -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Decode Enveloped Data Alice"} -fi -echo "diff alice.txt alice.data1" -diff alice.txt alice.data1 -if [ $? -ne 0 ]; then - echo "Enveloped Data Failed ($CMSFAILED)" - echo "<TR><TD>Enveloped Data</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "Enveloped Data Passed" - echo "<TR><TD>Enveloped Data</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi -# multiple recip -#cmsutil -E -i alicecc.txt -d alicedir -o alicecc.env -r bob@bogus.com,dave@bogus.com -#cmsutil -D -i alicecc.env -d bobdir -p nss - -#certs-only -echo "cmsutil -O -r \"Alice,bob@bogus.com,dave@bogus.com\" -d ${ALICEDIR} > co.der" -cmsutil -O -r "Alice,bob@bogus.com,dave@bogus.com" -d ${ALICEDIR} > co.der -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Create Certs-Only Alice"} -fi -echo "cmsutil -D -i co.der -d ${BOBDIR}" -cmsutil -D -i co.der -d ${BOBDIR} -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Verify Certs-Only by CA"} -fi -if [ -n "${CMSFAILED}" ]; then - echo "Sending certs-only message Failed ($CMSFAILED)" - echo "<TR><TD>Sending certs-only message</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "Sending certs-only message Passed" - echo "<TR><TD>Sending certs-only message</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi -echo "cmsutil -C -i alice.txt -e alicehello.env -d ${ALICEDIR} -r \"bob@bogus.com\" > alice.enc" -cmsutil -C -i alice.txt -e alicehello.env -d ${ALICEDIR} -r "bob@bogus.com" > alice.enc -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Create Encrypted-Data"} -fi -#echo "cmsutil -C -i bob.txt -e alicehello.env -d ${ALICEDIR} -r \"alice@bogus.com\" > bob.enc" -#cmsutil -C -i bob.txt -e alicehello.env -d ${ALICEDIR} -r "alice@bogus.com" > bob.enc -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Create Encrypted-Data"} -fi -echo "cmsutil -D -i alice.enc -d ${BOBDIR} -e alicehello.env -p nss -o alice.data2" -cmsutil -D -i alice.enc -d ${BOBDIR} -e alicehello.env -p nss -o alice.data2 -diff alice.txt alice.data2 -if [ $? -ne 0 ]; then - CMSFAILED=${CMSFAILED-"Decode Encrypted-Data"} -fi -if [ -n "${CMSFAILED}" ]; then - echo "Encrypted-Data message Failed ($CMSFAILED)" - echo "<TR><TD>Encrypted-Data message</TD><TD bgcolor=red>Failed ($CMSFAILED)</TD><TR>" >> ${RESULTS} -else - echo "Encrypted-Data message Passed" - echo "<TR><TD>Encrypted-Data message</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} -fi - -echo "</TABLE><BR>" >> ${RESULTS} - -if [ "$SONMI_DEBUG" != "ON" -a -n "$TEMPFILES" ] -then - rm -f ${TEMPFILES} -fi -cd ${CURDIR} +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. +# +# +######################################################################## +# +# mozilla/security/nss/tests/smime/smime.sh +# +# Script to test NSS smime +# +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +######################################################################## + +############################## smime_init ############################## +# local shell function to initialize this script +######################################################################## +smime_init() +{ + SCRIPTNAME=smime.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=smime.sh + html_head "S/MIME Tests" + + grep "SUCCESS: SMIME passed" $CERT_LOG_FILE >/dev/null || { + Exit 11 "Fatal - S/MIME of cert.sh needs to pass first" + } + + SMIMEDIR=${HOSTDIR}/smime + R_SMIMEDIR=../smime + mkdir -p ${SMIMEDIR} + cd ${SMIMEDIR} + cp ${QADIR}/smime/alice.txt ${SMIMEDIR} +} + + +############################## smime_main ############################## +# local shell function to test basic signed and enveloped messages +# from 1 --> 2" +######################################################################## +smime_main() +{ + + echo "$SCRIPTNAME: Signing Attached Message ------------------------------" + echo "cmsutil -S -N Alice -i alice.txt -d ${R_ALICEDIR} -p nss -o alice.sig" + cmsutil -S -N Alice -i alice.txt -d ${R_ALICEDIR} -p nss -o alice.sig + html_msg $? 0 "Create Signature Alice" "." + + echo "cmsutil -D -i alice.sig -d ${R_BOBDIR} -o alice.data1" + cmsutil -D -i alice.sig -d ${R_BOBDIR} -o alice.data1 + html_msg $? 0 "Decode Alice's Signature" "." + + echo "diff alice.txt alice.data1" + diff alice.txt alice.data1 + html_msg $? 0 "Compare Decoded Signature and Original" "." + + echo "$SCRIPTNAME: Enveloped Data Tests ------------------------------" + echo "cmsutil -E -r bob@bogus.com -i alice.txt -d ${R_ALICEDIR} -p nss \\" + echo " -o alice.env" + cmsutil -E -r bob@bogus.com -i alice.txt -d ${R_ALICEDIR} -p nss -o alice.env + html_msg $? 0 "Create Enveloped Data Alice" "." + + echo "cmsutil -D -i alice.env -d ${R_BOBDIR} -p nss -o alice.data1" + cmsutil -D -i alice.env -d ${R_BOBDIR} -p nss -o alice.data1 + html_msg $? 0 "Decode Enveloped Data Alice" "." + + echo "diff alice.txt alice.data1" + diff alice.txt alice.data1 + html_msg $? 0 "Compare Decoded Enveloped Data and Original" "." + + # multiple recip + #cmsutil -E -i alicecc.txt -d ${R_ALICEDIR} -o alicecc.env \ + # -r bob@bogus.com,dave@bogus.com + #cmsutil -D -i alicecc.env -d ${R_BOBDIR} -p nss + + echo "$SCRIPTNAME: Sending CERTS-ONLY Message ------------------------------" + echo "cmsutil -O -r \"Alice,bob@bogus.com,dave@bogus.com\" \\" + echo " -d ${R_ALICEDIR} > co.der" + cmsutil -O -r "Alice,bob@bogus.com,dave@bogus.com" -d ${R_ALICEDIR} > co.der + html_msg $? 0 "Create Certs-Only Alice" "." + + echo "cmsutil -D -i co.der -d ${R_BOBDIR}" + cmsutil -D -i co.der -d ${R_BOBDIR} + html_msg $? 0 "Verify Certs-Only by CA" "." + + echo "$SCRIPTNAME: Encrypted-Data Message ---------------------------------" + echo "cmsutil -C -i alice.txt -e alicehello.env -d ${R_ALICEDIR} \\" + echo " -r \"bob@bogus.com\" > alice.enc" + cmsutil -C -i alice.txt -e alicehello.env -d ${R_ALICEDIR} \ + -r "bob@bogus.com" > alice.enc + html_msg $? 0 "Create Encrypted-Data" "." + + echo "cmsutil -D -i alice.enc -d ${R_BOBDIR} -e alicehello.env -p nss \\" + echo " -o alice.data2" + cmsutil -D -i alice.enc -d ${R_BOBDIR} -e alicehello.env -p nss -o alice.data2 + html_msg $? 0 "Decode Encrypted-Data" "." + + diff alice.txt alice.data2 + html_msg $? 0 "Compare Decoded and Original Data" "." +} + +############################## smime_cleanup ########################### +# local shell function to finish this script (no exit since it might be +# sourced) +######################################################################## +smime_cleanup() +{ + html "</TABLE><BR>" + cd ${QADIR} + . common/cleanup.sh +} + +################## main ################################################# + +smime_init +smime_main +smime_cleanup -echo "</BODY></HTML>" >> ${RESULTS} diff --git a/security/nss/tests/ssl/ssl.sh b/security/nss/tests/ssl/ssl.sh index aedfae77b..fec714a95 100755 --- a/security/nss/tests/ssl/ssl.sh +++ b/security/nss/tests/ssl/ssl.sh @@ -1,406 +1,291 @@ #! /bin/sh # -# This is just a quick script so we can still run our testcases. -# Longer term we need a scriptable test environment.. +# The contents of this file are subject to the Mozilla Public +# License Version 1.1 (the "License"); you may not use this file +# except in compliance with the License. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +# +# Software distributed under the License is distributed on an "AS +# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +# implied. See the License for the specific language governing +# rights and limitations under the License. +# +# The Original Code is the Netscape security libraries. +# +# The Initial Developer of the Original Code is Netscape +# Communications Corporation. Portions created by Netscape are +# Copyright (C) 1994-2000 Netscape Communications Corporation. All +# Rights Reserved. +# +# Contributor(s): +# +# Alternatively, the contents of this file may be used under the +# terms of the GNU General Public License Version 2 or later (the +# "GPL"), in which case the provisions of the GPL are applicable +# instead of those above. If you wish to allow use of your +# version of this file only under the terms of the GPL and not to +# allow others to use your version of this file under the MPL, +# indicate your decision by deleting the provisions above and +# replace them with the notice and other provisions required by +# the GPL. If you do not delete the provisions above, a recipient +# may use your version of this file under either the MPL or the +# GPL. # -. ../common/init.sh -CURDIR=`pwd` -echo "PATH=$PATH" -echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" -PORT=${PORT-8443} - -# Test case files -SSLCOV=${CURDIR}/sslcov.txt -SSLAUTH=${CURDIR}/sslauth.txt -SSLSTRESS=${CURDIR}/sslstress.txt -REQUEST_FILE=${CURDIR}/sslreq.txt - -#temparary files -TMP=${TMP-/tmp} -PWFILE=${TMP}/tests.pw.$$ -CERTSCRIPT=${TMP}/tests_certs.$$ -NOISE_FILE=${TMP}/tests_noise.$$ -SERVEROUTFILE=${TMP}/tests_server.$$ -SERVERPID=${TMP}/tests_pid.$$ -CERTUTILOUT=${TMP}/certutilout.$$ - -TEMPFILES="${PWFILE} ${CERTSCRIPT} ${SERVEROUTFILE} ${NOISE_FILE} ${SERVERPID} ${CERTUTILOUT}" - -none=1 -coverage=0 -auth=0 -stress=0 -certs=1 -fileout=0 - -Exit() +# +######################################################################## +# +# mozilla/security/nss/tests/ssl/ssl.sh +# +# Script to test NSS SSL +# +# needs to work on all Unix and Windows platforms +# +# special strings +# --------------- +# FIXME ... known problems, search for this string +# NOTE .... unexpected behavior +# +######################################################################## + +############################## ssl_init ################################ +# local shell function to initialize this script +######################################################################## +ssl_init() { - echo $1 - rm -f ${TEMPFILES} - if [ -f "${SERVERPID}" ] - then - ${KILL} `cat ${SERVERPID}` - fi - exit 1 + SCRIPTNAME=ssl.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=ssl.sh + echo "$SCRIPTNAME: SSL tests ===============================" + + grep "SUCCESS: SSL passed" $CERT_LOG_FILE >/dev/null || { + html_head "SSL Test failure" + Exit 8 "Fatal - SSL of cert.sh needs to pass first" + } + + PORT=${PORT-8443} + + # Test case files + SSLCOV=${QADIR}/ssl/sslcov.txt + SSLAUTH=${QADIR}/ssl/sslauth.txt + SSLSTRESS=${QADIR}/ssl/sslstress.txt + REQUEST_FILE=${QADIR}/ssl/sslreq.txt + + #temparary files + SERVEROUTFILE=${TMP}/tests_server.$$ + SERVERPID=${TMP}/tests_pid.$$ + + R_SERVERPID=../tests_pid.$$ + + TEMPFILES="$TMPFILES ${SERVEROUTFILE} ${SERVERPID}" + + fileout=0 #FIXME, looks like all.sh tried to turn this on but actually didn't + #fileout=1 + #verbose="-v" #FIXME - see where this is usefull + cd ${CLIENTDIR} } +########################### is_selfserv_alive ########################## +# local shell function to exit with a fatal error if selfserver is not +# running +######################################################################## is_selfserv_alive() { - #echo "Testing if server is alive..." - if [ ! -f "${SERVERPID}" ] - then - echo "Error - selfserver pid file ${SERVERPID} does not exist" - sleep 5 - if [ ! -f "${SERVERPID}" ] - then - echo "<TR><TD>fatal error - no serverpidfile</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - echo "</TABLE><BR>" >> ${RESULTS} - Exit "Fatal Error - selfserver pid file ${SERVERPID} still does not exist - exiting" - fi - fi - PID=`cat ${SERVERPID}` - SERVER_OK="FALSE" - if [ `uname -s` = "SunOS" ] - then - /usr/5bin/ps -e | grep $PID >/dev/null && SERVER_OK="TRUE" - else - ps -e | grep $PID >/dev/null && SERVER_OK="TRUE" - fi - if [ "$SERVER_OK" = "FALSE" ] - then - echo "<TR><TD>fatal error - no selfserverprocess</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - echo "</TABLE><BR>" >> ${RESULTS} - Exit "Fatal Error - selfserver process not detectable" - fi + if [ ! -f "${SERVERPID}" ]; then + echo "$SCRIPTNAME: Error - selfserv PID file ${SERVERPID} doesn't exist" + sleep 5 + if [ ! -f "${SERVERPID}" ]; then + Exit 9 "Fatal - selfserv pid file ${SERVERPID} does not exist" + fi + fi + PID=`cat ${SERVERPID}` + $PS -e | grep $PID >/dev/null || \ + Exit 10 "Fatal - selfserv process not detectable" } -for i in $* -do - case $i in - [aA][lL]*) - none=0; coverage=1; auth=1; stress=1;; - [aA][uU]*) - none=0; auth=1;; - [Nn][Oo][aA][uU]*) - auth=0;; - [Cc][Oo]*) - none=0; coverage=1;; - [Nn][Oo][Cc][Oo]*) - coverage=0;; - [Cc][Ee]*) - none=0; certs=1;; - [Nn][Oo][Cc][Ee]*) - certs=0;; - [Ss]*) - none=0; stress=1;; - [Nn][Oo][Ss]*) - stress=0;; - [Vv][Ee][Rr][Bb]*) - verbose=-v;; - f) - fileout=1; - esac -done - -if [ $none -eq 1 ]; then - coverage=1 - auth=1 - stress=1 -fi +########################### wait_for_selfserv ########################## +# local shell function to wait until selfserver is running and initialized +######################################################################## +wait_for_selfserv() +{ + echo "tstclnt -p ${PORT} -h ${HOST} -q -d . < ${REQUEST_FILE} " + #echo "tstclnt -q started at `date`" + tstclnt -p ${PORT} -h ${HOST} -q -d . < ${REQUEST_FILE} + if [ $? -ne 0 ]; then + html_failed "<TR><TD> Wait for Server " + echo "RETRY: tstclnt -p ${PORT} -h ${HOST} -q -d . < ${REQUEST_FILE}" + tstclnt -p ${PORT} -h ${HOST} -q -d . < ${REQUEST_FILE} + elif [ sparam = "-c ABCDEFabcdefghijklm" ] ; then # "$1" = "cov" ] ; then + html_passed "<TR><TD> Wait for Server" + fi + is_selfserv_alive +} -# -# should also try to kill any running server -# -trap "rm -f ${TEMPFILES}; Exit Signal_caught" 2 3 +########################### kill_selfserv ############################## +# local shell function to kill the selfserver after the tests are done +######################################################################## +kill_selfserv() +{ + ${KILL} `cat ${SERVERPID}` + wait `cat ${SERVERPID}` + if [ ${fileout} -eq 1 ]; then + cat ${SERVEROUTFILE} + fi + ${SLEEP} #FIXME linux waits 30 seconds - find a shorter way (sockets free) + rm ${SERVERPID} +} -CADIR=${HOSTDIR}/CA -SERVERDIR=${HOSTDIR}/server -CLIENTDIR=${HOSTDIR}/client +########################### start_selfserv ############################# +# local shell function to start the selfserver with the parameters required +# for this test and log information (parameters, start time) +# also: wait until the server is up and running +######################################################################## +start_selfserv() +{ + if [ -n "$testname" ] ; then + echo "$SCRIPTNAME: $testname ----" + fi + sparam=`echo $sparam | sed -e 's;_; ;g'` + echo "selfserv -p ${PORT} -d ${R_SERVERDIR} -n ${HOST}.${DOMSUF} \\" + echo " -w nss ${sparam} -i ${R_SERVERPID} $verbose &" + echo "selfserv started at `date`" + if [ ${fileout} -eq 1 ]; then + selfserv -p ${PORT} -d ${R_SERVERDIR} -n ${HOST}.${DOMSUF} \ + -w nss ${sparam} -i ${R_SERVERPID} $verbose \ + > ${SERVEROUTFILE} 2>&1 & + else + selfserv -p ${PORT} -d ${R_SERVERDIR} -n ${HOST}.${DOMSUF} \ + -w nss ${sparam} -i ${R_SERVERPID} $verbose & + fi + wait_for_selfserv +} -if [ $certs -eq 1 ]; then -# Generate noise for our CA cert. -# -# NOTE: these keys are only suitable for testing, as this whole thing bypasses -# the entropy gathering. Don't use this method to generate keys and certs for -# product use or deployment. -# - ps -efl > ${NOISE_FILE} 2>&1 - ps aux >> ${NOISE_FILE} 2>&1 - netstat >> ${NOISE_FILE} 2>&1 - date >> ${NOISE_FILE} 2>&1 +############################## ssl_cov ################################# +# local shell function to perform SSL Cipher Coverage tests +######################################################################## +ssl_cov() +{ + html_head "SSL Cipher Coverage" + + testname="" + sparam="-c ABCDEFabcdefghijklm" + start_selfserv # Launch the server + + cat ${SSLCOV} | while read tls param testname + do + if [ $tls != "#" ]; then + echo "$SCRIPTNAME: running $testname ----------------------------" + TLS_FLAG=-T + if [ $tls = "TLS" ]; then + TLS_FLAG="" + fi + sparam="" + if [ ${param} = "i" ]; then + sparam='-c i' + fi + + is_selfserv_alive + echo "tstclnt -p ${PORT} -h ${HOST} -c ${param} ${TLS_FLAG} \\" + echo " -f -d . << ${REQUEST_FILE}" + tstclnt -p ${PORT} -h ${HOST} -c ${param} ${TLS_FLAG} -f \ + -d . < ${REQUEST_FILE} + html_msg $? 0 "${testname}" + fi + done + + kill_selfserv + html "</TABLE><BR>" +} -# -# build the TEMP CA used for testing purposes -# - echo "<TABLE BORDER=1><TR><TH COLSPAN=3>Certutil Tests</TH></TR>" >> ${RESULTS} - echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} - echo "********************** Creating a CA Certificate **********************" - if [ ! -d ${CADIR} ]; then - mkdir -p ${CADIR} - fi - cd ${CADIR} - echo nss > ${PWFILE} - echo "certutil -N -d . -f ${PWFILE} 2>&1" - certutil -N -d . -f ${PWFILE} 2>&1 - - echo initialized - echo 5 > ${CERTSCRIPT} - echo 9 >> ${CERTSCRIPT} - echo n >> ${CERTSCRIPT} - echo y >> ${CERTSCRIPT} - echo 3 >> ${CERTSCRIPT} - echo n >> ${CERTSCRIPT} - echo 5 >> ${CERTSCRIPT} - echo 6 >> ${CERTSCRIPT} - echo 7 >> ${CERTSCRIPT} - echo 9 >> ${CERTSCRIPT} - echo n >> ${CERTSCRIPT} - echo "certutil -S -n \"TestCA\" -s \"CN=NSS Test CA, O=BOGUS NSS, L=Mountain View, ST=California, C=US\" -t \"CTu,CTu,CTu\" -v 60 -x -d . -1 -2 -5 -f ${PWFILE} -z ${NOISE_FILE} 2>&1" - certutil -S -n "TestCA" -s "CN=NSS Test CA, O=BOGUS NSS, L=Mountain View, ST=California, C=US" -t "CTu,CTu,CTu" -v 60 -x -d . -1 -2 -5 -f ${PWFILE} -z ${NOISE_FILE} < ${CERTSCRIPT} 2>&1 - - if [ $? -ne 0 ]; then - echo "<TR><TD>Creating CA Cert</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - else - echo "<TR><TD>Creating CA Cert</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - fi - - echo "**************** Creating Client CA Issued Certificate ****************" - netstat >> ${NOISE_FILE} 2>&1 - date >> ${NOISE_FILE} 2>&1 - if [ ! -d ${CLIENTDIR} ]; then - mkdir -p ${CLIENTDIR} - fi - cd ${CLIENTDIR} - echo "certutil -N -d . -f ${PWFILE} 2>&1" - certutil -N -d . -f ${PWFILE} 2>&1 - if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Init DB"} - fi - echo "Import the root CA" - echo "certutil -L -n \"TestCA\" -r -d ../CA > root.cert 2>>$CERTUTILOUT" - certutil -L -n "TestCA" -r -d ../CA > root.cert 2>>$CERTUTILOUT - - cat $CERTUTILOUT - - if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Export Root"} - fi - echo "certutil -A -n \"TestCA\" -t \"TC,TC,TC\" -f ${PWFILE} -d . -i root.cert 2>&1" - certutil -A -n "TestCA" -t "TC,TC,TC" -f ${PWFILE} -d . -i root.cert 2>&1 - if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import Root"} - fi - echo "Generate a Certificate request" - echo " certutil -R -s \"CN=Test User, O=BOGUS Netscape, L=Mountain View, ST=California, C=US\" -d . -f ${PWFILE} -z ${NOISE_FILE} -o req 2>&1" - certutil -R -s "CN=Test User, O=BOGUS NSS, L=Mountain View, ST=California, C=US" -d . -f ${PWFILE} -z ${NOISE_FILE} -o req 2>&1 - if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Generate Request"} - fi - echo "Sign the Certificate request" - echo "certutil -C -c "TestCA" -m 3 -v 60 -d ../CA -f ${PWFILE} -i req -o user.cert 2>&1" - certutil -C -c "TestCA" -m 3 -v 60 -d ../CA -i req -o user.cert -f ${PWFILE} 2>&1 - if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Sign User Cert"} - fi - echo "Import the new Cert" - echo "certutil -A -n \"TestUser\" -t \"u,u,u\" -d . -f ${PWFILE} -i user.cert 2>&1" - certutil -A -n "TestUser" -t "u,u,u" -d . -f ${PWFILE} -i user.cert 2>&1 - if [ $? -ne 0 ]; then - CERTFAILED=${CERTFAILED-"Import User"} - fi - if [ -n "${CERTFAILED}" ]; then - echo "<TR><TD>Creating User Cert</TD><TD bgcolor=red>Failed ($CERTFAILED)</TD><TR>" >> ${RESULTS} - else - echo "<TR><TD>Creating User Cert</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - fi - - echo "***** Creating Server CA Issued Certificate for ${HOST}.${DOMSUF} *****" - netstat >> ${NOISE_FILE} 2>&1 - date >> ${NOISE_FILE} 2>&1 - if [ ! -d ${SERVERDIR} ]; then - mkdir -p ${SERVERDIR} - fi - cd ${SERVERDIR} - cp ../CA/*.db . - echo "certutil -S -n \"${HOST}.${DOMSUF}\" -s \"CN=${HOST}.${DOMSUF}, O=BOGUS Netscape, L=Mountain View, ST=California, C=US\" -t \"Pu,Pu,Pu\" -c "TestCA" -v 60 -d . -f ${PWFILE} -z ${NOISE_FILE} 2>&1" - certutil -S -n "${HOST}.${DOMSUF}" -s "CN=${HOST}.${DOMSUF}, O=BOGUS Netscape, L=Mountain View, ST=California, C=US" -t "Pu,Pu,Pu" -c "TestCA" -m 1 -v 60 -d . -f ${PWFILE} -z ${NOISE_FILE} 2>&1 - if [ $? -ne 0 ]; then - echo "<TR><TD>Creating Server Cert</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - else - echo "<TR><TD>Creating Server Cert</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - fi - echo "</TABLE><BR>" >> ${RESULTS} - - rm -f ${TEMPFILES} -fi - - -# OK now lets run the tests.... -if [ $coverage -eq 1 ]; then - echo "********************* SSL Cipher Coverage ****************************" - echo "<TABLE BORDER=1><TR><TH COLSPAN=3>SSL Cipher Coverage</TH></TR>" >> ${RESULTS} - echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} - cd ${CLIENTDIR} - - # Launch the server - echo "selfserv -v -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -i ${SERVERPID} -w nss -c ABCDEFabcdefghijklm & " - if [ ${fileout} -eq 1 ]; then - selfserv -v -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -i ${SERVERPID} -w nss -c ABCDEFabcdefghijklm > ${SERVEROUTFILE} 2>&1 & - else - selfserv -v -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss -i ${SERVERPID} -c ABCDEFabcdefghijklm & - fi - # wait until it's alive - echo "tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE}" - tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE} - if [ $? -ne 0 ]; then - echo "<TR><TD> Wait for Server </TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - else - echo "<TR><TD> Wait for Server </TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - fi - - cat ${SSLCOV} | while read tls param testname - do - if [ $tls != "#" ]; then - echo "********************* $testname ****************************" - TLS_FLAG=-T - if [ $tls = "TLS" ]; then - TLS_FLAG="" - fi - sparam="" - if [ ${param} = "i" ]; then - sparam='-c i' - fi - - is_selfserv_alive - echo "tstclnt -p ${PORT} -h ${HOST} -c ${param} ${TLS_FLAG} -f -d . redir from ${REQUEST_FILE}" - tstclnt -p ${PORT} -h ${HOST} -c ${param} ${TLS_FLAG} -f -d . < ${REQUEST_FILE} - if [ $? -ne 0 ]; then - echo "<TR><TD>"${testname}"</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - else - echo "<TR><TD>"${testname}"</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - fi - fi - done - # now kill the server - ${KILL} `cat ${SERVERPID}` - wait `cat ${SERVERPID}` - if [ ${fileout} -eq 1 ]; then - cat ${SERVEROUTFILE} - fi - ${SLEEP} - - echo "</TABLE><BR>" >> ${RESULTS} -fi - -if [ $auth -eq 1 ]; then - echo "********************* SSL Client Auth ****************************" - cd ${CLIENTDIR} - echo "<TABLE BORDER=1><TR><TH COLSPAN=3>SSL Client Authentication</TH></TR>" >> ${RESULTS} - echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} - - cat ${SSLAUTH} | while read value sparam cparam testname - do - if [ $value != "#" ]; then - echo "***** $testname ****" - sparam=`echo $sparam | sed -e 's;_; ;g'` - cparam=`echo $cparam | sed -e 's;_; ;g'` - echo "selfserv -v -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss ${sparam} -i ${SERVERPID} &" - if [ ${fileout} -eq 1 ]; then - selfserv -v -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss ${sparam} -i ${SERVERPID} > ${SERVEROUTFILE} 2>&1 & - else - selfserv -v -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss ${sparam} -i ${SERVERPID} & - fi - echo "tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} redir from ${REQUEST_FILE}" - tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE} - if [ $? -ne 0 ]; then - echo "<TR><TD> Wait for Server </TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - echo "tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} redir from ${REQUEST_FILE}" - tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE} - fi - pwd - is_selfserv_alive - echo "tstclnt -p ${PORT} -h ${HOST} -f -d ${CLIENTDIR} ${cparam} redir from ${REQUEST_FILE}" - tstclnt -p ${PORT} -h ${HOST} -f -d ${CLIENTDIR} ${cparam} < ${REQUEST_FILE} - ret=$? +############################## ssl_auth ################################ +# local shell function to perform SSL Client Authentication tests +######################################################################## +ssl_auth() +{ + html_head "SSL Client Authentication" + + cat ${SSLAUTH} | while read value sparam cparam testname + do + if [ $value != "#" ]; then + cparam=`echo $cparam | sed -e 's;_; ;g'` + start_selfserv + + echo "tstclnt -p ${PORT} -h ${HOST} -f -d . ${cparam} \\" + echo " < ${REQUEST_FILE}" + tstclnt -p ${PORT} -h ${HOST} -f -d . ${cparam} < ${REQUEST_FILE} + ret=$? + + # the NT client does not return the same error code as Unix + # FIXME - this is a serious bug in the NT testclient + if [ ${OS_ARCH} = "WINNT" -a $value -ne 0 -a $ret -ne 0 ]; then + echo "$SCRIPTNAME: WARNING! Testclient returned $ret, expect " + echo " $value (no error as tmp workaround)" + value=$ret + fi + + html_msg $ret $value "${testname}" \ + "produced a returncode of $ret, expected is $value" + kill_selfserv + fi + done + + html "</TABLE><BR>" +} -# -# for some reason the NT client does not return the same error code as Unix -# (sigh). -# - if [ ${OS_ARCH} = "WINNT" ]; then - if [ $value -ne 0 ]; then - if [ $ret -ne 0 ]; then - value=$ret - fi - fi - fi - - if [ $ret -ne $value ]; then - echo "<TR><TD>"${testname}"</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - echo "FAILURE: test $testname produced a returncode of $ret, expected is $value O_CRON = $O_CRON" - else - echo "<TR><TD>"${testname}"</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - echo "test $testname produced a returncode of $ret as expected " - fi - ${KILL} `cat ${SERVERPID}` - wait `cat ${SERVERPID}` - if [ ${fileout} -eq 1 ]; then - cat ${SERVEROUTFILE} - fi - ${SLEEP} - fi - done - - echo "</TABLE><BR>" >> ${RESULTS} -fi - - -if [ $stress -eq 1 ]; then - echo "********************* Stress Test ****************************" - cd ${CLIENTDIR} - echo "<TABLE BORDER=1><TR><TH COLSPAN=3>SSL Stress Test</TH></TR>" >> ${RESULTS} - echo "<TR><TH width=500>Test Case</TH><TH width=50>Result</TH></TR>" >> ${RESULTS} - - cat ${SSLSTRESS} | while read value sparam cparam testname - do - if [ $value != "#" ]; then - echo "********************* $testname ****************************" - sparam=`echo $sparam | sed -e 's;_; ;g'` - cparam=`echo $cparam | sed -e 's;_; ;g'` - echo "selfserv -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss ${sparam} -i ${SERVERPID} $verbose & started at `date`" - if [ ${fileout} -eq 1 ]; then - selfserv -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss ${sparam} -i ${SERVERPID} $verbose > ${SERVEROUTFILE} 2>&1 & - else - selfserv -p ${PORT} -d ${SERVERDIR} -n ${HOST}.${DOMSUF} -w nss ${sparam} -i ${SERVERPID} $verbose & - fi - echo "tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE} started at `date`" - tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE} - if [ $? -ne 0 ]; then - echo "<TR><TD> Wait for Server </TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - echo "tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} redir from ${REQUEST_FILE}" - tstclnt -p ${PORT} -h ${HOST} -q -d ${CLIENTDIR} < ${REQUEST_FILE} - fi - - is_selfserv_alive - echo "strsclnt -p ${PORT} -d . -w nss $cparam $verbose ${HOST}.${DOMSUF} started at `date`" - strsclnt -p ${PORT} -d . -w nss $cparam $verbose ${HOST}.${DOMSUF} - echo "strsclnt completed at `date`" - - if [ $? -ne $value ]; then - echo "<TR><TD>"${testname}"</TD><TD bgcolor=red>Failed</TD><TR>" >> ${RESULTS} - else - echo "<TR><TD>"${testname}"</TD><TD bgcolor=lightGreen>Passed</TD><TR>" >> ${RESULTS} - fi - ${KILL} `cat ${SERVERPID}` - wait `cat ${SERVERPID}` - if [ ${fileout} -eq 1 ]; then - cat ${SERVEROUTFILE} - fi - ${SLEEP} - fi - done - - echo "</TABLE><BR>" >> ${RESULTS} -fi - -rm -f ${TEMPFILES} + +############################## ssl_stress ############################## +# local shell function to perform SSL stress test +######################################################################## +ssl_stress() +{ + html_head "SSL Stress Test" + + cat ${SSLSTRESS} | while read value sparam cparam testname + do + if [ $value != "#" ]; then + cparam=`echo $cparam | sed -e 's;_; ;g'` + start_selfserv + + echo "strsclnt -p ${PORT} -d . -w nss $cparam $verbose \\" + echo " ${HOST}.${DOMSUF}" + echo "strsclnt started at `date`" + strsclnt -p ${PORT} -d . -w nss $cparam $verbose ${HOST}.${DOMSUF} + echo "strsclnt completed at `date`" + + html_msg $? $value "${testname}" + kill_selfserv + fi + done + + html "</TABLE><BR>" +} + +############################## ssl_cleanup ############################# +# local shell function to finish this script (no exit since it might be +# sourced) +######################################################################## +ssl_cleanup() +{ + rm $SERVERPID 2>/dev/null + cd ${QADIR} + . common/cleanup.sh +} + +################## main ################################################# + +ssl_init +ssl_cov +ssl_auth +ssl_stress +ssl_cleanup |