"Fossies" - the Fresh Open Source Software Archive

Member "nss-3.37.3/nss/tests/all.sh" (5 Jun 2018, 11153 Bytes) of package /linux/misc/nss-3.37.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "all.sh": 3.36.1_vs_3.37.

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