2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
10 ######################################################################
12 ######################################################################
14 readonly CLOBBER=${CLOBBER:-yes}
15 readonly SCONS_TRUSTED="./scons --mode=opt-host -j8"
16 readonly SCONS_NACL="./scons --mode=opt-host,nacl -j8"
17 readonly SPEC_HARNESS=${SPEC_HARNESS:-${HOME}/cpu2000-redhat64-ia32}/
19 readonly TRYBOT_TESTS="176.gcc 179.art 181.mcf 197.parser 252.eon 254.gap"
20 readonly TRYBOT_X86_64_ZERO_BASED_SANDBOX_TESTS="176.gcc"
22 readonly BUILDBOT_PNACL="buildbot/buildbot_pnacl.sh"
23 readonly UP_DOWN_LOAD="buildbot/file_up_down_load.sh"
25 readonly SPEC_BASE="tests/spec2k"
26 readonly ARCHIVE_NAME=$(${SPEC_BASE}/run_all.sh GetTestArchiveName)
28 readonly NAME_ARM_TRY_UPLOAD=$(${BUILDBOT_PNACL} NAME_ARM_TRY_UPLOAD)
29 readonly NAME_ARM_TRY_DOWNLOAD=$(${BUILDBOT_PNACL} NAME_ARM_TRY_DOWNLOAD)
30 readonly NAME_ARM_UPLOAD=$(${BUILDBOT_PNACL} NAME_ARM_UPLOAD)
31 readonly NAME_ARM_DOWNLOAD=$(${BUILDBOT_PNACL} NAME_ARM_DOWNLOAD)
33 readonly QEMU_TOOL="$(pwd)/toolchain/linux_x86/arm_trusted/run_under_qemu_arm"
35 # Note: the tool for updating the canned nexes lives at:
36 # tools/canned_nexe_tool.sh
37 readonly CANNED_NEXE_REV=1001
39 # If true, terminate script when first error is encountered.
40 readonly FAIL_FAST=${FAIL_FAST:-false}
43 # Print the number of tests being run for the buildbot status output
46 if [[ ${tests} == "all" ]]; then
53 # called when a commands invocation fails
56 echo "@@@STEP_FAILURE@@@"
57 if ${FAIL_FAST} ; then
58 echo "FAIL_FAST enabled"
63 ######################################################################
65 ######################################################################
68 if [ "${CLOBBER}" == "yes" ] ; then
73 # Make up for the toolchain tarballs not quite being a full SDK
74 # Also clean the SPEC dir (that step is here because it should
75 # not be run on hw bots which download rather than build binaries)
76 build-prerequisites() {
77 echo "@@@BUILD_STEP build prerequisites [$*] @@@"
79 ./run_all.sh BuildPrerequisites "$@"
80 ./run_all.sh CleanBenchmarks
81 ./run_all.sh PopulateFromSpecHarness "${SPEC_HARNESS}"
88 local timed="$3" # Do timing and size measurements
89 local compile_repetitions="$4"
90 local count=$(testcount "${tests}")
93 for setup in ${setups}; do
94 echo "@@@BUILD_STEP spec2k build [${setup}] [${count} tests]@@@"
96 SPEC_COMPILE_REPETITIONS=${compile_repetitions} \
97 ./run_all.sh BuildBenchmarks ${timed} ${setup} train ${tests} || \
107 local run_repetitions="$4"
108 local count=$(testcount "${tests}")
111 for setup in ${setups}; do
112 echo "@@@BUILD_STEP spec2k run [${setup}] [${count} tests]@@@"
113 if [ ${timed} == "1" ]; then
114 SPEC_RUN_REPETITIONS=${run_repetitions} \
115 ./run_all.sh RunTimedBenchmarks ${setup} train ${tests} || \
118 ./run_all.sh RunBenchmarks ${setup} train ${tests} || \
125 upload-test-binaries() {
127 local try="$2" # set to "try" if this is a try run
130 echo "@@@BUILD_STEP spec2k archive@@@"
131 ./run_all.sh PackageArmBinaries ${tests}
133 echo "@@@BUILD_STEP spec2k upload@@@"
134 if [[ ${try} == "try" ]]; then
135 ${UP_DOWN_LOAD} UploadArmBinariesForHWBotsTry ${NAME_ARM_TRY_UPLOAD} \
138 ${UP_DOWN_LOAD} UploadArmBinariesForHWBots ${NAME_ARM_UPLOAD} \
143 download-test-binaries() {
145 echo "@@@BUILD_STEP spec2k download@@@"
146 if [[ ${try} == "try" ]]; then
147 ${UP_DOWN_LOAD} DownloadArmBinariesForHWBotsTry ${NAME_ARM_TRY_DOWNLOAD} \
150 ${UP_DOWN_LOAD} DownloadArmBinariesForHWBots ${NAME_ARM_DOWNLOAD} \
153 echo "@@@BUILD_STEP spec2k untar@@@"
155 ./run_all.sh UnpackArmBinaries
159 download-validator-test-nexes() {
161 echo "@@@BUILD_STEP validator test download@@@"
162 ${UP_DOWN_LOAD} DownloadArchivedNexes ${CANNED_NEXE_REV} \
163 "${arch}_giant" giant_nexe.tar.bz2
164 # This generates "CannedNexes/" in the current directory
166 tar jxf giant_nexe.tar.bz2
171 if [[ ${arch} == "x86-32" ]] ; then
172 echo "$(pwd)/scons-out/opt-linux-x86-32/staging/ncval_new"
173 elif [[ ${arch} == "x86-64" ]] ; then
174 echo "$(pwd)/scons-out/opt-linux-x86-64/staging/ncval_new"
175 elif [[ ${arch} == "arm" ]] ; then
176 echo "$(pwd)/scons-out/opt-linux-arm/staging/arm-ncval-core"
178 echo "ERROR: unknown arch"
184 # This format is recognized by the buildbot system
185 echo "RESULT $1_$2: $3= $(bc) seconds"
193 # S: system mode CPU-seconds used by the process
194 # U: user mode CPU-seconds used by the process
195 # We add a plus sign inbetween so that we can pipe the output to "bc"
196 # Note: the >() magic creates a "fake" file (think named pipe)
197 # which passes the output of time to LogTimeHelper
198 /usr/bin/time -f "%U + %S" \
199 --output >(LogTimeHelper ${graph} ${benchmark} ${variant}) \
205 echo "@@@BUILD_STEP build validator [${arch}]@@@"
206 if [[ ${arch} == "arm" ]] ; then
207 # TODO(robertm): build the validator
209 elif [[ ${arch} == "x86-32" ]] ; then
210 ${SCONS_NACL} platform=${arch} ncval_new
211 elif [[ ${arch} == "x86-64" ]] ; then
212 ${SCONS_NACL} platform=${arch} ncval_new
214 echo "ERROR: unknown arch"
219 measure-validator-speed() {
221 local validator=$(get-validator ${arch})
223 echo "@@@BUILD_STEP validator speed test [${arch}]@@@"
224 if [[ ! -e ${validator} ]] ; then
225 echo "ERROR: missing validator executable: ${validator}"
230 if [[ ${arch} == "arm" && $(uname -p) != arm* ]] ; then
231 # TODO(robertm): build the validator
232 validator="${QEMU_TOOL} ${validator}"
235 for nexe in CannedNexes/* ; do
236 echo "timing validation of ${nexe}"
237 ls --size --block-size=1 ${nexe}
238 LogTimedRun "validationtime" $(basename ${nexe}) "canned" \
243 ######################################################################
244 # NOTE: trybots only runs a subset of the the spec2k tests
246 pnacl-trybot-arm-buildonly() {
248 build-prerequisites "arm" "bitcode" "arm-ncval-core"
249 ${BUILDBOT_PNACL} archive-for-hw-bots "${NAME_ARM_TRY_UPLOAD}" try
250 build-tests SetupPnaclPexeOpt "${TRYBOT_TESTS}" 0 1
251 upload-test-binaries "${TRYBOT_TESTS}" try
254 pnacl-trybot-arm-hw() {
256 ${BUILDBOT_PNACL} unarchive-for-hw-bots "${NAME_ARM_TRY_DOWNLOAD}" try
257 download-test-binaries try
258 build-tests SetupPnaclTranslatorArmOptHW "${TRYBOT_TESTS}" 1 1
259 run-tests SetupPnaclTranslatorArmOptHW "${TRYBOT_TESTS}" 1 1
260 build-tests SetupPnaclTranslator1ThreadArmOptHW "${TRYBOT_TESTS}" 1 1
261 run-tests SetupPnaclTranslator1ThreadArmOptHW "${TRYBOT_TESTS}" 1 1
263 ./run_all.sh TimeValidation SetupPnaclTranslatorArmOptHW "${TRYBOT_TESTS}" ||\
266 build-tests SetupPnaclTranslatorFastArmOptHW "${TRYBOT_TESTS}" 1 1
267 run-tests SetupPnaclTranslatorFastArmOptHW "${TRYBOT_TESTS}" 1 1
268 build-tests SetupPnaclTranslatorFast1ThreadArmOptHW "${TRYBOT_TESTS}" 1 1
269 run-tests SetupPnaclTranslatorFast1ThreadArmOptHW "${TRYBOT_TESTS}" 1 1
272 pnacl-trybot-x8632() {
274 build-prerequisites "x86-32" "bitcode"
275 build-tests SetupPnaclX8632Opt "${TRYBOT_TESTS}" 1 1
276 run-tests SetupPnaclX8632Opt "${TRYBOT_TESTS}" 1 1
277 build-tests SetupPnaclTranslatorX8632Opt "${TRYBOT_TESTS}" 1 1
278 run-tests SetupPnaclTranslatorX8632Opt "${TRYBOT_TESTS}" 1 1
279 build-tests SetupPnaclTranslator1ThreadX8632Opt "${TRYBOT_TESTS}" 1 1
280 run-tests SetupPnaclTranslator1ThreadX8632Opt "${TRYBOT_TESTS}" 1 1
281 build-tests SetupPnaclTranslatorFastX8632Opt "${TRYBOT_TESTS}" 1 1
282 run-tests SetupPnaclTranslatorFastX8632Opt "${TRYBOT_TESTS}" 1 1
283 build-tests SetupPnaclTranslatorFast1ThreadX8632Opt "${TRYBOT_TESTS}" 1 1
284 run-tests SetupPnaclTranslatorFast1ThreadX8632Opt "${TRYBOT_TESTS}" 1 1
285 build-validator x86-32
286 download-validator-test-nexes x86-32
287 measure-validator-speed x86-32
290 pnacl-x86-64-zero-based-sandbox() {
292 export NACL_ENABLE_INSECURE_ZERO_BASED_SANDBOX=1
293 build-prerequisites "x86-64" "bitcode" "x86_64_zero_based_sandbox=1"
294 build-tests SetupPnaclX8664ZBSOpt \
295 "${TRYBOT_X86_64_ZERO_BASED_SANDBOX_TESTS}" 1 1
296 run-tests SetupPnaclX8664ZBSOpt \
297 "${TRYBOT_X86_64_ZERO_BASED_SANDBOX_TESTS}" 1 1
300 pnacl-trybot-x8664() {
302 build-prerequisites "x86-64" "bitcode"
303 build-tests SetupPnaclX8664Opt "${TRYBOT_TESTS}" 1 1
304 run-tests SetupPnaclX8664Opt "${TRYBOT_TESTS}" 1 1
305 build-tests SetupPnaclTranslatorX8664Opt "${TRYBOT_TESTS}" 1 1
306 run-tests SetupPnaclTranslatorX8664Opt "${TRYBOT_TESTS}" 1 1
307 build-tests SetupPnaclTranslator1ThreadX8664Opt "${TRYBOT_TESTS}" 1 1
308 run-tests SetupPnaclTranslator1ThreadX8664Opt "${TRYBOT_TESTS}" 1 1
309 build-tests SetupPnaclTranslatorFastX8664Opt "${TRYBOT_TESTS}" 1 1
310 run-tests SetupPnaclTranslatorFastX8664Opt "${TRYBOT_TESTS}" 1 1
311 build-tests SetupPnaclTranslatorFast1ThreadX8664Opt "${TRYBOT_TESTS}" 1 1
312 run-tests SetupPnaclTranslatorFast1ThreadX8664Opt "${TRYBOT_TESTS}" 1 1
313 pnacl-x86-64-zero-based-sandbox
314 build-validator x86-64
315 download-validator-test-nexes x86-64
316 measure-validator-speed x86-64
319 pnacl-arm-buildonly() {
321 build-prerequisites "arm" "bitcode"
322 ${BUILDBOT_PNACL} archive-for-hw-bots "${NAME_ARM_UPLOAD}" regular
323 build-tests SetupPnaclPexeOpt all 0 1
324 upload-test-binaries all regular
329 ${BUILDBOT_PNACL} unarchive-for-hw-bots "${NAME_ARM_DOWNLOAD}" regular
330 download-test-binaries regular
331 build-tests SetupPnaclTranslatorArmOptHW all 1 1
332 run-tests SetupPnaclTranslatorArmOptHW all 1 2
333 # Only run 1 thread ARM tests 1x to save some time for now.
334 # Hopefully perf infrastructure will smooth out flakes.
335 # Otherwise, we'll bump the runs up to 2x as well.
336 build-tests SetupPnaclTranslator1ThreadArmOptHW all 1 1
337 run-tests SetupPnaclTranslator1ThreadArmOptHW all 1 1
338 build-tests SetupPnaclTranslatorFastArmOptHW all 1 1
339 run-tests SetupPnaclTranslatorFastArmOptHW all 1 2
340 # Only run 1 thread ARM tests 1x to save some time for now.
341 # Hopefully perf infrastructure will smooth out flakes.
342 # Otherwise, we'll bump the runs up to 2x as well.
343 build-tests SetupPnaclTranslatorFast1ThreadArmOptHW all 1 1
344 run-tests SetupPnaclTranslatorFast1ThreadArmOptHW all 1 1
349 build-prerequisites "x86-64" "bitcode"
350 local setups="SetupPnaclX8664Opt \
351 SetupPnaclTranslatorX8664Opt \
352 SetupPnaclTranslator1ThreadX8664Opt \
353 SetupPnaclTranslatorFastX8664Opt \
354 SetupPnaclTranslatorFast1ThreadX8664Opt"
355 build-tests "${setups}" all 1 3
356 run-tests "${setups}" all 1 3
357 pnacl-x86-64-zero-based-sandbox
358 build-validator x86-64
359 download-validator-test-nexes x86-64
360 measure-validator-speed x86-64
365 build-prerequisites "x86-32" "bitcode"
366 local setups="SetupPnaclX8632Opt \
367 SetupPnaclTranslatorX8632Opt \
368 SetupPnaclTranslator1ThreadX8632Opt \
369 SetupPnaclTranslatorFastX8632Opt \
370 SetupPnaclTranslatorFast1ThreadX8632Opt"
371 build-tests "${setups}" all 1 3
372 run-tests "${setups}" all 1 3
373 build-validator x86-32
374 download-validator-test-nexes x86-32
375 measure-validator-speed x86-32
380 build-prerequisites "x86-32" ""
381 local setups="SetupNaclX8632 \
383 build-tests "${setups}" all 1 3
384 run-tests "${setups}" all 1 3
385 build-validator x86-32
386 download-validator-test-nexes x86-32
387 measure-validator-speed x86-32
392 build-prerequisites "x86-64" ""
393 local setups="SetupNaclX8664 \
395 build-tests "${setups}" all 1 3
396 run-tests "${setups}" all 1 3
397 build-validator x86-64
398 download-validator-test-nexes x86-64
399 measure-validator-speed x86-64
403 ######################################################################
404 # Script assumed to be run in native_client/
405 if [[ $(pwd) != */native_client ]]; then
406 echo "ERROR: must be run in native_client!"
411 if [[ $# -eq 0 ]] ; then
412 echo "you must specify a mode on the commandline:"
416 if [ "$(type -t $1)" != "function" ]; then
418 echo "ERROR: unknown mode '$1'." >&2
424 if [[ ${RETCODE} != 0 ]]; then
425 echo "@@@BUILD_STEP summary@@@"
426 echo There were failed stages.