Upstream version 5.34.92.0
[platform/framework/web/crosswalk.git] / src / native_client / buildbot / buildbot_selector.py
1 #!/usr/bin/python
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.
5
6 import json
7 import os
8 import subprocess
9 import sys
10
11 python = sys.executable
12 bash = '/bin/bash'
13 echo = 'echo'
14
15
16 BOT_ASSIGNMENT = {
17     ######################################################################
18     # Buildbots.
19     ######################################################################
20     'xp-newlib-opt':
21         python + ' buildbot\\buildbot_standard.py opt 32 newlib --no-gyp',
22     'xp-glibc-opt':
23         python + ' buildbot\\buildbot_standard.py opt 32 glibc --no-gyp',
24
25     'xp-bare-newlib-opt':
26         python + ' buildbot\\buildbot_standard.py opt 32 newlib --no-gyp',
27     'xp-bare-glibc-opt':
28         python + ' buildbot\\buildbot_standard.py opt 32 glibc --no-gyp',
29
30     'precise-64-validator-opt':
31         python + ' buildbot/buildbot_standard.py opt 64 glibc --validator',
32
33     # Clang.
34     'precise_64-newlib-dbg-clang':
35         python + ' buildbot/buildbot_standard.py dbg 64 newlib --clang',
36     'mac10.7-newlib-dbg-clang':
37         python + ' buildbot/buildbot_standard.py dbg 32 newlib --clang',
38
39     # ASan.
40     'precise_64-newlib-dbg-asan':
41         python + ' buildbot/buildbot_standard.py opt 64 newlib --asan',
42     'mac10.7-newlib-dbg-asan':
43         python + ' buildbot/buildbot_standard.py opt 32 newlib --asan',
44
45     # PNaCl.
46     'oneiric_32-newlib-arm_hw-pnacl-panda-dbg':
47         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-hw-dbg',
48     'oneiric_32-newlib-arm_hw-pnacl-panda-opt':
49         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-hw-opt',
50     'precise_64-newlib-arm_qemu-pnacl-dbg':
51         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-dbg',
52     'precise_64-newlib-arm_qemu-pnacl-opt':
53         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-opt',
54     'precise_64-newlib-x86_32-pnacl':
55         python + ' buildbot/buildbot_pnacl.py opt 32 pnacl',
56     'precise_64-newlib-x86_64-pnacl':
57         python + ' buildbot/buildbot_pnacl.py opt 64 pnacl',
58     'precise_64-newlib-mips-pnacl':
59         echo + ' "TODO(mseaborn): add mips"',
60     # PNaCl Spec
61     'lucid_64-newlib-arm_qemu-pnacl-buildonly-spec':
62         bash + ' buildbot/buildbot_spec2k.sh pnacl-arm-buildonly',
63     'oneiric_32-newlib-arm_hw-pnacl-panda-spec':
64         bash + ' buildbot/buildbot_spec2k.sh pnacl-arm-hw',
65     'lucid_64-newlib-x86_32-pnacl-spec':
66         bash + ' buildbot/buildbot_spec2k.sh pnacl-x8632',
67     'lucid_64-newlib-x86_64-pnacl-spec':
68         bash + ' buildbot/buildbot_spec2k.sh pnacl-x8664',
69     'precise_64-newlib-arm_qemu-pnacl-buildonly-spec':
70         bash + ' buildbot/buildbot_spec2k.sh pnacl-arm-buildonly',
71     # NaCl Spec
72     'lucid_64-newlib-x86_32-spec':
73         bash + ' buildbot/buildbot_spec2k.sh nacl-x8632',
74     'lucid_64-newlib-x86_64-spec':
75         bash + ' buildbot/buildbot_spec2k.sh nacl-x8664',
76
77     # Valgrind bots.
78     'precise-64-newlib-dbg-valgrind':
79         echo + ' "Valgrind bots are disabled: see '
80             'https://code.google.com/p/nativeclient/issues/detail?id=3158"',
81     'precise-64-glibc-dbg-valgrind':
82         echo + ' "Valgrind bots are disabled: see '
83             'https://code.google.com/p/nativeclient/issues/detail?id=3158"',
84     # Coverage.
85     'mac10.6-newlib-coverage':
86          python + (' buildbot/buildbot_standard.py '
87                    'coverage 64 newlib --coverage --clang'),
88     'precise-64-32-newlib-coverage':
89          python + (' buildbot/buildbot_standard.py '
90                    'coverage 32 newlib --coverage'),
91     'precise-64-64-newlib-coverage':
92          python + (' buildbot/buildbot_standard.py '
93                    'coverage 64 newlib --coverage'),
94     'xp-newlib-coverage':
95          python + (' buildbot/buildbot_standard.py '
96                    'coverage 32 newlib --coverage'),
97
98     ######################################################################
99     # Trybots.
100     ######################################################################
101     'nacl-precise64_validator_opt':
102         python + ' buildbot/buildbot_standard.py opt 64 glibc --validator',
103     'nacl-precise64_newlib_dbg_valgrind':
104         bash + ' buildbot/buildbot_valgrind.sh newlib',
105     'nacl-precise64_glibc_dbg_valgrind':
106         bash + ' buildbot/buildbot_valgrind.sh glibc',
107     # Coverage trybots.
108     'nacl-mac10.6-newlib-coverage':
109          python + (' buildbot/buildbot_standard.py '
110                    'coverage 64 newlib --coverage --clang'),
111     'nacl-precise-64-32-newlib-coverage':
112          python + (' buildbot/buildbot_standard.py '
113                    'coverage 32 newlib --coverage'),
114     'nacl-precise-64-64-newlib-coverage':
115          python + (' buildbot/buildbot_standard.py '
116                    'coverage 64 newlib --coverage'),
117     'nacl-win32-newlib-coverage':
118          python + (' buildbot/buildbot_standard.py '
119                    'coverage 32 newlib --coverage'),
120     # Clang trybots.
121     'nacl-precise_64-newlib-dbg-clang':
122         python + ' buildbot/buildbot_standard.py dbg 64 newlib --clang',
123     'nacl-mac10.6-newlib-dbg-clang':
124         python + ' buildbot/buildbot_standard.py dbg 32 newlib --clang',
125     # Pnacl main trybots
126     'nacl-precise_64-newlib-arm_qemu-pnacl':
127         bash + ' buildbot/buildbot_pnacl.sh mode-trybot-qemu',
128     'nacl-precise_64-newlib-x86_32-pnacl':
129          python + ' buildbot/buildbot_pnacl.py opt 32 pnacl',
130     'nacl-precise_64-newlib-x86_64-pnacl':
131          python + ' buildbot/buildbot_pnacl.py opt 64 pnacl',
132     'nacl-precise_64-newlib-mips-pnacl':
133         echo + ' "TODO(mseaborn): add mips"',
134     'nacl-arm_opt_panda':
135         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-try',
136     'nacl-arm_hw_opt_panda':
137         bash + ' buildbot/buildbot_pnacl.sh mode-buildbot-arm-hw-try',
138     # Pnacl spec2k trybots
139     'nacl-precise_64-newlib-x86_32-pnacl-spec':
140         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-x8632',
141     'nacl-precise_64-newlib-x86_64-pnacl-spec':
142         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-x8664',
143     'nacl-arm_perf_panda':
144         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-arm-buildonly',
145     'nacl-arm_hw_perf_panda':
146         bash + ' buildbot/buildbot_spec2k.sh pnacl-trybot-arm-hw',
147     # Toolchain glibc.
148     'precise64-glibc': bash + ' buildbot/buildbot_linux-glibc-makefile.sh',
149     'mac-glibc': bash + ' buildbot/buildbot_mac-glibc-makefile.sh',
150     'win7-glibc': 'buildbot\\buildbot_windows-glibc-makefile.bat',
151     # Toolchain newlib x86.
152     'win7-toolchain_x86': 'buildbot\\buildbot_toolchain_win.bat',
153     'mac-toolchain_x86': bash + ' buildbot/buildbot_toolchain.sh mac',
154     'precise64-toolchain_x86': bash + ' buildbot/buildbot_toolchain.sh linux',
155     # Toolchain newlib arm.
156     'win7-toolchain_arm':
157         python + ' buildbot/buildbot_toolchain_build.py --buildbot',
158     'mac-toolchain_arm':
159         python + ' buildbot/buildbot_toolchain_build.py --buildbot',
160     'precise64-toolchain_arm':
161         python + ' buildbot/buildbot_toolchain_build.py --buildbot',
162
163     # Pnacl toolchain builders.
164     'linux-armtools-x86_32':
165         bash + ' buildbot/buildbot_toolchain_arm_trusted.sh',
166     'linux-pnacl-x86_32':
167         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
168     'linux-pnacl-x86_64':
169         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
170     'precise-pnacl-x86_32':
171         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
172     'precise-pnacl-x86_64':
173         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
174     'mac-pnacl-x86_32':
175         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
176     # TODO(robertm): Delete this once we are using win-pnacl-x86_64
177     'win-pnacl-x86_32':
178         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
179     # TODO(robertm): use this in favor or the misnamed win-pnacl-x86_32
180     'win-pnacl-x86_64':
181         python + ' buildbot/buildbot_pnacl_toolchain.py --buildbot',
182
183     # Pnacl toolchain testers
184     'linux-pnacl-x86_64-tests-x86_64':
185         bash + ' buildbot/buildbot_pnacl_toolchain_tests.sh tc-test-bot x86-64',
186     'linux-pnacl-x86_64-tests-x86_32':
187         bash + ' buildbot/buildbot_pnacl_toolchain_tests.sh tc-test-bot x86-32',
188     'linux-pnacl-x86_64-tests-arm':
189         bash + ' buildbot/buildbot_pnacl_toolchain_tests.sh tc-test-bot arm',
190
191     # MIPS toolchain buildbot.
192     'linux-pnacl-x86_32-tests-mips':
193         bash + ' buildbot/buildbot_toolchain_mips_trusted.sh',
194
195     # Toolchain trybots.
196     'nacl-toolchain-precise64-newlib':
197         bash + ' buildbot/buildbot_toolchain.sh linux',
198     'nacl-toolchain-mac-newlib': bash + ' buildbot/buildbot_toolchain.sh mac',
199     'nacl-toolchain-win7-newlib': 'buildbot\\buildbot_toolchain_win.bat',
200     'nacl-toolchain-precise64-newlib-arm':
201         python + ' buildbot/buildbot_toolchain_build.py --trybot',
202     'nacl-toolchain-mac-newlib-arm':
203         python + ' buildbot/buildbot_toolchain_build.py --trybot',
204     'nacl-toolchain-win7-newlib-arm':
205         python + ' buildbot/buildbot_toolchain_build.py --trybot',
206     'nacl-toolchain-precise64-glibc':
207         bash + ' buildbot/buildbot_linux-glibc-makefile.sh',
208     'nacl-toolchain-mac-glibc':
209         bash + ' buildbot/buildbot_mac-glibc-makefile.sh',
210     'nacl-toolchain-win7-glibc':
211         'buildbot\\buildbot_windows-glibc-makefile.bat',
212
213     # Pnacl toolchain trybots.
214     'nacl-toolchain-linux-pnacl-x86_32':
215         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
216     'nacl-toolchain-linux-pnacl-x86_64':
217         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
218     'nacl-toolchain-linux-pnacl-mips': echo + ' "TODO(mseaborn)"',
219     'nacl-toolchain-precise-pnacl-x86_32':
220         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
221     'nacl-toolchain-precise-pnacl-x86_64':
222         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
223     'nacl-toolchain-precise-pnacl-mips': echo + ' "TODO(mseaborn)"',
224     'nacl-toolchain-mac-pnacl-x86_32':
225         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
226     'nacl-toolchain-win7-pnacl-x86_64':
227         python + ' buildbot/buildbot_pnacl_toolchain.py --trybot',
228
229 }
230
231 special_for_arm = [
232     'win7_64',
233     'win7-64',
234     'lucid-64',
235     'lucid64',
236     'precise-64',
237     'precise64'
238 ]
239 for platform in [
240     'vista', 'win7', 'win8', 'win',
241     'mac10.6', 'mac10.7', 'mac10.8',
242     'lucid', 'precise'] + special_for_arm:
243   if platform in special_for_arm:
244     arch_variants = ['arm']
245   else:
246     arch_variants = ['', '32', '64', 'arm']
247   for arch in arch_variants:
248     arch_flags = ''
249     real_arch = arch
250     arch_part = '-' + arch
251     # Disable GYP build for win32 bots and arm cross-builders. In this case
252     # "win" means Windows XP, not Vista, Windows 7, etc.
253     #
254     # Building via GYP always builds all toolchains by default, but the win32
255     # XP pnacl builds are pathologically slow (e.g. ~38 seconds per compile on
256     # the nacl-win32_glibc_opt trybot). There are other builders that test
257     # Windows builds via gyp, so the reduced test coverage should be slight.
258     if arch == 'arm' or (platform == 'win' and arch == '32'):
259       arch_flags += ' --no-gyp'
260     if arch == '':
261       arch_part = ''
262       real_arch = '32'
263     if platform.startswith('mac'):
264       arch_flags += ' --clang'
265     # Test with Breakpad tools only on basic Linux builds.
266     if sys.platform.startswith('linux'):
267       arch_flags += ' --use-breakpad-tools'
268     for mode in ['dbg', 'opt']:
269       for libc in ['newlib', 'glibc']:
270         # Buildbots.
271         for bare in ['', '-bare']:
272           name = platform + arch_part + bare + '-' + libc + '-' + mode
273           assert name not in BOT_ASSIGNMENT, name
274           BOT_ASSIGNMENT[name] = (
275               python + ' buildbot/buildbot_standard.py ' +
276               mode + ' ' + real_arch + ' ' + libc + arch_flags)
277         # Trybots
278         for arch_sep in ['', '-', '_']:
279           name = 'nacl-' + platform + arch_sep + arch + '_' + libc + '_' + mode
280           assert name not in BOT_ASSIGNMENT, name
281           BOT_ASSIGNMENT[name] = (
282               python + ' buildbot/buildbot_standard.py ' +
283               mode + ' ' + real_arch + ' ' + libc + arch_flags)
284
285
286 def EscapeJson(data):
287   return '"' + json.dumps(data).replace('"', r'\"') + '"'
288
289
290 def Main():
291   builder = os.environ.get('BUILDBOT_BUILDERNAME')
292   build_number = os.environ.get('BUILDBOT_BUILDNUMBER')
293   slave_type = os.environ.get('BUILDBOT_SLAVE_TYPE')
294   cmd = BOT_ASSIGNMENT.get(builder)
295   if not cmd:
296     sys.stderr.write('ERROR - unset/invalid builder name\n')
297     sys.exit(1)
298
299   env = os.environ.copy()
300
301   # Use .boto file from home-dir instead of buildbot supplied one.
302   if 'AWS_CREDENTIAL_FILE' in env:
303     del env['AWS_CREDENTIAL_FILE']
304   if 'BOTO_CONFIG' in env:
305     del env['BOTO_CONFIG']
306
307   env['GSUTIL'] = '/b/build/third_party/gsutil/gsutil'
308
309   # Run through runtest.py to get upload of perf data.
310   build_properties = {
311       'buildername': builder,
312       'mastername': 'client.nacl',
313       'buildnumber': str(build_number),
314   }
315   factory_properties = {
316       'perf_id': builder,
317       'show_perf_results': True,
318       'step_name': 'naclperf',  # Seems unused, but is required.
319       'test_name': 'naclperf',  # Really "Test Suite"
320       'expectations': True,
321       'perf_filename': ('native_client/tools/'
322                         'nacl_perf_expectations/nacl_perf_expectations.json'),
323   }
324   # Locate the buildbot build directory by relative path, as it's absolute
325   # location varies by platform and configuration.
326   buildbot_build_dir = os.path.join(* [os.pardir] * 4)
327   runtest = os.path.join(buildbot_build_dir, 'scripts', 'slave', 'runtest.py')
328   # For builds with an actual build number, require that the script is present
329   # (i.e. that we're run from an actual buildbot).
330   if build_number is not None and not os.path.exists(runtest):
331     raise Exception('runtest.py script not found at: %s\n' % runtest)
332   cmd_exe = cmd.split(' ')[0]
333   cmd_exe_ext = os.path.splitext(cmd_exe)[1]
334   # Do not wrap these types of builds with runtest.py:
335   # - tryjobs
336   # - commands beginning with 'echo '
337   # - batch files
338   if not (slave_type == 'Trybot' or
339           cmd_exe == echo or
340           cmd_exe_ext == '.bat'):
341     # Perf dashboards are now generated by output scraping that occurs in the
342     # script runtest.py, which lives in the buildbot repository.
343     # Non-trybot builds should be run through runtest, allowing it to upload
344     # perf data if relevant.
345     cmd = ' '.join([
346         python, runtest,
347         '--build-dir=src/out',
348         '--results-url=https://chromeperf.appspot.com',
349         '--annotate=graphing',
350         '--no-xvfb',  # We provide our own xvfb invocation.
351         '--factory-properties', EscapeJson(factory_properties),
352         '--build-properties', EscapeJson(build_properties),
353         cmd,
354     ])
355
356   print "%s runs: %s\n" % (builder, cmd)
357   retcode = subprocess.call(cmd, env=env, shell=True)
358   sys.exit(retcode)
359
360
361 if __name__ == '__main__':
362   Main()