security/nss/tests/libpkix/sample_apps/runPerf.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

     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 #
    10 curdir=`pwd`
    11 cd ../common
    12 . ./libpkix_init.sh > /dev/null
    13 cd ${curdir}
    15 numtests=0
    16 passed=0
    17 testunit=PERFORMANCE
    19 totalErrors=0
    20 loopErrors=0
    22 ParseArgs $*
    24 testHeadingEcho
    26 Display "\nRunning executables at ${DIST_BIN}"
    27 Display "Using libraries at ${LD_LIBRARY_PATH}"
    30 # Check the performance data ...
    31 perfTest()
    32 {
    34     Display ""
    35     Display "*******************************************************************************"
    36     Display "START OF PKIX PERFORMANCE SCENARIOS ${memText}"
    37 Display "*******************************************************************************"
    38     Display ""
    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
    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
    53         outputCount=`cat ${testOut} | grep "per second"`
    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
    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 }
    84 # If there is race condition bug, may this test catch it...
    85 loopTest()
    86 {
    87     totalLoop=10
    89     Display ""
    90     Display "*******************************************************************************"
    91     Display "START OF TESTS FOR PKIX PERFORMANCE SANITY LOOP (${totalLoop} times)"
    92 Display "*******************************************************************************"
    93     Display ""
    95     errors=0
    96     iLoop=0
    97     perfPgm="${DIST_BIN}/pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE"
    99     while [ $iLoop -lt $totalLoop ]
   100     do
   101         iLoop=`expr $iLoop + 1`
   102         numtests=`expr ${numtests} + 1`
   104         Display "Running ${perfPgm}"
   105         ${perfPgm} > ${testOut} 2>&1
   106         Display `cat ${testOut} | grep "per second"`
   108         outputCount=`cat ${testOut} | grep "per second"`
   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
   119     return ${errors}
   121 }
   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
   131 totalErrors=$?
   132 html_msg ${totalErrors} 0 "&nbsp;&nbsp;&nbsp;performance test: passed ${passed} of ${numtests} tests"
   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"
   141 testEndingEcho
   143 exit ${totalErrors}

mercurial