1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/tests/libpkix/sample_apps/runPerf.sh Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,143 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# This Source Code Form is subject to the terms of the Mozilla Public 1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.9 +# 1.10 +# runPerf.sh 1.11 +# 1.12 + 1.13 +curdir=`pwd` 1.14 +cd ../common 1.15 +. ./libpkix_init.sh > /dev/null 1.16 +cd ${curdir} 1.17 + 1.18 +numtests=0 1.19 +passed=0 1.20 +testunit=PERFORMANCE 1.21 + 1.22 +totalErrors=0 1.23 +loopErrors=0 1.24 + 1.25 +ParseArgs $* 1.26 + 1.27 +testHeadingEcho 1.28 + 1.29 +Display "\nRunning executables at ${DIST_BIN}" 1.30 +Display "Using libraries at ${LD_LIBRARY_PATH}" 1.31 + 1.32 + 1.33 +# Check the performance data ... 1.34 +perfTest() 1.35 +{ 1.36 + 1.37 + Display "" 1.38 + Display "*******************************************************************************" 1.39 + Display "START OF PKIX PERFORMANCE SCENARIOS ${memText}" 1.40 +Display "*******************************************************************************" 1.41 + Display "" 1.42 + 1.43 + while read perfPgm args; do 1.44 + numtests=`expr ${numtests} + 1` 1.45 + Display "Running ${perfPgm} ${args}" 1.46 + if [ ${checkmem} -eq 1 ]; then 1.47 + dbx -C -c "runargs $args; check -all ;run;exit" ${DIST_BIN}/${perfPgm} > ${testOut} 2>&1 1.48 + else 1.49 + ${DIST_BIN}/${perfPgm} ${args} > ${testOut} 2>&1 1.50 + fi 1.51 + 1.52 + # Examine output file to see if test failed and keep track of number 1.53 + # of failures and names of failed tests. This assumes that the test 1.54 + # uses our utility library for displaying information 1.55 + 1.56 + outputCount=`cat ${testOut} | grep "per second"` 1.57 + 1.58 + if [ $? -ne 0 ]; then 1.59 + errors=`expr ${errors} + 1` 1.60 + failedpgms="${failedpgms}${perfPgm} ${args}\n" 1.61 + cat ${testOut} 1.62 + else 1.63 + Display ${outputCount} 1.64 + passed=`expr ${passed} + 1` 1.65 + fi 1.66 + 1.67 + if [ ${checkmem} -eq 1 ]; then 1.68 + grep "(actual leaks:" ${testOut} > ${testOutMem} 2>&1 1.69 + if [ $? -ne 0 ]; then 1.70 + prematureErrors=`expr ${prematureErrors} + 1` 1.71 + failedprematurepgms="${failedprematurepgms}${perfPgm} " 1.72 + Display "...program terminated prematurely (unable to check for memory leak errors) ..." 1.73 + else 1.74 + grep "(actual leaks: 1 total size: 4 bytes)" ${testOut} > /dev/null 2>&1 1.75 + if [ $? -ne 0 ]; then 1.76 + memErrors=`expr ${memErrors} + 1` 1.77 + failedmempgms="${failedmempgms}${perfPgm} " 1.78 + Display ${testOutMem} 1.79 + fi 1.80 + fi 1.81 + fi 1.82 + done 1.83 + return ${errors} 1.84 +} 1.85 + 1.86 + 1.87 +# If there is race condition bug, may this test catch it... 1.88 +loopTest() 1.89 +{ 1.90 + totalLoop=10 1.91 + 1.92 + Display "" 1.93 + Display "*******************************************************************************" 1.94 + Display "START OF TESTS FOR PKIX PERFORMANCE SANITY LOOP (${totalLoop} times)" 1.95 +Display "*******************************************************************************" 1.96 + Display "" 1.97 + 1.98 + errors=0 1.99 + iLoop=0 1.100 + perfPgm="${DIST_BIN}/pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE" 1.101 + 1.102 + while [ $iLoop -lt $totalLoop ] 1.103 + do 1.104 + iLoop=`expr $iLoop + 1` 1.105 + numtests=`expr ${numtests} + 1` 1.106 + 1.107 + Display "Running ${perfPgm}" 1.108 + ${perfPgm} > ${testOut} 2>&1 1.109 + Display `cat ${testOut} | grep "per second"` 1.110 + 1.111 + outputCount=`cat ${testOut} | grep "per second"` 1.112 + 1.113 + if [ $? -ne 0 ]; then 1.114 + errors=`expr ${errors} + 1` 1.115 + failedpgms="${failedpgms} ${perfPgm}\n" 1.116 + cat ${testOut} 1.117 + else 1.118 + passed=`expr ${passed} + 1` 1.119 + fi 1.120 + done 1.121 + 1.122 + return ${errors} 1.123 + 1.124 +} 1.125 + 1.126 +#main 1.127 +perfTest <<EOF 1.128 +pkixutil libpkix_buildthreads -d . 5 1 ValidCertificatePathTest1EE 1.129 +pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE 1.130 +pkixutil nss_threads -d . 5 1 ValidCertificatePathTest1EE 1.131 +pkixutil nss_threads -d . 5 8 ValidCertificatePathTest1EE 1.132 +EOF 1.133 + 1.134 +totalErrors=$? 1.135 +html_msg ${totalErrors} 0 " performance test: passed ${passed} of ${numtests} tests" 1.136 + 1.137 +numtests=0 1.138 +passed=0 1.139 +loopTest 1.140 +loopErrors=$? 1.141 +totalErrors=`expr ${totalErrors} + ${loopErrors}` 1.142 +html_msg ${totalErrors} 0 " loop test: passed ${passed} of ${numtests} tests" 1.143 + 1.144 +testEndingEcho 1.145 + 1.146 +exit ${totalErrors}