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/bash |
michael@0 | 2 | |
michael@0 | 3 | # Ensure a failure of the first command inside a pipe |
michael@0 | 4 | # won't be hidden by commands later in the pipe. |
michael@0 | 5 | # (e.g. as in ./dosomething | grep) |
michael@0 | 6 | |
michael@0 | 7 | set -o pipefail |
michael@0 | 8 | |
michael@0 | 9 | proc_args() |
michael@0 | 10 | { |
michael@0 | 11 | while [ -n "$1" ]; do |
michael@0 | 12 | OPT=$(echo $1 | cut -d= -f1) |
michael@0 | 13 | VAL=$(echo $1 | cut -d= -f2) |
michael@0 | 14 | |
michael@0 | 15 | case $OPT in |
michael@0 | 16 | "--build-nss") |
michael@0 | 17 | BUILD_NSS=1 |
michael@0 | 18 | ;; |
michael@0 | 19 | "--test-nss") |
michael@0 | 20 | TEST_NSS=1 |
michael@0 | 21 | ;; |
michael@0 | 22 | "--build-jss") |
michael@0 | 23 | BUILD_JSS=1 |
michael@0 | 24 | ;; |
michael@0 | 25 | "--test-jss") |
michael@0 | 26 | TEST_JSS=1 |
michael@0 | 27 | ;; |
michael@0 | 28 | "--memtest") |
michael@0 | 29 | NSS_TESTS="memleak" |
michael@0 | 30 | export NSS_TESTS |
michael@0 | 31 | ;; |
michael@0 | 32 | "--nojsssign") |
michael@0 | 33 | NO_JSS_SIGN=1 |
michael@0 | 34 | ;; |
michael@0 | 35 | *) |
michael@0 | 36 | echo "Usage: $0 ..." |
michael@0 | 37 | echo " --memtest - run the memory leak tests" |
michael@0 | 38 | echo " --nojsssign - try to sign jss" |
michael@0 | 39 | echo " --build-nss" |
michael@0 | 40 | echo " --build-jss" |
michael@0 | 41 | echo " --test-nss" |
michael@0 | 42 | echo " --test-jss" |
michael@0 | 43 | exit 1 |
michael@0 | 44 | ;; |
michael@0 | 45 | esac |
michael@0 | 46 | |
michael@0 | 47 | shift |
michael@0 | 48 | done |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | set_env() |
michael@0 | 52 | { |
michael@0 | 53 | TOPDIR=$(pwd) |
michael@0 | 54 | HGDIR=$(pwd)$(echo "/hg") |
michael@0 | 55 | OUTPUTDIR=$(pwd)$(echo "/output") |
michael@0 | 56 | LOG_ALL="${OUTPUTDIR}/all.log" |
michael@0 | 57 | LOG_TMP="${OUTPUTDIR}/tmp.log" |
michael@0 | 58 | |
michael@0 | 59 | echo "hello" |grep --line-buffered hello >/dev/null 2>&1 |
michael@0 | 60 | [ $? -eq 0 ] && GREP_BUFFER="--line-buffered" |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | print_log() |
michael@0 | 64 | { |
michael@0 | 65 | DATE=$(date "+TB [%Y-%m-%d %H:%M:%S]") |
michael@0 | 66 | echo "${DATE} $*" |
michael@0 | 67 | echo "${DATE} $*" >> ${LOG_ALL} |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | print_result() |
michael@0 | 71 | { |
michael@0 | 72 | TESTNAME=$1 |
michael@0 | 73 | RET=$2 |
michael@0 | 74 | EXP=$3 |
michael@0 | 75 | |
michael@0 | 76 | if [ ${RET} -eq ${EXP} ]; then |
michael@0 | 77 | print_log "${TESTNAME} PASSED" |
michael@0 | 78 | else |
michael@0 | 79 | print_log "${TESTNAME} FAILED" |
michael@0 | 80 | fi |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | print_env() |
michael@0 | 84 | { |
michael@0 | 85 | print_log "######## Environment variables ########" |
michael@0 | 86 | |
michael@0 | 87 | uname -a | tee -a ${LOG_ALL} |
michael@0 | 88 | if [ -e "/etc/redhat-release" ]; then |
michael@0 | 89 | cat "/etc/redhat-release" | tee -a ${LOG_ALL} |
michael@0 | 90 | fi |
michael@0 | 91 | # don't print the MAIL command, it might contain a password |
michael@0 | 92 | env | grep -v "^MAIL=" | tee -a ${LOG_ALL} |
michael@0 | 93 | } |
michael@0 | 94 | |
michael@0 | 95 | set_cycle() |
michael@0 | 96 | { |
michael@0 | 97 | BITS=$1 |
michael@0 | 98 | OPT=$2 |
michael@0 | 99 | |
michael@0 | 100 | if [ "${BITS}" = "64" ]; then |
michael@0 | 101 | USE_64=1 |
michael@0 | 102 | JAVA_HOME=${JAVA_HOME_64} |
michael@0 | 103 | PORT_DBG=${PORT_64_DBG} |
michael@0 | 104 | PORT_OPT=${PORT_64_OPT} |
michael@0 | 105 | else |
michael@0 | 106 | USE_64= |
michael@0 | 107 | JAVA_HOME=${JAVA_HOME_32} |
michael@0 | 108 | PORT_DBG=${PORT_32_DBG} |
michael@0 | 109 | PORT_OPT=${PORT_32_OPT} |
michael@0 | 110 | fi |
michael@0 | 111 | export USE_64 |
michael@0 | 112 | export JAVA_HOME |
michael@0 | 113 | |
michael@0 | 114 | BUILD_OPT= |
michael@0 | 115 | if [ "${OPT}" = "OPT" ]; then |
michael@0 | 116 | BUILD_OPT=1 |
michael@0 | 117 | XPCLASS=xpclass.jar |
michael@0 | 118 | PORT=${PORT_OPT} |
michael@0 | 119 | else |
michael@0 | 120 | BUILD_OPT= |
michael@0 | 121 | XPCLASS=xpclass_dbg.jar |
michael@0 | 122 | PORT=${PORT_DBG} |
michael@0 | 123 | fi |
michael@0 | 124 | export BUILD_OPT |
michael@0 | 125 | |
michael@0 | 126 | PORT_JSS_SERVER=$(expr ${PORT} + 20) |
michael@0 | 127 | PORT_JSSE_SERVER=$(expr ${PORT} + 40) |
michael@0 | 128 | |
michael@0 | 129 | export PORT |
michael@0 | 130 | export PORT_JSS_SERVER |
michael@0 | 131 | export PORT_JSSE_SERVER |
michael@0 | 132 | } |
michael@0 | 133 | |
michael@0 | 134 | build_nss() |
michael@0 | 135 | { |
michael@0 | 136 | print_log "######## NSS - build - ${BITS} bits - ${OPT} ########" |
michael@0 | 137 | |
michael@0 | 138 | print_log "$ cd ${HGDIR}/nss" |
michael@0 | 139 | cd ${HGDIR}/nss |
michael@0 | 140 | |
michael@0 | 141 | print_log "$ ${MAKE} ${NSS_BUILD_TARGET}" |
michael@0 | 142 | #${MAKE} ${NSS_BUILD_TARGET} 2>&1 | tee -a ${LOG_ALL} | grep ${GREP_BUFFER} "^${MAKE}" |
michael@0 | 143 | ${MAKE} ${NSS_BUILD_TARGET} 2>&1 | tee -a ${LOG_ALL} |
michael@0 | 144 | RET=$? |
michael@0 | 145 | print_result "NSS - build - ${BITS} bits - ${OPT}" ${RET} 0 |
michael@0 | 146 | |
michael@0 | 147 | if [ ${RET} -eq 0 ]; then |
michael@0 | 148 | return 0 |
michael@0 | 149 | else |
michael@0 | 150 | tail -100 ${LOG_ALL} |
michael@0 | 151 | return ${RET} |
michael@0 | 152 | fi |
michael@0 | 153 | } |
michael@0 | 154 | |
michael@0 | 155 | build_jss() |
michael@0 | 156 | { |
michael@0 | 157 | print_log "######## JSS - build - ${BITS} bits - ${OPT} ########" |
michael@0 | 158 | |
michael@0 | 159 | print_log "$ cd ${HGDIR}/jss" |
michael@0 | 160 | cd ${HGDIR}/jss |
michael@0 | 161 | |
michael@0 | 162 | print_log "$ ${MAKE} ${JSS_BUILD_TARGET}" |
michael@0 | 163 | #${MAKE} ${JSS_BUILD_TARGET} 2>&1 | tee -a ${LOG_ALL} | grep ${GREP_BUFFER} "^${MAKE}" |
michael@0 | 164 | ${MAKE} ${JSS_BUILD_TARGET} 2>&1 | tee -a ${LOG_ALL} |
michael@0 | 165 | RET=$? |
michael@0 | 166 | print_result "JSS build - ${BITS} bits - ${OPT}" ${RET} 0 |
michael@0 | 167 | [ ${RET} -eq 0 ] || return ${RET} |
michael@0 | 168 | |
michael@0 | 169 | print_log "$ cd ${HGDIR}/dist" |
michael@0 | 170 | cd ${HGDIR}/dist |
michael@0 | 171 | |
michael@0 | 172 | if [ -z "${NO_JSS_SIGN}" ]; then |
michael@0 | 173 | print_log "cat ${TOPDIR}/keystore.pw | ${JAVA_HOME}/bin/jarsigner -keystore ${TOPDIR}/keystore -internalsf ${XPCLASS} jssdsa" |
michael@0 | 174 | cat ${TOPDIR}/keystore.pw | ${JAVA_HOME}/bin/jarsigner -keystore ${TOPDIR}/keystore -internalsf ${XPCLASS} jssdsa >> ${LOG_ALL} 2>&1 |
michael@0 | 175 | RET=$? |
michael@0 | 176 | print_result "JSS - sign JAR files - ${BITS} bits - ${OPT}" ${RET} 0 |
michael@0 | 177 | [ ${RET} -eq 0 ] || return ${RET} |
michael@0 | 178 | fi |
michael@0 | 179 | print_log "${JAVA_HOME}/bin/jarsigner -verify -certs ${XPCLASS}" |
michael@0 | 180 | ${JAVA_HOME}/bin/jarsigner -verify -certs ${XPCLASS} >> ${LOG_ALL} 2>&1 |
michael@0 | 181 | RET=$? |
michael@0 | 182 | print_result "JSS - verify JAR files - ${BITS} bits - ${OPT}" ${RET} 0 |
michael@0 | 183 | [ ${RET} -eq 0 ] || return ${RET} |
michael@0 | 184 | |
michael@0 | 185 | return 0 |
michael@0 | 186 | } |
michael@0 | 187 | |
michael@0 | 188 | test_nss() |
michael@0 | 189 | { |
michael@0 | 190 | print_log "######## NSS - tests - ${BITS} bits - ${OPT} ########" |
michael@0 | 191 | |
michael@0 | 192 | if [ "${OS_TARGET}" = "Android" ]; then |
michael@0 | 193 | print_log "$ cd ${HGDIR}/nss/tests/remote" |
michael@0 | 194 | cd ${HGDIR}/nss/tests/remote |
michael@0 | 195 | print_log "$ make test_android" |
michael@0 | 196 | make test_android 2>&1 | tee ${LOG_TMP} | grep ${GREP_BUFFER} ": #" |
michael@0 | 197 | OUTPUTFILE=${HGDIR}/tests_results/security/*.1/output.log |
michael@0 | 198 | else |
michael@0 | 199 | print_log "$ cd ${HGDIR}/nss/tests" |
michael@0 | 200 | cd ${HGDIR}/nss/tests |
michael@0 | 201 | print_log "$ ./all.sh" |
michael@0 | 202 | ./all.sh 2>&1 | tee ${LOG_TMP} | grep ${GREP_BUFFER} ": #" |
michael@0 | 203 | OUTPUTFILE=${LOG_TMP} |
michael@0 | 204 | fi |
michael@0 | 205 | |
michael@0 | 206 | cat ${LOG_TMP} >> ${LOG_ALL} |
michael@0 | 207 | tail -n2 ${HGDIR}/tests_results/security/*.1/results.html | grep END_OF_TEST >> ${LOG_ALL} |
michael@0 | 208 | RET=$? |
michael@0 | 209 | |
michael@0 | 210 | print_log "######## details of detected failures (if any) ########" |
michael@0 | 211 | grep -B50 FAIL ${OUTPUTFILE} |
michael@0 | 212 | [ $? -eq 1 ] || RET=1 |
michael@0 | 213 | |
michael@0 | 214 | print_result "NSS - tests - ${BITS} bits - ${OPT}" ${RET} 0 |
michael@0 | 215 | return ${RET} |
michael@0 | 216 | } |
michael@0 | 217 | |
michael@0 | 218 | test_jss() |
michael@0 | 219 | { |
michael@0 | 220 | print_log "######## JSS - tests - ${BITS} bits - ${OPT} ########" |
michael@0 | 221 | |
michael@0 | 222 | print_log "$ cd ${HGDIR}/jss" |
michael@0 | 223 | cd ${HGDIR}/jss |
michael@0 | 224 | |
michael@0 | 225 | print_log "$ ${MAKE} platform" |
michael@0 | 226 | PLATFORM=$(${MAKE} platform) |
michael@0 | 227 | print_log "PLATFORM=${PLATFORM}" |
michael@0 | 228 | |
michael@0 | 229 | print_log "$ cd ${HGDIR}/jss/org/mozilla/jss/tests" |
michael@0 | 230 | cd ${HGDIR}/jss/org/mozilla/jss/tests |
michael@0 | 231 | |
michael@0 | 232 | print_log "$ perl all.pl dist ${HGDIR}/dist/${PLATFORM}" |
michael@0 | 233 | perl all.pl dist ${HGDIR}/dist/${PLATFORM} 2>&1 | tee ${LOG_TMP} |
michael@0 | 234 | cat ${LOG_TMP} >> ${LOG_ALL} |
michael@0 | 235 | |
michael@0 | 236 | tail -n2 ${LOG_TMP} | grep JSSTEST_RATE > /dev/null |
michael@0 | 237 | RET=$? |
michael@0 | 238 | |
michael@0 | 239 | grep FAIL ${LOG_TMP} |
michael@0 | 240 | [ $? -eq 1 ] || RET=1 |
michael@0 | 241 | |
michael@0 | 242 | print_result "JSS - tests - ${BITS} bits - ${OPT}" ${RET} 0 |
michael@0 | 243 | return ${RET} |
michael@0 | 244 | } |
michael@0 | 245 | |
michael@0 | 246 | build_and_test() |
michael@0 | 247 | { |
michael@0 | 248 | if [ -n "${BUILD_NSS}" ]; then |
michael@0 | 249 | build_nss |
michael@0 | 250 | [ $? -eq 0 ] || return 1 |
michael@0 | 251 | fi |
michael@0 | 252 | |
michael@0 | 253 | if [ -n "${TEST_NSS}" ]; then |
michael@0 | 254 | test_nss |
michael@0 | 255 | [ $? -eq 0 ] || return 1 |
michael@0 | 256 | fi |
michael@0 | 257 | |
michael@0 | 258 | if [ -n "${BUILD_JSS}" ]; then |
michael@0 | 259 | build_jss |
michael@0 | 260 | [ $? -eq 0 ] || return 1 |
michael@0 | 261 | fi |
michael@0 | 262 | |
michael@0 | 263 | if [ -n "${TEST_JSS}" ]; then |
michael@0 | 264 | test_jss |
michael@0 | 265 | [ $? -eq 0 ] || return 1 |
michael@0 | 266 | fi |
michael@0 | 267 | |
michael@0 | 268 | return 0 |
michael@0 | 269 | } |
michael@0 | 270 | |
michael@0 | 271 | run_cycle() |
michael@0 | 272 | { |
michael@0 | 273 | print_env |
michael@0 | 274 | build_and_test |
michael@0 | 275 | RET=$? |
michael@0 | 276 | |
michael@0 | 277 | grep ^TinderboxPrint ${LOG_ALL} |
michael@0 | 278 | |
michael@0 | 279 | return ${RET} |
michael@0 | 280 | } |
michael@0 | 281 | |
michael@0 | 282 | prepare() |
michael@0 | 283 | { |
michael@0 | 284 | rm -rf ${OUTPUTDIR}.oldest >/dev/null 2>&1 |
michael@0 | 285 | mv ${OUTPUTDIR}.older ${OUTPUTDIR}.oldest >/dev/null 2>&1 |
michael@0 | 286 | mv ${OUTPUTDIR}.old ${OUTPUTDIR}.older >/dev/null 2>&1 |
michael@0 | 287 | mv ${OUTPUTDIR}.last ${OUTPUTDIR}.old >/dev/null 2>&1 |
michael@0 | 288 | mv ${OUTPUTDIR} ${OUTPUTDIR}.last >/dev/null 2>&1 |
michael@0 | 289 | mkdir -p ${OUTPUTDIR} |
michael@0 | 290 | |
michael@0 | 291 | if [ -z "${NSS_DISABLE_ECC}" -a -n "${NSS_ECC_MORE_THAN_SUITE_B}" ]; then |
michael@0 | 292 | cd ${HGDIR}/nss |
michael@0 | 293 | ECF="lib/freebl/ecl/ecl-curve.h" |
michael@0 | 294 | print_log "hg revert -r NSS_3_11_1_RTM ${ECF}" |
michael@0 | 295 | hg revert -r NSS_3_11_1_RTM security/nss/${ECF} |
michael@0 | 296 | cp -f security/nss/${ECF} ${ECF} |
michael@0 | 297 | fi |
michael@0 | 298 | |
michael@0 | 299 | return 0 |
michael@0 | 300 | } |
michael@0 | 301 | |
michael@0 | 302 | move_results() |
michael@0 | 303 | { |
michael@0 | 304 | cd ${HGDIR} |
michael@0 | 305 | if [ -n "${TEST_NSS}" ]; then |
michael@0 | 306 | mv -f tests_results ${OUTPUTDIR} |
michael@0 | 307 | fi |
michael@0 | 308 | tar -c -z --dereference -f ${OUTPUTDIR}/dist.tgz dist |
michael@0 | 309 | rm -rf dist |
michael@0 | 310 | } |
michael@0 | 311 | |
michael@0 | 312 | run_all() |
michael@0 | 313 | { |
michael@0 | 314 | set_cycle ${BITS} ${OPT} |
michael@0 | 315 | prepare |
michael@0 | 316 | run_cycle |
michael@0 | 317 | RESULT=$? |
michael@0 | 318 | print_log "### result of run_cycle is ${RESULT}" |
michael@0 | 319 | move_results |
michael@0 | 320 | return ${RESULT} |
michael@0 | 321 | } |
michael@0 | 322 | |
michael@0 | 323 | main() |
michael@0 | 324 | { |
michael@0 | 325 | VALID=0 |
michael@0 | 326 | RET=1 |
michael@0 | 327 | |
michael@0 | 328 | for BITS in 32 64; do |
michael@0 | 329 | echo ${RUN_BITS} | grep ${BITS} > /dev/null |
michael@0 | 330 | [ $? -eq 0 ] || continue |
michael@0 | 331 | for OPT in DBG OPT; do |
michael@0 | 332 | echo ${RUN_OPT} | grep ${OPT} > /dev/null |
michael@0 | 333 | [ $? -eq 0 ] || continue |
michael@0 | 334 | |
michael@0 | 335 | VALID=1 |
michael@0 | 336 | set_env |
michael@0 | 337 | run_all |
michael@0 | 338 | RET=$? |
michael@0 | 339 | print_log "### result of run_all is ${RET}" |
michael@0 | 340 | done |
michael@0 | 341 | done |
michael@0 | 342 | |
michael@0 | 343 | if [ ${VALID} -ne 1 ]; then |
michael@0 | 344 | echo "Need to set valid bits/opt values." |
michael@0 | 345 | return 1 |
michael@0 | 346 | fi |
michael@0 | 347 | |
michael@0 | 348 | return ${RET} |
michael@0 | 349 | } |
michael@0 | 350 | |
michael@0 | 351 | #function killallsub() |
michael@0 | 352 | #{ |
michael@0 | 353 | # FINAL_RET=$? |
michael@0 | 354 | # for proc in `jobs -p` |
michael@0 | 355 | # do |
michael@0 | 356 | # kill -9 $proc |
michael@0 | 357 | # done |
michael@0 | 358 | # return ${FINAL_RET} |
michael@0 | 359 | #} |
michael@0 | 360 | #trap killallsub EXIT |
michael@0 | 361 | |
michael@0 | 362 | #IS_RUNNING_FILE="./build-is-running" |
michael@0 | 363 | |
michael@0 | 364 | #if [ -a $IS_RUNNING_FILE ]; then |
michael@0 | 365 | # echo "exiting, because old job is still running" |
michael@0 | 366 | # exit 1 |
michael@0 | 367 | #fi |
michael@0 | 368 | |
michael@0 | 369 | #touch $IS_RUNNING_FILE |
michael@0 | 370 | |
michael@0 | 371 | echo "tinderbox args: $0 $@" |
michael@0 | 372 | . ${ENVVARS} |
michael@0 | 373 | proc_args "$@" |
michael@0 | 374 | main |
michael@0 | 375 | |
michael@0 | 376 | #RET=$? |
michael@0 | 377 | #rm $IS_RUNNING_FILE |
michael@0 | 378 | #exit ${RET} |