tor-browser

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

runPerf.sh (4151B)


      1 #!/bin/sh
      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 # runPerf.sh
      8 #
      9 
     10 curdir=`pwd`
     11 cd ../common
     12 . ./libpkix_init.sh > /dev/null
     13 cd ${curdir}
     14 
     15 numtests=0
     16 passed=0
     17 testunit=PERFORMANCE
     18 
     19 totalErrors=0
     20 loopErrors=0
     21 
     22 ParseArgs $*
     23 
     24 testHeadingEcho
     25 
     26 Display "\nRunning executables at ${DIST_BIN}"
     27 Display "Using libraries at ${LD_LIBRARY_PATH}"
     28 
     29 
     30 # Check the performance data ...
     31 perfTest()
     32 {
     33 
     34    Display ""
     35    Display "*******************************************************************************"
     36    Display "START OF PKIX PERFORMANCE SCENARIOS ${memText}"
     37 Display "*******************************************************************************"
     38    Display ""
     39 
     40    while read perfPgm args; do
     41        numtests=`expr ${numtests} + 1`
     42        Display "Running ${perfPgm} ${args}"
     43        if [ ${checkmem} -eq 1 ]; then
     44            dbx -C -c "runargs $args; check -all ;run;exit" ${DIST_BIN}/${perfPgm} > ${testOut} 2>&1
     45        else
     46            ${DIST_BIN}/${perfPgm} ${args} > ${testOut} 2>&1
     47        fi
     48 
     49        # Examine output file to see if test failed and keep track of number
     50        # of failures and names of failed tests. This assumes that the test
     51        # uses our utility library for displaying information
     52 
     53        outputCount=`cat ${testOut} | grep "per second"`
     54 
     55        if [ $? -ne 0 ]; then
     56            errors=`expr ${errors} + 1`
     57            failedpgms="${failedpgms}${perfPgm} ${args}\n"
     58            cat ${testOut}
     59        else
     60            Display ${outputCount}
     61            passed=`expr ${passed} + 1`
     62        fi
     63 
     64        if [ ${checkmem} -eq 1 ]; then
     65            grep "(actual leaks:" ${testOut} > ${testOutMem} 2>&1
     66            if [ $? -ne 0 ]; then
     67                prematureErrors=`expr ${prematureErrors} + 1`
     68                failedprematurepgms="${failedprematurepgms}${perfPgm} "
     69                Display "...program terminated prematurely (unable to check for memory leak errors) ..."
     70            else
     71                grep  "(actual leaks:         1  total size:       4 bytes)" ${testOut} > /dev/null 2>&1
     72                if [ $? -ne 0 ]; then
     73                    memErrors=`expr ${memErrors} + 1`
     74                    failedmempgms="${failedmempgms}${perfPgm} "
     75                    Display ${testOutMem}
     76                fi
     77            fi
     78        fi
     79    done
     80    return ${errors}
     81 }
     82 
     83 
     84 # If there is race condition bug, may this test catch it...
     85 loopTest()
     86 {
     87    totalLoop=10
     88 
     89    Display ""
     90    Display "*******************************************************************************"
     91    Display "START OF TESTS FOR PKIX PERFORMANCE SANITY LOOP (${totalLoop} times)"
     92 Display "*******************************************************************************"
     93    Display ""
     94 
     95    errors=0
     96    iLoop=0
     97    perfPgm="${DIST_BIN}/pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE"
     98 
     99    while [ $iLoop -lt $totalLoop ]
    100    do
    101        iLoop=`expr $iLoop + 1`
    102        numtests=`expr ${numtests} + 1`
    103 
    104        Display "Running ${perfPgm}"
    105        ${perfPgm} > ${testOut} 2>&1
    106        Display `cat ${testOut} | grep "per second"`
    107 
    108        outputCount=`cat ${testOut} | grep "per second"`
    109 
    110        if [ $? -ne 0 ]; then
    111            errors=`expr ${errors} + 1`
    112            failedpgms="${failedpgms} ${perfPgm}\n"
    113            cat ${testOut}
    114        else
    115            passed=`expr ${passed} + 1`
    116        fi
    117    done
    118 
    119    return ${errors}
    120 
    121 }
    122 
    123 #main
    124 perfTest <<EOF
    125 pkixutil libpkix_buildthreads -d . 5 1 ValidCertificatePathTest1EE
    126 pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE
    127 pkixutil nss_threads -d . 5 1 ValidCertificatePathTest1EE
    128 pkixutil nss_threads -d . 5 8 ValidCertificatePathTest1EE
    129 EOF
    130 
    131 totalErrors=$?
    132 html_msg ${totalErrors} 0 "&nbsp;&nbsp;&nbsp;performance test: passed ${passed} of ${numtests} tests"
    133 
    134 numtests=0
    135 passed=0
    136 loopTest
    137 loopErrors=$?
    138 totalErrors=`expr ${totalErrors} + ${loopErrors}`
    139 html_msg ${totalErrors} 0 "&nbsp;&nbsp;&nbsp;loop test: passed ${passed} of ${numtests} tests"
    140 
    141 testEndingEcho
    142 
    143 exit ${totalErrors}