1 #!/usr/bin/env python 2 3 # Copyright (c) 2013 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 LTCG is working properly. 9 """ 10 11 import TestGyp 12 13 import sys 14 15 if sys.platform == 'win32': 16 test = TestGyp.TestGyp(formats=['msvs', 'ninja']) 17 18 CHDIR = 'linker-flags' 19 test.run_gyp('ltcg.gyp', chdir=CHDIR) 20 21 # Here we expect LTCG is able to inline functions beyond compile unit. 22 # Note: This marker is embedded in 'inline_test_main.cc' 23 INLINE_MARKER = '==== inlined ====' 24 25 # link.exe generates following lines when LTCG is enabled. 26 # Note: Future link.exe may or may not generate them. Update as needed. 27 LTCG_LINKER_MESSAGES = ['Generating code', 'Finished generating code'] 28 29 # test 'LinkTimeCodeGenerationOptionDefault' 30 test.build('ltcg.gyp', 'test_ltcg_off', chdir=CHDIR) 31 test.run_built_executable('test_ltcg_off', chdir=CHDIR) 32 test.must_not_contain_any_line(test.stdout(), [INLINE_MARKER]) 33 34 # test 'LinkTimeCodeGenerationOptionUse' 35 test.build('ltcg.gyp', 'test_ltcg_on', chdir=CHDIR) 36 if test.format == 'ninja': 37 # Make sure ninja win_tool.py filters out noisy lines. 38 test.must_not_contain_any_line(test.stdout(), LTCG_LINKER_MESSAGES) 39 elif test.format == 'msvs': 40 test.must_contain_any_line(test.stdout(), LTCG_LINKER_MESSAGES) 41 test.run_built_executable('test_ltcg_on', chdir=CHDIR) 42 test.must_contain_any_line(test.stdout(), [INLINE_MARKER]) 43 44 test.pass_test() 45