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