Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | |
| 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 |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | """ |
| 8 | Make sure optimization settings are extracted properly. |
| 9 | """ |
| 10 | |
| 11 | import TestGyp |
| 12 | |
| 13 | import sys |
| 14 | |
| 15 | if sys.platform == 'win32': |
| 16 | test = TestGyp.TestGyp(formats=['ninja']) |
| 17 | |
| 18 | CHDIR = 'compiler-flags' |
| 19 | test.run_gyp('optimizations.gyp', chdir=CHDIR) |
| 20 | |
| 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 |
| 23 | # contents. |
| 24 | |
| 25 | ninja_file = test.built_file_path('obj/test_opt_off.ninja', chdir=CHDIR) |
| 26 | test.must_contain(ninja_file, 'cflags = /Od') |
| 27 | |
| 28 | ninja_file = test.built_file_path('obj/test_opt_lev_size.ninja', chdir=CHDIR) |
| 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') |
| 36 | |
| 37 | ninja_file = test.built_file_path('obj/test_opt_unset.ninja', chdir=CHDIR) |
| 38 | test.must_not_contain(ninja_file, '/Od') |
| 39 | test.must_not_contain(ninja_file, '/O1') |
| 40 | test.must_not_contain(ninja_file, '/Ox') |
| 41 | # Set by default if none specified. |
| 42 | test.must_contain(ninja_file, '/O2') |
| 43 | |
| 44 | ninja_file = test.built_file_path('obj/test_opt_fpo.ninja', chdir=CHDIR) |
| 45 | test.must_contain(ninja_file, '/Oy') |
| 46 | test.must_not_contain(ninja_file, '/Oy-') |
| 47 | |
| 48 | ninja_file = test.built_file_path('obj/test_opt_fpo_off.ninja', chdir=CHDIR) |
| 49 | test.must_contain(ninja_file, '/Oy-') |
| 50 | |
| 51 | ninja_file = test.built_file_path('obj/test_opt_intrinsic.ninja', |
| 52 | chdir=CHDIR) |
| 53 | test.must_contain(ninja_file, '/Oi') |
| 54 | test.must_not_contain(ninja_file, '/Oi-') |
| 55 | |
| 56 | ninja_file = test.built_file_path('obj/test_opt_intrinsic_off.ninja', |
| 57 | chdir=CHDIR) |
| 58 | test.must_contain(ninja_file, '/Oi-') |
| 59 | |
| 60 | ninja_file = test.built_file_path('obj/test_opt_inline_off.ninja', |
| 61 | chdir=CHDIR) |
| 62 | test.must_contain(ninja_file, '/Ob0') |
| 63 | |
| 64 | ninja_file = test.built_file_path('obj/test_opt_inline_manual.ninja', |
| 65 | chdir=CHDIR) |
| 66 | test.must_contain(ninja_file, '/Ob1') |
| 67 | |
| 68 | ninja_file = test.built_file_path('obj/test_opt_inline_auto.ninja', |
| 69 | chdir=CHDIR) |
| 70 | test.must_contain(ninja_file, '/Ob2') |
| 71 | |
| 72 | ninja_file = test.built_file_path('obj/test_opt_neither.ninja', |
| 73 | chdir=CHDIR) |
| 74 | test.must_not_contain(ninja_file, '/Os') |
| 75 | test.must_not_contain(ninja_file, '/Ot') |
| 76 | |
| 77 | ninja_file = test.built_file_path('obj/test_opt_size.ninja', |
| 78 | chdir=CHDIR) |
| 79 | test.must_contain(ninja_file, '/Os') |
| 80 | |
| 81 | ninja_file = test.built_file_path('obj/test_opt_speed.ninja', |
| 82 | chdir=CHDIR) |
| 83 | test.must_contain(ninja_file, '/Ot') |
| 84 | |
| 85 | ninja_file = test.built_file_path('obj/test_opt_wpo.ninja', |
| 86 | chdir=CHDIR) |
| 87 | test.must_contain(ninja_file, '/GL') |
| 88 | |
| 89 | ninja_file = test.built_file_path('obj/test_opt_sp.ninja', |
| 90 | chdir=CHDIR) |
| 91 | test.must_contain(ninja_file, '/GF') |
| 92 | |
| 93 | ninja_file = test.built_file_path('obj/test_opt_sp_off.ninja', |
| 94 | chdir=CHDIR) |
| 95 | test.must_not_contain(ninja_file, '/GF') |
| 96 | |
| 97 | ninja_file = test.built_file_path('obj/test_opt_fso.ninja', |
| 98 | chdir=CHDIR) |
| 99 | test.must_contain(ninja_file, '/GT') |
| 100 | |
| 101 | ninja_file = test.built_file_path('obj/test_opt_fso_off.ninja', |
| 102 | chdir=CHDIR) |
| 103 | test.must_not_contain(ninja_file, '/GT') |
| 104 | |
| 105 | test.pass_test() |