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_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
261 ./run_all.sh TimeValidation SetupPnaclTranslatorArmOptHW "${TRYBOT_TESTS}" ||\
264 build-tests SetupPnaclTranslatorFastArmOptHW "${TRYBOT_TESTS}" 1 1
265 run-tests SetupPnaclTranslatorFastArmOptHW "${TRYBOT_TESTS}" 1 1
268 pnacl-trybot-x8632() {
270 build-prerequisites "x86-32" "bitcode"
271 build-tests SetupPnaclX8632Opt "${TRYBOT_TESTS}" 1 1
272 run-tests SetupPnaclX8632Opt "${TRYBOT_TESTS}" 1 1
273 build-tests SetupPnaclTranslatorX8632Opt "${TRYBOT_TESTS}" 1 1
274 run-tests SetupPnaclTranslatorX8632Opt "${TRYBOT_TESTS}" 1 1
275 build-tests SetupPnaclTranslatorFastX8632Opt "${TRYBOT_TESTS}" 1 1
276 run-tests SetupPnaclTranslatorFastX8632Opt "${TRYBOT_TESTS}" 1 1
277 build-validator x86-32
278 download-validator-test-nexes x86-32
279 measure-validator-speed x86-32
282 pnacl-x86-64-zero-based-sandbox() {
284 export NACL_ENABLE_INSECURE_ZERO_BASED_SANDBOX=1
285 build-prerequisites "x86-64" "bitcode" "x86_64_zero_based_sandbox=1"
286 build-tests SetupPnaclX8664ZBSOpt \
287 "${TRYBOT_X86_64_ZERO_BASED_SANDBOX_TESTS}" 1 1
288 run-tests SetupPnaclX8664ZBSOpt \
289 "${TRYBOT_X86_64_ZERO_BASED_SANDBOX_TESTS}" 1 1
292 pnacl-trybot-x8664() {
294 build-prerequisites "x86-64" "bitcode"
295 build-tests SetupPnaclX8664Opt "${TRYBOT_TESTS}" 1 1
296 run-tests SetupPnaclX8664Opt "${TRYBOT_TESTS}" 1 1
297 build-tests SetupPnaclTranslatorX8664Opt "${TRYBOT_TESTS}" 1 1
298 run-tests SetupPnaclTranslatorX8664Opt "${TRYBOT_TESTS}" 1 1
299 build-tests SetupPnaclTranslatorFastX8664Opt "${TRYBOT_TESTS}" 1 1
300 run-tests SetupPnaclTranslatorFastX8664Opt "${TRYBOT_TESTS}" 1 1
301 pnacl-x86-64-zero-based-sandbox
302 build-validator x86-64
303 download-validator-test-nexes x86-64
304 measure-validator-speed x86-64
307 pnacl-arm-buildonly() {
309 build-prerequisites "arm" "bitcode"
310 ${BUILDBOT_PNACL} archive-for-hw-bots "${NAME_ARM_UPLOAD}" regular
311 build-tests SetupPnaclPexeOpt all 0 1
312 upload-test-binaries all regular
317 ${BUILDBOT_PNACL} unarchive-for-hw-bots "${NAME_ARM_DOWNLOAD}" regular
318 download-test-binaries regular
319 build-tests SetupPnaclTranslatorArmOptHW all 1 1
320 run-tests SetupPnaclTranslatorArmOptHW all 1 2
321 build-tests SetupPnaclTranslatorFastArmOptHW all 1 1
322 run-tests SetupPnaclTranslatorFastArmOptHW all 1 2
327 build-prerequisites "x86-64" "bitcode"
328 local setups="SetupPnaclX8664Opt \
329 SetupPnaclTranslatorX8664Opt \
330 SetupPnaclTranslatorFastX8664Opt"
331 build-tests "${setups}" all 1 3
332 run-tests "${setups}" all 1 3
333 pnacl-x86-64-zero-based-sandbox
334 build-validator x86-64
335 download-validator-test-nexes x86-64
336 measure-validator-speed x86-64
341 build-prerequisites "x86-32" "bitcode"
342 local setups="SetupPnaclX8632Opt \
343 SetupPnaclTranslatorX8632Opt \
344 SetupPnaclTranslatorFastX8632Opt"
345 build-tests "${setups}" all 1 3
346 run-tests "${setups}" all 1 3
347 build-validator x86-32
348 download-validator-test-nexes x86-32
349 measure-validator-speed x86-32
354 build-prerequisites "x86-32" ""
355 local setups="SetupNaclX8632 \
357 build-tests "${setups}" all 1 3
358 run-tests "${setups}" all 1 3
359 build-validator x86-32
360 download-validator-test-nexes x86-32
361 measure-validator-speed x86-32
366 build-prerequisites "x86-64" ""
367 local setups="SetupNaclX8664 \
369 build-tests "${setups}" all 1 3
370 run-tests "${setups}" all 1 3
371 build-validator x86-64
372 download-validator-test-nexes x86-64
373 measure-validator-speed x86-64
377 ######################################################################
378 # Script assumed to be run in native_client/
379 if [[ $(pwd) != */native_client ]]; then
380 echo "ERROR: must be run in native_client!"
385 if [[ $# -eq 0 ]] ; then
386 echo "you must specify a mode on the commandline:"
390 if [ "$(type -t $1)" != "function" ]; then
392 echo "ERROR: unknown mode '$1'." >&2
398 if [[ ${RETCODE} != 0 ]]; then
399 echo "@@@BUILD_STEP summary@@@"
400 echo There were failed stages.