security/nss/tests/all.sh

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

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

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

michael@0 1 #!/bin/bash
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 ########################################################################
michael@0 8 #
michael@0 9 # mozilla/security/nss/tests/all.sh
michael@0 10 #
michael@0 11 # Script to start selected available NSS QA suites on one machine
michael@0 12 # this script is called or sourced by NSS QA which runs on all required
michael@0 13 # platforms
michael@0 14 #
michael@0 15 # Needs to work on all Unix and Windows platforms
michael@0 16 #
michael@0 17 # Currently available NSS QA suites:
michael@0 18 # ----------------------------------
michael@0 19 # cipher.sh - tests NSS ciphers
michael@0 20 # libpkix.sh - tests PKIX functionality
michael@0 21 # cert.sh - exercises certutil and creates certs necessary for
michael@0 22 # all other tests
michael@0 23 # dbtests.sh - tests related to certificate databases
michael@0 24 # tools.sh - tests the majority of the NSS tools
michael@0 25 # fips.sh - tests basic functionallity of NSS in FIPS-compliant
michael@0 26 # - mode
michael@0 27 # sdr.sh - tests NSS SDR
michael@0 28 # crmf.sh - CRMF/CMMF testing
michael@0 29 # smime.sh - S/MIME testing
michael@0 30 # ssl.sh - tests SSL V2 SSL V3 and TLS
michael@0 31 # ocsp.sh - OCSP testing
michael@0 32 # merge.sh - tests merging old and new shareable databases
michael@0 33 # pkits.sh - NIST/PKITS tests
michael@0 34 # chains.sh - PKIX cert chains tests
michael@0 35 # dbupgrade.sh - upgrade databases to new shareable version (used
michael@0 36 # only in upgrade test cycle)
michael@0 37 # memleak.sh - memory leak testing (optional)
michael@0 38 #
michael@0 39 # NSS testing is now devided to 4 cycles:
michael@0 40 # ---------------------------------------
michael@0 41 # standard - run test suites with defaults settings
michael@0 42 # pkix - run test suites with PKIX enabled
michael@0 43 # upgradedb - upgrade existing certificate databases to shareable
michael@0 44 # format (creates them if doesn't exist yet) and run
michael@0 45 # test suites with those databases
michael@0 46 # sharedb - run test suites with shareable database format
michael@0 47 # enabled (databases are created directly to this
michael@0 48 # format)
michael@0 49 #
michael@0 50 # Mandatory environment variables (to be set before testing):
michael@0 51 # -----------------------------------------------------------
michael@0 52 # HOST - test machine host name
michael@0 53 # DOMSUF - test machine domain name
michael@0 54 #
michael@0 55 # Optional environment variables to specify build to use:
michael@0 56 # -------------------------------------------------------
michael@0 57 # BUILT_OPT - use optimized/debug build
michael@0 58 # USE_64 - use 64bit/32bit build
michael@0 59 #
michael@0 60 # Optional environment variables to enable specific NSS features:
michael@0 61 # ---------------------------------------------------------------
michael@0 62 # NSS_DISABLE_ECC - disable ECC
michael@0 63 # NSS_ECC_MORE_THAN_SUITE_B - enable extended ECC
michael@0 64 #
michael@0 65 # Optional environment variables to select which cycles/suites to test:
michael@0 66 # ---------------------------------------------------------------------
michael@0 67 # NSS_CYCLES - list of cycles to run (separated by space
michael@0 68 # character)
michael@0 69 # - by default all cycles are tested
michael@0 70 #
michael@0 71 # NSS_TESTS - list of all test suites to run (separated by space
michael@0 72 # character, without trailing .sh)
michael@0 73 # - this list can be reduced for individual test cycles
michael@0 74 #
michael@0 75 # NSS_SSL_TESTS - list of ssl tests to run (see ssl.sh)
michael@0 76 # NSS_SSL_RUN - list of ssl sub-tests to run (see ssl.sh)
michael@0 77 #
michael@0 78 # Testing schema:
michael@0 79 # ---------------
michael@0 80 # all.sh ~ (main)
michael@0 81 # | |
michael@0 82 # +------------+------------+-----------+ ~ run_cycles
michael@0 83 # | | | | |
michael@0 84 # standard pkix upgradedb sharedb ~ run_cycle_*
michael@0 85 # | |
michael@0 86 # +------+------+------+-----> ~ run_tests
michael@0 87 # | | | | |
michael@0 88 # cert tools fips ssl ... ~ . *.sh
michael@0 89 #
michael@0 90 # Special strings:
michael@0 91 # ----------------
michael@0 92 # FIXME ... known problems, search for this string
michael@0 93 # NOTE .... unexpected behavior
michael@0 94 #
michael@0 95 # NOTE:
michael@0 96 # -----
michael@0 97 # Unlike the old QA this is based on files sourcing each other
michael@0 98 # This is done to save time, since a great portion of time is lost
michael@0 99 # in calling and sourcing the same things multiple times over the
michael@0 100 # network. Also, this way all scripts have all shell function
michael@0 101 # available and a completely common environment
michael@0 102 #
michael@0 103 ########################################################################
michael@0 104
michael@0 105 ############################## run_tests ###############################
michael@0 106 # run test suites defined in TESTS variable, skip scripts defined in
michael@0 107 # TESTS_SKIP variable
michael@0 108 ########################################################################
michael@0 109 run_tests()
michael@0 110 {
michael@0 111 for TEST in ${TESTS}
michael@0 112 do
michael@0 113 echo "${TESTS_SKIP}" | grep "${TEST}" > /dev/null
michael@0 114 if [ $? -eq 0 ]; then
michael@0 115 continue
michael@0 116 fi
michael@0 117
michael@0 118 SCRIPTNAME=${TEST}.sh
michael@0 119 echo "Running tests for ${TEST}"
michael@0 120 echo "TIMESTAMP ${TEST} BEGIN: `date`"
michael@0 121 (cd ${QADIR}/${TEST}; . ./${SCRIPTNAME} 2>&1)
michael@0 122 echo "TIMESTAMP ${TEST} END: `date`"
michael@0 123 done
michael@0 124 }
michael@0 125
michael@0 126 ########################## run_cycle_standard ##########################
michael@0 127 # run test suites with defaults settings (no PKIX, no sharedb)
michael@0 128 ########################################################################
michael@0 129 run_cycle_standard()
michael@0 130 {
michael@0 131 TEST_MODE=STANDARD
michael@0 132
michael@0 133 TESTS="${ALL_TESTS}"
michael@0 134 TESTS_SKIP=
michael@0 135
michael@0 136 run_tests
michael@0 137 }
michael@0 138
michael@0 139 ############################ run_cycle_pkix ############################
michael@0 140 # run test suites with PKIX enabled
michael@0 141 ########################################################################
michael@0 142 run_cycle_pkix()
michael@0 143 {
michael@0 144 TEST_MODE=PKIX
michael@0 145
michael@0 146 TABLE_ARGS="bgcolor=cyan"
michael@0 147 html_head "Testing with PKIX"
michael@0 148 html "</TABLE><BR>"
michael@0 149
michael@0 150 HOSTDIR="${HOSTDIR}/pkix"
michael@0 151 mkdir -p "${HOSTDIR}"
michael@0 152 init_directories
michael@0 153
michael@0 154 NSS_ENABLE_PKIX_VERIFY="1"
michael@0 155 export NSS_ENABLE_PKIX_VERIFY
michael@0 156
michael@0 157 TESTS="${ALL_TESTS}"
michael@0 158 TESTS_SKIP="cipher dbtests sdr crmf smime merge multinit"
michael@0 159
michael@0 160 echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null
michael@0 161 RET=$?
michael@0 162 NSS_SSL_TESTS=`echo "${NSS_SSL_TESTS}" | sed -e "s/normal//g" -e "s/bypass//g" -e "s/fips//g" -e "s/_//g"`
michael@0 163 [ ${RET} -eq 0 ] && NSS_SSL_TESTS="${NSS_SSL_TESTS} bypass_bypass"
michael@0 164
michael@0 165 run_tests
michael@0 166 }
michael@0 167
michael@0 168 ######################### run_cycle_upgrade_db #########################
michael@0 169 # upgrades certificate database to shareable format and run test suites
michael@0 170 # with those databases
michael@0 171 ########################################################################
michael@0 172 run_cycle_upgrade_db()
michael@0 173 {
michael@0 174 TEST_MODE=UPGRADE_DB
michael@0 175
michael@0 176 TABLE_ARGS="bgcolor=pink"
michael@0 177 html_head "Testing with upgraded library"
michael@0 178 html "</TABLE><BR>"
michael@0 179
michael@0 180 OLDHOSTDIR="${HOSTDIR}"
michael@0 181 HOSTDIR="${HOSTDIR}/upgradedb"
michael@0 182 mkdir -p "${HOSTDIR}"
michael@0 183 init_directories
michael@0 184
michael@0 185 if [ -r "${OLDHOSTDIR}/cert.log" ]; then
michael@0 186 DIRS="alicedir bobdir CA cert_extensions client clientCA dave eccurves eve ext_client ext_server fips SDR server serverCA stapling tools/copydir cert.log cert.done tests.*"
michael@0 187 for i in $DIRS
michael@0 188 do
michael@0 189 cp -r ${OLDHOSTDIR}/${i} ${HOSTDIR} #2> /dev/null
michael@0 190 done
michael@0 191 fi
michael@0 192
michael@0 193 # upgrade certs dbs to shared db
michael@0 194 TESTS="dbupgrade"
michael@0 195 TESTS_SKIP=
michael@0 196
michael@0 197 run_tests
michael@0 198
michael@0 199 NSS_DEFAULT_DB_TYPE="sql"
michael@0 200 export NSS_DEFAULT_DB_TYPE
michael@0 201
michael@0 202 # run the subset of tests with the upgraded database
michael@0 203 TESTS="${ALL_TESTS}"
michael@0 204 TESTS_SKIP="cipher libpkix cert dbtests sdr ocsp pkits chains"
michael@0 205
michael@0 206 echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null
michael@0 207 RET=$?
michael@0 208 NSS_SSL_TESTS=`echo "${NSS_SSL_TESTS}" | sed -e "s/normal//g" -e "s/bypass//g" -e "s/fips//g" -e "s/_//g"`
michael@0 209 [ ${RET} -eq 0 ] && NSS_SSL_TESTS="${NSS_SSL_TESTS} bypass_bypass"
michael@0 210 NSS_SSL_RUN=`echo "${NSS_SSL_RUN}" | sed -e "s/cov//g" -e "s/auth//g"`
michael@0 211
michael@0 212 run_tests
michael@0 213 }
michael@0 214
michael@0 215 ########################## run_cycle_shared_db #########################
michael@0 216 # run test suites with certificate databases set to shareable format
michael@0 217 ########################################################################
michael@0 218 run_cycle_shared_db()
michael@0 219 {
michael@0 220 TEST_MODE=SHARED_DB
michael@0 221
michael@0 222 TABLE_ARGS="bgcolor=yellow"
michael@0 223 html_head "Testing with shared library"
michael@0 224 html "</TABLE><BR>"
michael@0 225
michael@0 226 HOSTDIR="${HOSTDIR}/sharedb"
michael@0 227 mkdir -p "${HOSTDIR}"
michael@0 228 init_directories
michael@0 229
michael@0 230 NSS_DEFAULT_DB_TYPE="sql"
michael@0 231 export NSS_DEFAULT_DB_TYPE
michael@0 232
michael@0 233 # run the tests for native sharedb support
michael@0 234 TESTS="${ALL_TESTS}"
michael@0 235 TESTS_SKIP="cipher libpkix dbupgrade sdr ocsp pkits"
michael@0 236
michael@0 237 echo "${NSS_SSL_TESTS}" | grep "_" > /dev/null
michael@0 238 RET=$?
michael@0 239 NSS_SSL_TESTS=`echo "${NSS_SSL_TESTS}" | sed -e "s/normal//g" -e "s/bypass//g" -e "s/fips//g" -e "s/_//g"`
michael@0 240 [ ${RET} -eq 0 ] && NSS_SSL_TESTS="${NSS_SSL_TESTS} bypass_bypass"
michael@0 241 NSS_SSL_RUN=`echo "${NSS_SSL_RUN}" | sed -e "s/cov//g" -e "s/auth//g"`
michael@0 242
michael@0 243 run_tests
michael@0 244 }
michael@0 245
michael@0 246 ############################# run_cycles ###############################
michael@0 247 # run test cycles defined in CYCLES variable
michael@0 248 ########################################################################
michael@0 249 run_cycles()
michael@0 250 {
michael@0 251 for CYCLE in ${CYCLES}
michael@0 252 do
michael@0 253 case "${CYCLE}" in
michael@0 254 "standard")
michael@0 255 run_cycle_standard
michael@0 256 ;;
michael@0 257 "pkix")
michael@0 258 run_cycle_pkix
michael@0 259 ;;
michael@0 260 "upgradedb")
michael@0 261 run_cycle_upgrade_db
michael@0 262 ;;
michael@0 263 "sharedb")
michael@0 264 run_cycle_shared_db
michael@0 265 ;;
michael@0 266 esac
michael@0 267 . ${ENV_BACKUP}
michael@0 268 done
michael@0 269 }
michael@0 270
michael@0 271 ############################## main code ###############################
michael@0 272
michael@0 273 cycles="standard pkix upgradedb sharedb"
michael@0 274 CYCLES=${NSS_CYCLES:-$cycles}
michael@0 275
michael@0 276 tests="cipher lowhash libpkix cert dbtests tools fips sdr crmf smime ssl ocsp merge pkits chains"
michael@0 277 TESTS=${NSS_TESTS:-$tests}
michael@0 278
michael@0 279 ALL_TESTS=${TESTS}
michael@0 280
michael@0 281 nss_ssl_tests="crl bypass_normal normal_bypass fips_normal normal_fips iopr"
michael@0 282 NSS_SSL_TESTS="${NSS_SSL_TESTS:-$nss_ssl_tests}"
michael@0 283
michael@0 284 nss_ssl_run="cov auth stapling stress"
michael@0 285 NSS_SSL_RUN="${NSS_SSL_RUN:-$nss_ssl_run}"
michael@0 286
michael@0 287 SCRIPTNAME=all.sh
michael@0 288 CLEANUP="${SCRIPTNAME}"
michael@0 289 cd `dirname $0`
michael@0 290
michael@0 291 # all.sh should be the first one to try to source the init
michael@0 292 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
michael@0 293 cd common
michael@0 294 . ./init.sh
michael@0 295 fi
michael@0 296
michael@0 297 # NOTE:
michael@0 298 # Since in make at the top level, modutil is the last file
michael@0 299 # created, we check for modutil to know whether the build
michael@0 300 # is complete. If a new file is created after that, the
michael@0 301 # following test for modutil should check for that instead.
michael@0 302 # Exception: when building softoken only, shlibsign is the
michael@0 303 # last file created.
michael@0 304 if [ ${NSS_BUILD_SOFTOKEN_ONLY} -eq "1" ]; then
michael@0 305 LAST_FILE_BUILT=shlibsign
michael@0 306 else
michael@0 307 LAST_FILE_BUILT=modutil
michael@0 308 fi
michael@0 309
michael@0 310 if [ ! -f ${DIST}/${OBJDIR}/bin/${LAST_FILE_BUILT}${PROG_SUFFIX} ]; then
michael@0 311 echo "Build Incomplete. Aborting test." >> ${LOGFILE}
michael@0 312 html_head "Testing Initialization"
michael@0 313 Exit "Checking for build"
michael@0 314 fi
michael@0 315
michael@0 316 # NOTE:
michael@0 317 # Lists of enabled tests and other settings are stored to ${ENV_BACKUP}
michael@0 318 # file and are are restored after every test cycle.
michael@0 319
michael@0 320 ENV_BACKUP=${HOSTDIR}/env.sh
michael@0 321 env_backup > ${ENV_BACKUP}
michael@0 322
michael@0 323 if [ "${O_CRON}" = "ON" ]; then
michael@0 324 run_cycles >> ${LOGFILE}
michael@0 325 else
michael@0 326 run_cycles | tee -a ${LOGFILE}
michael@0 327 fi
michael@0 328
michael@0 329 SCRIPTNAME=all.sh
michael@0 330
michael@0 331 . ${QADIR}/common/cleanup.sh
michael@0 332

mercurial