OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 Google Inc. All rights reserved. | 3 # Copyright (c) 2012 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 optimization settings are extracted properly. | 8 Make sure optimization settings are extracted properly. |
9 """ | 9 """ |
10 | 10 |
11 import TestGyp | 11 import TestGyp |
12 | 12 |
13 import sys | 13 import sys |
14 | 14 |
15 if sys.platform == 'win32': | 15 if sys.platform == 'win32': |
16 test = TestGyp.TestGyp(formats=['ninja']) | 16 test = TestGyp.TestGyp(formats=['ninja']) |
17 | 17 |
18 CHDIR = 'compiler-flags' | 18 CHDIR = 'compiler-flags' |
19 test.run_gyp('optimizations.gyp', chdir=CHDIR) | 19 test.run_gyp('optimizations.gyp', chdir=CHDIR) |
20 | 20 |
21 # It's hard to map flags to output contents in a non-fragile way (especially | 21 # It's hard to map flags to output contents in a non-fragile way (especially |
22 # handling both 2008/2010), so just verify the correct ninja command line | 22 # handling both 2008/2010), so just verify the correct ninja command line |
23 # contents. | 23 # contents. |
24 | 24 |
25 ninja_file = test.built_file_path('obj/test_opt_off.ninja', chdir=CHDIR) | 25 ninja_file = test.built_file_path('obj/test_opt_off.ninja', chdir=CHDIR) |
26 test.must_contain(ninja_file, 'cflags = /Od') | 26 test.must_contain(ninja_file, 'cflags = /Od') |
27 | 27 |
28 ninja_file = test.built_file_path('obj/test_opt_level_s.ninja', chdir=CHDIR) | 28 ninja_file = test.built_file_path('obj/test_opt_lev_size.ninja', chdir=CHDIR) |
29 test.must_contain(ninja_file, 'cflags = /Os') | 29 test.must_contain(ninja_file, 'cflags = /O1') |
| 30 |
| 31 ninja_file = test.built_file_path('obj/test_opt_lev_speed.ninja', chdir=CHDIR) |
| 32 test.must_contain(ninja_file, 'cflags = /O2') |
| 33 |
| 34 ninja_file = test.built_file_path('obj/test_opt_lev_max.ninja', chdir=CHDIR) |
| 35 test.must_contain(ninja_file, 'cflags = /Ox') |
30 | 36 |
31 ninja_file = test.built_file_path('obj/test_opt_unset.ninja', chdir=CHDIR) | 37 ninja_file = test.built_file_path('obj/test_opt_unset.ninja', chdir=CHDIR) |
32 test.must_not_contain(ninja_file, '/Os') | 38 test.must_not_contain(ninja_file, '/Od') |
| 39 test.must_not_contain(ninja_file, '/O1') |
| 40 test.must_not_contain(ninja_file, '/O2') |
33 test.must_not_contain(ninja_file, '/Ox') | 41 test.must_not_contain(ninja_file, '/Ox') |
34 test.must_not_contain(ninja_file, '/Od') | |
35 | 42 |
36 ninja_file = test.built_file_path('obj/test_opt_fpo.ninja', chdir=CHDIR) | 43 ninja_file = test.built_file_path('obj/test_opt_fpo.ninja', chdir=CHDIR) |
37 test.must_contain(ninja_file, '/Oy') | 44 test.must_contain(ninja_file, '/Oy') |
38 test.must_not_contain(ninja_file, '/Oy-') | 45 test.must_not_contain(ninja_file, '/Oy-') |
39 | 46 |
40 ninja_file = test.built_file_path('obj/test_opt_fpo_off.ninja', chdir=CHDIR) | 47 ninja_file = test.built_file_path('obj/test_opt_fpo_off.ninja', chdir=CHDIR) |
41 test.must_contain(ninja_file, '/Oy-') | 48 test.must_contain(ninja_file, '/Oy-') |
42 | 49 |
43 ninja_file = test.built_file_path('obj/test_opt_inline_off.ninja', | 50 ninja_file = test.built_file_path('obj/test_opt_inline_off.ninja', |
44 chdir=CHDIR) | 51 chdir=CHDIR) |
45 test.must_contain(ninja_file, '/Ob0') | 52 test.must_contain(ninja_file, '/Ob0') |
46 | 53 |
47 ninja_file = test.built_file_path('obj/test_opt_inline_manual.ninja', | 54 ninja_file = test.built_file_path('obj/test_opt_inline_manual.ninja', |
48 chdir=CHDIR) | 55 chdir=CHDIR) |
49 test.must_contain(ninja_file, '/Ob1') | 56 test.must_contain(ninja_file, '/Ob1') |
50 | 57 |
51 ninja_file = test.built_file_path('obj/test_opt_inline_auto.ninja', | 58 ninja_file = test.built_file_path('obj/test_opt_inline_auto.ninja', |
52 chdir=CHDIR) | 59 chdir=CHDIR) |
53 test.must_contain(ninja_file, '/Ob2') | 60 test.must_contain(ninja_file, '/Ob2') |
54 | 61 |
| 62 ninja_file = test.built_file_path('obj/test_opt_neither.ninja', |
| 63 chdir=CHDIR) |
| 64 test.must_not_contain(ninja_file, '/Os') |
| 65 test.must_not_contain(ninja_file, '/Ot') |
| 66 |
55 ninja_file = test.built_file_path('obj/test_opt_size.ninja', | 67 ninja_file = test.built_file_path('obj/test_opt_size.ninja', |
56 chdir=CHDIR) | 68 chdir=CHDIR) |
57 test.must_contain(ninja_file, '/Os') | 69 test.must_contain(ninja_file, '/Os') |
58 | 70 |
59 ninja_file = test.built_file_path('obj/test_opt_speed.ninja', | 71 ninja_file = test.built_file_path('obj/test_opt_speed.ninja', |
60 chdir=CHDIR) | 72 chdir=CHDIR) |
61 test.must_contain(ninja_file, '/Ot') | 73 test.must_contain(ninja_file, '/Ot') |
62 | 74 |
63 ninja_file = test.built_file_path('obj/test_opt_wpo.ninja', | 75 ninja_file = test.built_file_path('obj/test_opt_wpo.ninja', |
64 chdir=CHDIR) | 76 chdir=CHDIR) |
65 test.must_contain(ninja_file, '/GL') | 77 test.must_contain(ninja_file, '/GL') |
66 | 78 |
67 test.pass_test() | 79 test.pass_test() |
OLD | NEW |