OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 # | 3 # |
4 # Use of this source code is governed by a BSD-style license | 4 # Use of this source code is governed by a BSD-style license |
5 # that can be found in the LICENSE file in the root of the source | 5 # that can be found in the LICENSE file in the root of the source |
6 # tree. An additional intellectual property rights grant can be found | 6 # tree. An additional intellectual property rights grant can be found |
7 # in the file PATENTS. All contributing project authors may | 7 # in the file PATENTS. All contributing project authors may |
8 # be found in the AUTHORS file in the root of the source tree. | 8 # be found in the AUTHORS file in the root of the source tree. |
9 | 9 |
10 """Tests for mb.py.""" | 10 """Tests for mb.py.""" |
11 | 11 |
12 import ast | 12 import ast |
13 import json | 13 import json |
14 import StringIO | 14 import StringIO |
15 import os | 15 import os |
16 import sys | 16 import sys |
17 import unittest | 17 import unittest |
18 | 18 |
19 import mb | 19 import mb |
20 | 20 |
21 | 21 |
22 class FakeMBW(mb.MetaBuildWrapper): | 22 class FakeMBW(mb.MetaBuildWrapper): |
23 def __init__(self, win32=False): | 23 def __init__(self, win32=False): |
24 super(FakeMBW, self).__init__() | 24 super(FakeMBW, self).__init__() |
25 | 25 |
26 # Override vars for test portability. | 26 # Override vars for test portability. |
27 if win32: | 27 if win32: |
28 self.chromium_src_dir = 'c:\\fake_src' | 28 self.chromium_src_dir = 'c:\\fake_src' |
29 self.default_config = 'c:\\fake_src\\tools\\mb\\mb_config.pyl' | 29 self.default_config = 'c:\\fake_src\\tools-webrtc\\mb\\mb_config.pyl' |
30 self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\' | 30 self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\' |
31 'gn_isolate_map.pyl') | 31 'gn_isolate_map.pyl') |
32 self.platform = 'win32' | 32 self.platform = 'win32' |
33 self.executable = 'c:\\python\\python.exe' | 33 self.executable = 'c:\\python\\python.exe' |
34 self.sep = '\\' | 34 self.sep = '\\' |
35 else: | 35 else: |
36 self.chromium_src_dir = '/fake_src' | 36 self.chromium_src_dir = '/fake_src' |
37 self.default_config = '/fake_src/tools/mb/mb_config.pyl' | 37 self.default_config = '/fake_src/tools-webrtc/mb/mb_config.pyl' |
38 self.default_isolate_map = '/fake_src/testing/buildbot/gn_isolate_map.pyl' | 38 self.default_isolate_map = '/fake_src/testing/buildbot/gn_isolate_map.pyl' |
39 self.executable = '/usr/bin/python' | 39 self.executable = '/usr/bin/python' |
40 self.platform = 'linux2' | 40 self.platform = 'linux2' |
41 self.sep = '/' | 41 self.sep = '/' |
42 | 42 |
43 self.files = {} | 43 self.files = {} |
44 self.calls = [] | 44 self.calls = [] |
45 self.cmds = [] | 45 self.cmds = [] |
46 self.cross_compile = None | 46 self.cross_compile = None |
47 self.out = '' | 47 self.out = '' |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 'memcheck': { | 169 'memcheck': { |
170 'gn_args': 'rtc_use_memcheck=true', | 170 'gn_args': 'rtc_use_memcheck=true', |
171 }, | 171 }, |
172 'android': { | 172 'android': { |
173 'gn_args': 'target_os="android"', | 173 'gn_args': 'target_os="android"', |
174 } | 174 } |
175 }, | 175 }, |
176 } | 176 } |
177 """ | 177 """ |
178 | 178 |
179 | |
180 TEST_BAD_CONFIG = """\ | |
181 { | |
182 'configs': { | |
183 'gn_rel_bot_1': ['gn', 'rel', 'chrome_with_codecs'], | |
184 'gn_rel_bot_2': ['gn', 'rel', 'bad_nested_config'], | |
185 }, | |
186 'masters': { | |
187 'chromium': { | |
188 'a': 'gn_rel_bot_1', | |
189 'b': 'gn_rel_bot_2', | |
190 }, | |
191 }, | |
192 'mixins': { | |
193 'gn': {'type': 'gn'}, | |
194 'chrome_with_codecs': { | |
195 'gn_args': 'proprietary_codecs=true', | |
196 }, | |
197 'bad_nested_config': { | |
198 'mixins': ['chrome_with_codecs'], | |
199 }, | |
200 'rel': { | |
201 'gn_args': 'is_debug=false', | |
202 }, | |
203 }, | |
204 } | |
205 """ | |
206 | |
207 | |
208 GYP_HACKS_CONFIG = """\ | 179 GYP_HACKS_CONFIG = """\ |
209 { | 180 { |
210 'masters': { | 181 'masters': { |
211 'chromium': {}, | 182 'chromium': {}, |
212 'fake_master': { | 183 'fake_master': { |
213 'fake_builder': 'fake_config', | 184 'fake_builder': 'fake_config', |
214 }, | 185 }, |
215 }, | 186 }, |
216 'configs': { | 187 'configs': { |
217 'fake_config': ['fake_mixin'], | 188 'fake_config': ['fake_mixin'], |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 self.assertIn('phase = 1', mbw.out) | 762 self.assertIn('phase = 1', mbw.out) |
792 | 763 |
793 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', | 764 mbw = self.check(['lookup', '-m', 'fake_master', '-b', 'fake_multi_phase', |
794 '--phase', 'phase_2'], ret=0) | 765 '--phase', 'phase_2'], ret=0) |
795 self.assertIn('phase = 2', mbw.out) | 766 self.assertIn('phase = 2', mbw.out) |
796 | 767 |
797 def test_validate(self): | 768 def test_validate(self): |
798 mbw = self.fake_mbw() | 769 mbw = self.fake_mbw() |
799 self.check(['validate'], mbw=mbw, ret=0) | 770 self.check(['validate'], mbw=mbw, ret=0) |
800 | 771 |
801 def test_bad_validate(self): | |
802 mbw = self.fake_mbw() | |
803 mbw.files[mbw.default_config] = TEST_BAD_CONFIG | |
804 self.check(['validate'], mbw=mbw, ret=1) | |
805 | |
806 def test_gyp_env_hacks(self): | 772 def test_gyp_env_hacks(self): |
807 mbw = self.fake_mbw() | 773 mbw = self.fake_mbw() |
808 mbw.files[mbw.default_config] = GYP_HACKS_CONFIG | 774 mbw.files[mbw.default_config] = GYP_HACKS_CONFIG |
809 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, | |
810 ret=0, | |
811 out=("GYP_DEFINES='foo=bar baz=1'\n" | |
812 "GYP_LINK_CONCURRENCY=1\n" | |
813 "LLVM_FORCE_HEAD_REVISION=1\n" | |
814 "python build/gyp_chromium -G output_dir=_path_\n")) | |
815 | |
816 | |
817 if __name__ == '__main__': | |
818 unittest.main() | |
819 | |
820 def test_validate(self): | |
821 mbw = self.fake_mbw() | |
822 self.check(['validate'], mbw=mbw, ret=0) | |
823 | |
824 def test_bad_validate(self): | |
825 mbw = self.fake_mbw() | |
826 mbw.files[mbw.default_config] = TEST_BAD_CONFIG | |
827 self.check(['validate'], mbw=mbw, ret=1) | |
828 | |
829 def test_gyp_env_hacks(self): | |
830 mbw = self.fake_mbw() | |
831 mbw.files[mbw.default_config] = GYP_HACKS_CONFIG | |
832 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, | 775 self.check(['lookup', '-c', 'fake_config'], mbw=mbw, |
833 ret=0, | 776 ret=0, |
834 out=("GYP_DEFINES='foo=bar baz=1'\n" | 777 out=("GYP_DEFINES='foo=bar baz=1'\n" |
835 "GYP_LINK_CONCURRENCY=1\n" | 778 "GYP_LINK_CONCURRENCY=1\n" |
836 "LLVM_FORCE_HEAD_REVISION=1\n" | 779 "LLVM_FORCE_HEAD_REVISION=1\n" |
837 "python build/gyp_chromium -G output_dir=_path_\n")) | 780 "python build/gyp_chromium -G output_dir=_path_\n")) |
838 | 781 |
839 | 782 |
840 if __name__ == '__main__': | 783 if __name__ == '__main__': |
841 unittest.main() | 784 unittest.main() |
OLD | NEW |