OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2013 Google Inc. All rights reserved. | 3 # Copyright 2013 Google Inc. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """ | 7 """ |
8 Make sure the base address setting is extracted properly. | 8 Make sure the base address setting is extracted properly. |
9 """ | 9 """ |
10 | 10 |
11 import TestGyp | 11 import TestGyp |
12 | 12 |
13 import re | 13 import re |
14 import sys | 14 import sys |
15 | 15 |
16 if sys.platform == 'win32': | 16 if sys.platform == 'win32': |
17 test = TestGyp.TestGyp(formats=['msvs', 'ninja']) | 17 test = TestGyp.TestGyp(formats=['msvs', 'ninja']) |
18 | 18 |
19 CHDIR = 'linker-flags' | 19 CHDIR = 'linker-flags' |
20 test.run_gyp('base-address.gyp', chdir=CHDIR) | 20 test.run_gyp('base-address.gyp', chdir=CHDIR) |
21 test.build('base-address.gyp', test.ALL, chdir=CHDIR) | 21 test.build('base-address.gyp', test.ALL, chdir=CHDIR) |
22 | 22 |
23 def GetHeaders(exe): | 23 def GetHeaders(exe): |
24 full_path = test.built_file_path(exe, chdir=CHDIR) | 24 full_path = test.built_file_path(exe, chdir=CHDIR) |
25 return test.run_dumpbin('/headers', full_path) | 25 return test.run_dumpbin('/headers', full_path) |
26 | 26 |
27 # Extract the image base address from the headers output. | 27 # Extract the image base address from the headers output. |
28 image_base_reg_ex = re.compile('.*\s+([0-9]+) image base.*', re.DOTALL) | 28 image_base_reg_ex = re.compile(r'.*\s+([0-9]+) image base.*', re.DOTALL) |
29 | 29 |
30 exe_headers = GetHeaders('test_base_specified_exe.exe') | 30 exe_headers = GetHeaders('test_base_specified_exe.exe') |
31 exe_match = image_base_reg_ex.match(exe_headers) | 31 exe_match = image_base_reg_ex.match(exe_headers) |
32 | 32 |
33 if not exe_match or not exe_match.group(1): | 33 if not exe_match or not exe_match.group(1): |
34 test.fail_test() | 34 test.fail_test() |
35 if exe_match.group(1) != '420000': | 35 if exe_match.group(1) != '420000': |
36 test.fail_test() | 36 test.fail_test() |
37 | 37 |
38 dll_headers = GetHeaders('test_base_specified_dll.dll') | 38 dll_headers = GetHeaders('test_base_specified_dll.dll') |
(...skipping 14 matching lines...) Expand all Loading... |
53 | 53 |
54 default_dll_headers = GetHeaders('test_base_default_dll.dll') | 54 default_dll_headers = GetHeaders('test_base_default_dll.dll') |
55 default_dll_match = image_base_reg_ex.match(default_dll_headers) | 55 default_dll_match = image_base_reg_ex.match(default_dll_headers) |
56 | 56 |
57 if not default_dll_match or not default_dll_match.group(1): | 57 if not default_dll_match or not default_dll_match.group(1): |
58 test.fail_test() | 58 test.fail_test() |
59 if default_dll_match.group(1) != '10000000': | 59 if default_dll_match.group(1) != '10000000': |
60 test.fail_test() | 60 test.fail_test() |
61 | 61 |
62 test.pass_test() | 62 test.pass_test() |
OLD | NEW |