diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /security/nss/tests/libpkix/common | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'security/nss/tests/libpkix/common')
-rw-r--r-- | security/nss/tests/libpkix/common/libpkix_init.sh | 324 | ||||
-rw-r--r-- | security/nss/tests/libpkix/common/libpkix_init_nist.sh | 70 |
2 files changed, 394 insertions, 0 deletions
diff --git a/security/nss/tests/libpkix/common/libpkix_init.sh b/security/nss/tests/libpkix/common/libpkix_init.sh new file mode 100644 index 000000000..01eb070e1 --- /dev/null +++ b/security/nss/tests/libpkix/common/libpkix_init.sh @@ -0,0 +1,324 @@ +#!/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/. +# +# libpkix_init.sh +# + +### when the script is exiting, handle it in the Cleanup routine...the result +### value will get set to 0 if all the tests completed successfully, so we can +### use that value in the handler + +trap 'Cleanup' EXIT + +result=1 +checkmem=0 +arenas=0 +quiet=0 + +doNIST=1 +doNIST_PDTest=0 +doPD=0 +doTop=0 +doModule=0 +doPki=0 +doOCSP=0 +doOCSPTest=0 + +combinedErrors=0 +totalErrors=0 +prematureTermination=0 +errors=0 + +if [ -z "${INIT_SOURCED}" ] ; then + libpkixCommondir=`pwd` + cd ../../common + . ./init.sh > /dev/null + cd ${libpkixCommondir} +fi + +DIST_BIN=${DIST}/${OBJDIR}/bin + +### setup some defaults +WD=`pwd` +prog=`basename $0` +testOut=${HOSTDIR}/${prog}.$$ +testOutMem=${HOSTDIR}/${prog}_mem.$$ + +#################### +# cleanup from tests +#################### +Cleanup() +{ + if [ ${testOut} != "" ]; then + rm -f ${testOut} + fi + + if [ ${testOutMem} != "" ]; then + rm -f ${testOutMem} + fi + + if [ -d ../../nist_pkits/certs ]; then + rm -f ../../nist_pkits/certs + fi + + if [ ${doTop} -eq 1 ]; then + for i in ${linkMStoreNistFiles}; do + if [ -f ${HOSTDIR}/rev_data/multiple_certstores/$i ]; then + rm -f ${HOSTDIR}/rev_data/multiple_certstores/$i + fi + done + if [ -d ${HOSTDIR}/rev_data/multiple_certstores ]; then + rm -fr ${HOSTDIR}/rev_data/multiple_certstores + fi + fi + + if [ ${doModule} -eq 1 ]; then + for i in ${linkModuleNistFiles}; do + if [ -f ${HOSTDIR}/rev_data/local/$i ]; then + rm -f ${HOSTDIR}/rev_data/local/$i + fi + done + for i in ${localCRLFiles}; do + if [ -f ${HOSTDIR}/rev_data/local/$i ]; then + rm -f ${HOSTDIR}/rev_data/local/$i + fi + done + fi + + if [ ${doPki} -eq 1 ]; then + for i in ${linkPkiNistFiles}; do + if [ -f ${HOSTDIR}/rev_data/local/$i ]; then + rm -f ${HOSTDIR}/rev_data/local/$i + fi + done + fi + + return ${result} +} + +### ParseArgs +ParseArgs() # args +{ + while [ $# -gt 0 ]; do + if [ $1 = "-checkmem" ]; then + checkmem=1 + elif [ $1 = "-quiet" ]; then + quiet=1 + elif [ $1 = "-arenas" ]; then + arenas=1 + fi + shift + done +} + +Display() # string +{ + if [ ${quiet} -eq 0 ]; then + echo "$1" + fi +} + +testHeadingEcho() +{ + echo "*******************************************************************************" + echo "START OF TESTS FOR ${testunit}${memText}" + echo "*******************************************************************************" + echo "" +} + +testEndingEcho() +{ + if [ ${totalErrors} -eq 0 ]; then + echo "" + echo "************************************************************" + echo "END OF TESTS FOR ${testunit}: ALL TESTS COMPLETED SUCCESSFULLY" + echo "************************************************************" + echo "" + return 0 + fi + + if [ ${totalErrors} -eq 1 ]; then + plural="" + else + plural="S" + fi + + echo "" + echo "************************************************************" + echo "END OF TESTS FOR ${testunit}: ${totalErrors} TEST${plural} FAILED" + echo "************************************************************" + echo "" + return ${totalErrors} +} + +########### +# RunTests +########### +RunTests() +{ + errors=0 + memErrors=0 + prematureErrors=0 + + failedpgms="" + failedmempgms="" + failedprematurepgms="" + memText="" + arenaCmd="" + + if [ ${checkmem} -eq 1 ]; then + memText=" (Memory Checking Enabled)" + fi + + if [ ${arenas} -eq 1 ]; then + arenaCmd="-arenas" + fi + + # + # Announce start of tests + # + Display "*******************************************************************************" + Display "START OF TESTS FOR PKIX ${testunit} ${memText}" + Display "*******************************************************************************" + Display "" + + # run each test specified by the input redirection below + + while read testPgm args; do + + shortTestPurpose=`echo $args | awk '{print $1 " " $2 " "}'` + fullTestPurpose=${args} + if [ ${doTop} -eq 1 -o ${doModule} -eq 1 -o ${doPki} -eq 1 ]; then + testPurpose=${shortTestPurpose} + else + testPurpose=${fullTestPurpose} + fi + + # If we want shorter command printout for NIST tests, delete next line + testPurpose=${fullTestPurpose} + + # Skip OCSP tests if OCSP is not defined in the environment + if [ ${doOCSPTest} -eq 0 ]; then + hasOCSP=`echo ${args} | grep OCSP-Test` + if [ ! -z "${hasOCSP}" ]; then + Display "SKIPPING ${testPgm} ${testPurpose}" + continue + fi + fi + + if [ ${doNIST} -eq 0 ]; then + hasNIST=`echo ${args} | grep NIST-Test` + if [ ! -z "${hasNIST}" ]; then + Display "SKIPPING ${testPgm} ${testPurpose}" + continue + fi + fi + + # This "if" is not reached when doNIST is not set. The assumption + # is that NIST tests are basic, NIST Path Discovery tests are + # additional + if [ ${doNIST_PDTest} -eq 0 ]; then + hasNIST=`echo ${args} | grep NIST-PDTest` + if [ ! -z "${hasNIST}" ]; then + Display "SKIPPING ${testPgm} ${testPurpose}" + continue + fi + fi + + Display "RUNNING ${testPgm} ${arenaCmd} ${testPurpose}" + + numtests=`expr ${numtests} + 1` + + if [ ${checkmem} -eq 1 ]; then + dbx -C -c "runargs ${arenaCmd} ${args};check -all;run;exit" ${DIST_BIN}/${testPgm} > ${testOut} 2>&1 + else + ${DIST_BIN}/${testPgm} ${arenaCmd} ${args} > ${testOut} 2>&1 + fi + + # Examine output file to see if test failed and keep track of number + # of failures and names of failed tests. This assumes that the test + # uses our utility library for displaying information + + cat ${testOut} | tail -2 | grep "COMPLETED SUCCESSFULLY" >/dev/null 2>&1 + + if [ $? -ne 0 ]; then + testFail=1 + errors=`expr ${errors} + 1` + failedpgms="${failedpgms}\n${testPgm} ${testPurpose} " +# cat ${testOut} + else + testFail=0 + passed=`expr ${passed} + 1` + fi + cat ${testOut} + html_msg ${testFail} 0 "${testPgm} ${arenaCmd} ${shortTestPurpose}" + + if [ ${checkmem} -eq 1 ]; then + grep "(actual leaks:" ${testOut} > ${testOutMem} 2>&1 + if [ $? -ne 0 ]; then + prematureErrors=`expr ${prematureErrors} + 1` + failedprematurepgms="${failedprematurepgms}${testPgm} " + Display "...program terminated prematurely (unable to check for memory leak errors) ..." + else + #grep "(actual leaks: 0" ${testOut} > /dev/null 2>&1 + # special consideration for memory leak in NSS_NoDB_Init + grep "(actual leaks: 1 total size: 4 bytes)" ${testOut} > /dev/null 2>&1 + if [ $? -ne 0 ]; then + memErrors=`expr ${memErrors} + 1` + failedmempgms="${failedmempgms}${testPgm} " + cat ${testOutMem} + fi + fi + fi + + done + + if [ ${errors} -eq 0 ]; then + if [ ${memErrors} -eq 0 ]; then + Display "" + Display "************************************************************" + Display "END OF TESTS FOR PKIX ${testunit}: ALL TESTS COMPLETED SUCCESSFULLY" + Display "************************************************************" + Display "" + return 0 + fi + fi + + if [ ${errors} -eq 1 ]; then + plural="" + else + plural="S" + fi + + Display "" + Display "*******************************************************************************" + Display "END OF TESTS FOR PKIX ${testunit}: ${errors} UNIT TEST${plural} FAILED: ${failedpgms}" + Display "" + if [ ${checkmem} -eq 1 ]; then + if [ ${memErrors} -eq 1 ]; then + memPlural="" + else + memPlural="S" + fi + Display " ${memErrors} MEMORY LEAK TEST${memPlural} FAILED: ${failedmempgms}" + + if [ ${prematureErrors} -ne 0 ]; then + if [ ${prematureErrors} -eq 1 ]; then + prematurePlural="" + else + prematurePlural="S" + fi + Display " ${prematureErrors} MEMORY LEAK TEST${prematurePlural} INDETERMINATE: ${failedprematurepgms}" + fi + + fi + Display "*******************************************************************************" + Display "" + combinedErrors=`expr ${errors} + ${memErrors} + ${prematureErrors}` + + return ${combinedErrors} + +} diff --git a/security/nss/tests/libpkix/common/libpkix_init_nist.sh b/security/nss/tests/libpkix/common/libpkix_init_nist.sh new file mode 100644 index 000000000..d4dfd2a6c --- /dev/null +++ b/security/nss/tests/libpkix/common/libpkix_init_nist.sh @@ -0,0 +1,70 @@ +#!/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/. +# +# libpkix_init_nist.sh +# + +# +# Any test that uses NIST files should have a tag of either NIST-Test or +# NIST-Test-Files-Used at the command option so if there are no NIST files +# installed in the system, the test can be skipped +# + +if [ -z "${NIST_FILES_DIR}" ] ; then + Display "" + Display "*******************************************************************************" + Display "The environment variable NIST_FILES_DIR is not defined. Therefore" + Display "tests depending on it will be skipped. To enable these tests set" + Display "NIST_FILES_DIR to the directory where NIST Certificates and CRLs" + Display "are located." + Display "*******************************************************************************" + Display "" + doNIST=0 +else + + NIST=${NIST_FILES_DIR} + doNIST=1 +fi + +# +# Any tests that use NIST Path Discovery files should have a tag of NIST-PDTest +# at the command option so if there are no NIST Path Discovery files +# installed in the system, the test can be skipped +# +if [ ${doPD} -eq 1 -a -z "${PDVAL}" ] ; then + + Display "" + Display "*******************************************************************************" + Display "The environment variable PDVAL is not defined. Therefore tests" + Display "depending on it will be skipped. To enable these tests set PDVAL to" + Display "the directory where NIST Path Discovery Certificates are located." + Display "*******************************************************************************" + Display "" + doNIST_PDTest=0 +else + + NIST_PDTEST=${PDVAL} + doNIST_PDTest=1 +fi + +# +# Any tests that use an OCSP Server should have a tag of OCSP-Test at the +# command option so if there is no OCSP Server installed in the system, the +# test can be skipped +# +if [ ${doOCSP} -eq 1 -a -z "${OCSP}" ] ; then + + Display "" + Display "*******************************************************************************" + Display "The environment variable OCSP is not defined. Therefore tests" + Display "depending on it will be skipped. To enable these tests set OCSP" + Display "non-NULL (the actual URI used is taken from the AIA extension)." + Display "*******************************************************************************" + Display "" + doOCSPTest=0 +else + doOCSPTest=1 +fi |