| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
| 4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
| 5 | 5 |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import shutil | |
| 9 import sys | 8 import sys |
| 10 | 9 |
| 11 import bot | 10 import bot |
| 12 | 11 |
| 13 GCS_BUCKET = 'gs://dart-cross-compiled-binaries' | 12 GCS_BUCKET = 'gs://dart-cross-compiled-binaries' |
| 14 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) | 13 SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 15 sys.path.append(os.path.join(SCRIPT_DIR, '..')) | 14 sys.path.append(os.path.join(SCRIPT_DIR, '..')) |
| 16 | 15 |
| 17 import utils | 16 import utils |
| 18 | 17 |
| 19 CROSS_VM = r'cross-(arm)-vm-linux-(release)' | 18 CROSS_VM = r'cross-(arm)-vm-linux-(release)' |
| 20 TARGET_VM = r'target-(arm)-vm-linux-(release)' | 19 TARGET_VM = r'target-(arm)-vm-linux-(release)' |
| 21 GSUTIL = utils.GetBuildbotGSUtilPath() | 20 GSUTIL = utils.GetBuildbotGSUtilPath() |
| 22 | 21 |
| 23 def run(args): | 22 def run(args): |
| 24 print 'Running: %s' % (' '.join(args)) | 23 print 'Running: %s' % (' '.join(args)) |
| 25 sys.stdout.flush() | 24 sys.stdout.flush() |
| 26 bot.RunProcess(args) | 25 bot.RunProcess(args) |
| 27 | 26 |
| 28 def tarball_name(arch, mode): | 27 def tarball_name(arch, mode): |
| 29 return 'cross_build_%s_%s.tar.bz2' % (arch, mode) | 28 return 'cross_build_%s_%s.tar.bz2' % (arch, mode) |
| 30 | 29 |
| 31 def record_names(name, arch, mode): | 30 def record_names(name, arch, mode): |
| 32 return ('record_%s_%s_%s.json' % (name, arch, mode), | 31 return ('record_%s_%s_%s.json' % (name, arch, mode), |
| 33 'record_output_%s_%s_%s.json' % (name, arch, mode)) | 32 'record_output_%s_%s_%s.json' % (name, arch, mode)) |
| 34 | 33 |
| 35 def cross_compiling_builder(arch, mode): | 34 def cross_compiling_builder(arch, mode): |
| 36 build_py = os.path.join('tools', 'build.py') | 35 build_py = os.path.join('tools', 'build.py') |
| 37 test_py = os.path.join('tools', 'test.py') | |
| 38 test_args = [sys.executable, test_py, '--progress=line', '--report', | |
| 39 '--time', '--compiler=none', '--runtime=vm', '--write-debug-log'] | |
| 40 | 36 |
| 41 tarball = tarball_name(arch, mode) | 37 tarball = tarball_name(arch, mode) |
| 42 (recording, recording_out) = record_names('tests', arch, mode) | 38 temporary_files = [tarball] |
| 43 (checked_recording, checked_recording_out) = record_names( | |
| 44 'checked_tests', arch, mode) | |
| 45 | |
| 46 temporary_files = [tarball, recording, recording_out, checked_recording, | |
| 47 checked_recording_out] | |
| 48 bot.Clobber() | 39 bot.Clobber() |
| 49 try: | 40 try: |
| 50 num_run = int(os.environ['BUILDBOT_ANNOTATED_STEPS_RUN']) | 41 num_run = int(os.environ['BUILDBOT_ANNOTATED_STEPS_RUN']) |
| 51 if num_run == 1: | 42 if num_run == 1: |
| 52 with bot.BuildStep('Build %s %s' % (arch, mode)): | 43 with bot.BuildStep('Build %s %s' % (arch, mode)): |
| 53 run([sys.executable, build_py, | 44 run([sys.executable, build_py, |
| 54 '-m%s' % mode, '--arch=%s' % arch, 'runtime']) | 45 '-m%s' % mode, '--arch=%s' % arch, 'runtime']) |
| 55 # We need to build 'run_vm_tests.host' as well to enable | 46 # We need to build 'run_vm_tests.host' as well to enable |
| 56 # test.py to list the VM tests. | 47 # test.py to list the VM tests. |
| 57 run([sys.executable, build_py, | 48 run([sys.executable, build_py, |
| 58 '-m%s' % mode, '--arch=%s' % arch, 'run_vm_tests.host']) | 49 '-m%s' % mode, '--arch=%s' % arch, 'run_vm_tests.host']) |
| 59 | 50 |
| 60 with bot.BuildStep('Create build tarball'): | 51 with bot.BuildStep('Create build tarball'): |
| 61 run(['tar', '-cjf', tarball, '--exclude=**/obj', | 52 run(['tar', '-cjf', tarball, '--exclude=**/obj', |
| 62 '--exclude=**/obj.host', '--exclude=**/obj.target', | 53 '--exclude=**/obj.host', '--exclude=**/obj.target', |
| 63 '--exclude=**/*analyzer*', '--exclude=**/run_vm_tests.host', | 54 '--exclude=**/*analyzer*', '--exclude=**/run_vm_tests.host', |
| 64 'out/']) | 55 'out/']) |
| 65 | 56 |
| 66 with bot.BuildStep('Upload build tarball'): | 57 with bot.BuildStep('Upload build tarball'): |
| 67 uri = "%s/%s" % (GCS_BUCKET, tarball) | 58 uri = "%s/%s" % (GCS_BUCKET, tarball) |
| 68 run([GSUTIL, 'cp', tarball, uri]) | 59 run([GSUTIL, 'cp', tarball, uri]) |
| 69 run([GSUTIL, 'setacl', 'public-read', uri]) | 60 run([GSUTIL, 'setacl', 'public-read', uri]) |
| 70 | 61 |
| 71 with bot.BuildStep('prepare tests'): | |
| 72 uri = "%s/%s" % (GCS_BUCKET, recording) | |
| 73 run(test_args + ['--mode=' + mode, '--arch=' + arch, | |
| 74 '--record_to_file=' + recording]) | |
| 75 run([GSUTIL, 'cp', recording, uri]) | |
| 76 run([GSUTIL, 'setacl', 'public-read', uri]) | |
| 77 | |
| 78 with bot.BuildStep('prepare checked_tests'): | |
| 79 uri = "%s/%s" % (GCS_BUCKET, checked_recording) | |
| 80 run(test_args + ['--mode=' + mode, '--arch=' + arch, '--checked', | |
| 81 '--record_to_file=' + checked_recording]) | |
| 82 run([GSUTIL, 'cp', checked_recording, uri]) | |
| 83 run([GSUTIL, 'setacl', 'public-read', uri]) | |
| 84 elif num_run == 2: | 62 elif num_run == 2: |
| 85 with bot.BuildStep('tests'): | 63 with bot.BuildStep('tests'): |
| 86 uri = "%s/%s" % (GCS_BUCKET, recording_out) | 64 print "Please see the target device for results." |
| 87 run([GSUTIL, 'cp', uri, recording_out]) | 65 print "We no longer record/replay tests." |
| 88 run(test_args + ['--mode=' + mode, '--arch=' + arch, | |
| 89 '--replay_from_file=' + recording_out]) | |
| 90 | |
| 91 with bot.BuildStep('checked_tests'): | |
| 92 uri = "%s/%s" % (GCS_BUCKET, checked_recording_out) | |
| 93 run([GSUTIL, 'cp', uri, checked_recording_out]) | |
| 94 run(test_args + ['--mode=' + mode, '--arch=' + arch, '--checked', | |
| 95 '--replay_from_file=' + checked_recording_out]) | |
| 96 else: | 66 else: |
| 97 raise Exception("Invalid annotated steps run") | 67 raise Exception("Invalid annotated steps run") |
| 98 finally: | 68 finally: |
| 99 for path in temporary_files: | 69 for path in temporary_files: |
| 100 if os.path.exists(path): | 70 if os.path.exists(path): |
| 101 os.remove(path) | 71 os.remove(path) |
| 102 | 72 |
| 103 def target_builder(arch, mode): | 73 def target_builder(arch, mode): |
| 104 execute_testcases_py = os.path.join('tools', 'execute_recorded_testcases.py') | 74 test_py = os.path.join('tools', 'test.py') |
| 75 test_args = [sys.executable, test_py, '--progress=line', '--report', |
| 76 '--time', '--compiler=none', '--runtime=vm', '--write-debug-log', |
| 77 '--mode=' + mode, '--arch=' + arch] |
| 105 | 78 |
| 106 tarball = tarball_name(arch, mode) | 79 tarball = tarball_name(arch, mode) |
| 107 (recording, recording_out) = record_names('tests', arch, mode) | 80 temporary_files = [tarball] |
| 108 (checked_recording, checked_recording_out) = record_names( | |
| 109 'checked_tests', arch, mode) | |
| 110 | |
| 111 temporary_files = [tarball, recording, recording_out, checked_recording, | |
| 112 checked_recording_out] | |
| 113 bot.Clobber() | 81 bot.Clobber() |
| 114 try: | 82 try: |
| 115 with bot.BuildStep('Fetch build tarball'): | 83 with bot.BuildStep('Fetch build tarball'): |
| 116 run([GSUTIL, 'cp', "%s/%s" % (GCS_BUCKET, tarball), tarball]) | 84 run([GSUTIL, 'cp', "%s/%s" % (GCS_BUCKET, tarball), tarball]) |
| 117 | 85 |
| 118 with bot.BuildStep('Unpack build tarball'): | 86 with bot.BuildStep('Unpack build tarball'): |
| 119 run(['tar', '-xjf', tarball]) | 87 run(['tar', '-xjf', tarball]) |
| 120 | 88 |
| 121 with bot.BuildStep('execute tests'): | 89 with bot.BuildStep('execute tests'): |
| 122 uri = "%s/%s" % (GCS_BUCKET, recording) | 90 run(test_args) |
| 123 uri_out = "%s/%s" % (GCS_BUCKET, recording_out) | |
| 124 run([GSUTIL, 'cp', uri, recording]) | |
| 125 run(['python', execute_testcases_py, recording, recording_out]) | |
| 126 run([GSUTIL, 'cp', recording_out, uri_out]) | |
| 127 run([GSUTIL, 'setacl', 'public-read', uri_out]) | |
| 128 | 91 |
| 129 with bot.BuildStep('execute checked_tests'): | 92 with bot.BuildStep('execute checked_tests'): |
| 130 uri = "%s/%s" % (GCS_BUCKET, checked_recording) | 93 run(test_args + ['--checked']) |
| 131 uri_out = "%s/%s" % (GCS_BUCKET, checked_recording_out) | |
| 132 run([GSUTIL, 'cp', uri, checked_recording]) | |
| 133 run(['python', execute_testcases_py, checked_recording, | |
| 134 checked_recording_out]) | |
| 135 run([GSUTIL, 'cp', checked_recording_out, uri_out]) | |
| 136 run([GSUTIL, 'setacl', 'public-read', uri_out]) | |
| 137 finally: | 94 finally: |
| 138 for path in temporary_files: | 95 for path in temporary_files: |
| 139 if os.path.exists(path): | 96 if os.path.exists(path): |
| 140 os.remove(path) | 97 os.remove(path) |
| 141 | 98 |
| 142 def main(): | 99 def main(): |
| 143 name, is_buildbot = bot.GetBotName() | 100 name, is_buildbot = bot.GetBotName() |
| 144 | 101 |
| 145 cross_vm_pattern_match = re.match(CROSS_VM, name) | 102 cross_vm_pattern_match = re.match(CROSS_VM, name) |
| 146 target_vm_pattern_match = re.match(TARGET_VM, name) | 103 target_vm_pattern_match = re.match(TARGET_VM, name) |
| 147 if cross_vm_pattern_match: | 104 if cross_vm_pattern_match: |
| 148 arch = cross_vm_pattern_match.group(1) | 105 arch = cross_vm_pattern_match.group(1) |
| 149 mode = cross_vm_pattern_match.group(2) | 106 mode = cross_vm_pattern_match.group(2) |
| 150 cross_compiling_builder(arch, mode) | 107 cross_compiling_builder(arch, mode) |
| 151 elif target_vm_pattern_match: | 108 elif target_vm_pattern_match: |
| 152 arch = target_vm_pattern_match.group(1) | 109 arch = target_vm_pattern_match.group(1) |
| 153 mode = target_vm_pattern_match.group(2) | 110 mode = target_vm_pattern_match.group(2) |
| 154 target_builder(arch, mode) | 111 target_builder(arch, mode) |
| 155 else: | 112 else: |
| 156 raise Exception("Unknown builder name %s" % name) | 113 raise Exception("Unknown builder name %s" % name) |
| 157 | 114 |
| 158 if __name__ == '__main__': | 115 if __name__ == '__main__': |
| 159 try: | 116 try: |
| 160 sys.exit(main()) | 117 sys.exit(main()) |
| 161 except OSError as e: | 118 except OSError as e: |
| 162 sys.exit(e.errno) | 119 sys.exit(e.errno) |
| OLD | NEW |