tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

gtests.sh (3117B)


      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 # similar to all.sh this file runs drives gtests.
     10 #
     11 # needs to work on all Unix and Windows platforms
     12 #
     13 # special strings
     14 # ---------------
     15 #   FIXME ... known problems, search for this string
     16 #   NOTE .... unexpected behavior
     17 #
     18 ########################################################################
     19 
     20 ############################## gtest_init ##############################
     21 # local shell function to initialize this script
     22 ########################################################################
     23 gtest_init()
     24 {
     25  cd "$(dirname "$1")"
     26  pwd
     27  SOURCE_DIR="$PWD"/../..
     28 
     29  if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
     30      cd ../common
     31      . ./init.sh
     32  fi
     33 
     34  SCRIPTNAME=gtests.sh
     35  . "${QADIR}"/common/certsetup.sh
     36 
     37  if [ -z "${CLEANUP}" ] ; then   # if nobody else is responsible for
     38    CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
     39  fi
     40 
     41  mkdir -p "${GTESTDIR}"
     42  cd "${GTESTDIR}"
     43 }
     44 
     45 ########################## gtest_start #############################
     46 # Local function to actually start the test
     47 ####################################################################
     48 gtest_start()
     49 {
     50  echo "gtests: ${GTESTS}"
     51  for i in ${GTESTS}; do
     52    if [ ! -f "${BINDIR}/$i" ]; then
     53      html_unknown "Skipping $i (not built)"
     54      continue
     55    fi
     56    DIR="${GTESTDIR}/$i"
     57    html_head "$i"
     58    if [ ! -d "$DIR" ]; then
     59      mkdir -p "$DIR"
     60      echo "${BINDIR}/certutil" -N -d "$DIR" --empty-password 2>&1
     61      "${BINDIR}/certutil" -N -d "$DIR" --empty-password 2>&1
     62 
     63      PROFILEDIR="$DIR" make_cert dummy p256 sign
     64    fi
     65    pushd "$DIR"
     66    GTESTREPORT="$DIR/report.xml"
     67    PARSED_REPORT="$DIR/report.parsed"
     68    # NSS CI sets a lower max for PBE iterations, otherwise cert.sh
     69    # is very slow. Unset this maxiumum for softoken_gtest, as it
     70    # needs to check the default value.
     71    if [ "$i" = "softoken_gtest" ]; then
     72      OLD_MAX_PBE_ITERATIONS=$NSS_MAX_MP_PBE_ITERATION_COUNT
     73      unset NSS_MAX_MP_PBE_ITERATION_COUNT
     74    fi
     75    echo "executing $i"
     76    "${BINDIR}/$i" -s "${SOURCE_DIR}/gtests/$i" -d "$DIR" -w \
     77                   --gtest_output=xml:"${GTESTREPORT}" \
     78                   --gtest_filter="${GTESTFILTER:-*}"
     79    html_msg $? 0 "$i run successfully"
     80    if [ "$i" = "softoken_gtest" ]; then
     81      export NSS_MAX_MP_PBE_ITERATION_COUNT=$OLD_MAX_PBE_ITERATIONS
     82    fi
     83 
     84    echo "test output dir: ${GTESTREPORT}"
     85    echo "processing the parsed report"
     86    gtest_parse_report ${GTESTREPORT}
     87    popd
     88  done
     89 }
     90 
     91 gtest_cleanup()
     92 {
     93  html "</TABLE><BR>"
     94  . "${QADIR}"/common/cleanup.sh
     95 }
     96 
     97 ################## main #################################################
     98 GTESTS="${GTESTS:-base_gtest certhigh_gtest certdb_gtest der_gtest pk11_gtest util_gtest freebl_gtest softoken_gtest sysinit_gtest smime_gtest mozpkix_gtest}"
     99 gtest_init "$0"
    100 gtest_start
    101 gtest_cleanup