OLD | NEW |
| (Empty) |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 """Recipe to test the deterministic build. | |
6 """ | |
7 | |
8 DEPS = [ | |
9 'depot_tools/bot_update', | |
10 'chromium', | |
11 'chromium_android', | |
12 'depot_tools/gclient', | |
13 'isolate', | |
14 'recipe_engine/json', | |
15 'recipe_engine/path', | |
16 'recipe_engine/platform', | |
17 'recipe_engine/properties', | |
18 'recipe_engine/python', | |
19 'recipe_engine/step', | |
20 ] | |
21 | |
22 DETERMINISTIC_BUILDERS = { | |
23 'android_deterministic': { | |
24 'chromium_config': 'android', | |
25 'chromium_config_kwargs': { | |
26 'BUILD_CONFIG': 'Release', | |
27 'TARGET_BITS': 32, | |
28 'TARGET_PLATFORM': 'android', | |
29 }, | |
30 'platform': 'linux', | |
31 'targets': ['all'], | |
32 }, | |
33 'linux_deterministic': { | |
34 'chromium_config': 'chromium', | |
35 'gclient_config': 'chromium', | |
36 'platform': 'linux', | |
37 }, | |
38 'mac_deterministic': { | |
39 'chromium_config': 'chromium', | |
40 'gclient_config': 'chromium', | |
41 'platform': 'mac', | |
42 }, | |
43 'win_deterministic': { | |
44 'chromium_config': 'chromium', | |
45 'gclient_config': 'chromium', | |
46 'platform': 'win', | |
47 }, | |
48 } | |
49 | |
50 | |
51 def MoveBuildDirectory(api, src_dir, dst_dir): | |
52 api.python.inline('Move %s to %s' % (src_dir, dst_dir), | |
53 """ | |
54 import os | |
55 import shutil | |
56 import sys | |
57 if os.path.exists(sys.argv[2]): | |
58 shutil.rmtree(sys.argv[2]) | |
59 shutil.move(sys.argv[1], sys.argv[2])""", | |
60 args=[src_dir, dst_dir]) | |
61 | |
62 | |
63 def ConfigureChromiumBuilder(api, recipe_config): | |
64 api.chromium.set_config(recipe_config['chromium_config'], | |
65 **recipe_config.get('chromium_config_kwargs', | |
66 {'BUILD_CONFIG': 'Release'})) | |
67 api.gclient.set_config(recipe_config['gclient_config'], | |
68 **recipe_config.get('gclient_config_kwargs', {})) | |
69 | |
70 api.chromium.cleanup_temp() | |
71 | |
72 # Checkout chromium. | |
73 api.bot_update.ensure_checkout(force=True) | |
74 | |
75 | |
76 def ConfigureAndroidBuilder(api, recipe_config): | |
77 kwargs = { | |
78 'REPO_NAME': 'src', | |
79 'REPO_URL': 'https://chromium.googlesource.com/chromium/src.git', | |
80 'Internal': False, | |
81 } | |
82 kwargs.update(recipe_config.get('chromium_config_kwargs', | |
83 {'BUILD_CONFIG': 'Release'})) | |
84 | |
85 api.chromium_android.configure_from_properties( | |
86 'base_config', **kwargs) | |
87 api.chromium.set_config('base_config', **kwargs) | |
88 api.chromium.apply_config(recipe_config['chromium_config']) | |
89 | |
90 def RunSteps(api): | |
91 buildername = api.properties['buildername'] | |
92 recipe_config = DETERMINISTIC_BUILDERS[buildername] | |
93 enable_isolate = True | |
94 | |
95 targets = recipe_config.get('targets', ['chromium_swarm_tests']) | |
96 if recipe_config.get('chromium_config_kwargs'): | |
97 target_platform = recipe_config['chromium_config_kwargs'].get( | |
98 'TARGET_PLATFORM') | |
99 else: | |
100 target_platform = recipe_config.get('platform') | |
101 | |
102 if target_platform in ('linux', 'mac', 'win'): | |
103 ConfigureChromiumBuilder(api, recipe_config) | |
104 elif target_platform is 'android': | |
105 # Disable the tests isolation on Android as it's not supported yet. | |
106 enable_isolate = False | |
107 ConfigureAndroidBuilder(api, recipe_config) | |
108 api.chromium_android.init_and_sync() | |
109 | |
110 if enable_isolate: | |
111 # Enable test isolation. Modifies GYP_DEFINES used in 'runhooks' below. | |
112 api.isolate.set_isolate_environment(api.chromium.c) | |
113 | |
114 # Do a first build and move the build artifact to the temp directory. | |
115 api.chromium.runhooks() | |
116 api.chromium.compile(targets, force_clobber=True, name='First build') | |
117 api.isolate.remove_build_metadata() | |
118 if enable_isolate: | |
119 # This archives the results and regenerate the .isolated files. | |
120 api.isolate.isolate_tests(api.chromium.output_dir) | |
121 MoveBuildDirectory(api, str(api.chromium.output_dir), | |
122 str(api.chromium.output_dir).rstrip('\\/') + '.1') | |
123 | |
124 # Do the second build and move the build artifact to the temp directory. | |
125 api.chromium.runhooks() | |
126 api.chromium.compile(targets, force_clobber=True, name='Second build') | |
127 api.isolate.remove_build_metadata() | |
128 if enable_isolate: | |
129 # This should be quick if the build is indeed deterministic. | |
130 api.isolate.isolate_tests(api.chromium.output_dir) | |
131 MoveBuildDirectory(api, str(api.chromium.output_dir), | |
132 str(api.chromium.output_dir).rstrip('\\/') + '.2') | |
133 | |
134 # Compare the artifacts from the 2 builds, raise an exception if they're | |
135 # not equals. | |
136 api.isolate.compare_build_artifacts( | |
137 str(api.chromium.output_dir).rstrip('\\/') + '.1', | |
138 str(api.chromium.output_dir).rstrip('\\/') + '.2') | |
139 | |
140 | |
141 def _sanitize_nonalpha(text): | |
142 return ''.join(c if c.isalnum() else '_' for c in text) | |
143 | |
144 | |
145 def GenTests(api): | |
146 mastername = 'chromium.swarm' | |
147 for buildername in DETERMINISTIC_BUILDERS: | |
148 test_name = 'full_%s_%s' % (_sanitize_nonalpha(mastername), | |
149 _sanitize_nonalpha(buildername)) | |
150 yield ( | |
151 api.test(test_name) + | |
152 api.properties.scheduled() + | |
153 api.properties.generic(buildername=buildername, | |
154 mastername=mastername) + | |
155 api.platform(DETERMINISTIC_BUILDERS[buildername]['platform'], 32) + | |
156 api.properties(configuration='Release') + | |
157 api.step_data('remove_build_metadata', retcode=1) | |
158 ) | |
OLD | NEW |