michael@0: #!/bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: # michael@0: # runPerf.sh michael@0: # michael@0: michael@0: curdir=`pwd` michael@0: cd ../common michael@0: . ./libpkix_init.sh > /dev/null michael@0: cd ${curdir} michael@0: michael@0: numtests=0 michael@0: passed=0 michael@0: testunit=PERFORMANCE michael@0: michael@0: totalErrors=0 michael@0: loopErrors=0 michael@0: michael@0: ParseArgs $* michael@0: michael@0: testHeadingEcho michael@0: michael@0: Display "\nRunning executables at ${DIST_BIN}" michael@0: Display "Using libraries at ${LD_LIBRARY_PATH}" michael@0: michael@0: michael@0: # Check the performance data ... michael@0: perfTest() michael@0: { michael@0: michael@0: Display "" michael@0: Display "*******************************************************************************" michael@0: Display "START OF PKIX PERFORMANCE SCENARIOS ${memText}" michael@0: Display "*******************************************************************************" michael@0: Display "" michael@0: michael@0: while read perfPgm args; do michael@0: numtests=`expr ${numtests} + 1` michael@0: Display "Running ${perfPgm} ${args}" michael@0: if [ ${checkmem} -eq 1 ]; then michael@0: dbx -C -c "runargs $args; check -all ;run;exit" ${DIST_BIN}/${perfPgm} > ${testOut} 2>&1 michael@0: else michael@0: ${DIST_BIN}/${perfPgm} ${args} > ${testOut} 2>&1 michael@0: fi michael@0: michael@0: # Examine output file to see if test failed and keep track of number michael@0: # of failures and names of failed tests. This assumes that the test michael@0: # uses our utility library for displaying information michael@0: michael@0: outputCount=`cat ${testOut} | grep "per second"` michael@0: michael@0: if [ $? -ne 0 ]; then michael@0: errors=`expr ${errors} + 1` michael@0: failedpgms="${failedpgms}${perfPgm} ${args}\n" michael@0: cat ${testOut} michael@0: else michael@0: Display ${outputCount} michael@0: passed=`expr ${passed} + 1` michael@0: fi michael@0: michael@0: if [ ${checkmem} -eq 1 ]; then michael@0: grep "(actual leaks:" ${testOut} > ${testOutMem} 2>&1 michael@0: if [ $? -ne 0 ]; then michael@0: prematureErrors=`expr ${prematureErrors} + 1` michael@0: failedprematurepgms="${failedprematurepgms}${perfPgm} " michael@0: Display "...program terminated prematurely (unable to check for memory leak errors) ..." michael@0: else michael@0: grep "(actual leaks: 1 total size: 4 bytes)" ${testOut} > /dev/null 2>&1 michael@0: if [ $? -ne 0 ]; then michael@0: memErrors=`expr ${memErrors} + 1` michael@0: failedmempgms="${failedmempgms}${perfPgm} " michael@0: Display ${testOutMem} michael@0: fi michael@0: fi michael@0: fi michael@0: done michael@0: return ${errors} michael@0: } michael@0: michael@0: michael@0: # If there is race condition bug, may this test catch it... michael@0: loopTest() michael@0: { michael@0: totalLoop=10 michael@0: michael@0: Display "" michael@0: Display "*******************************************************************************" michael@0: Display "START OF TESTS FOR PKIX PERFORMANCE SANITY LOOP (${totalLoop} times)" michael@0: Display "*******************************************************************************" michael@0: Display "" michael@0: michael@0: errors=0 michael@0: iLoop=0 michael@0: perfPgm="${DIST_BIN}/pkixutil libpkix_buildthreads -d . 5 8 ValidCertificatePathTest1EE" michael@0: michael@0: while [ $iLoop -lt $totalLoop ] michael@0: do michael@0: iLoop=`expr $iLoop + 1` michael@0: numtests=`expr ${numtests} + 1` michael@0: michael@0: Display "Running ${perfPgm}" michael@0: ${perfPgm} > ${testOut} 2>&1 michael@0: Display `cat ${testOut} | grep "per second"` michael@0: michael@0: outputCount=`cat ${testOut} | grep "per second"` michael@0: michael@0: if [ $? -ne 0 ]; then michael@0: errors=`expr ${errors} + 1` michael@0: failedpgms="${failedpgms} ${perfPgm}\n" michael@0: cat ${testOut} michael@0: else michael@0: passed=`expr ${passed} + 1` michael@0: fi michael@0: done michael@0: michael@0: return ${errors} michael@0: michael@0: } michael@0: michael@0: #main michael@0: perfTest <