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""" 8Make sure comdat folding optimization setting is extracted properly. 9""" 10 11import TestGyp 12 13import sys 14 15if sys.platform == 'win32': 16 test = TestGyp.TestGyp(formats=['msvs', 'ninja']) 17 18 CHDIR = 'linker-flags' 19 test.run_gyp('opt-icf.gyp', chdir=CHDIR) 20 test.build('opt-icf.gyp', chdir=CHDIR) 21 22 # We're specifying /DEBUG so the default is to not merge identical 23 # functions, so all of the similar_functions should be preserved. 24 output = test.run_dumpbin( 25 '/disasm', test.built_file_path('test_opticf_default.exe', chdir=CHDIR)) 26 if output.count('similar_function') != 6: # 3 definitions, 3 calls. 27 test.fail_test() 28 29 # Explicitly off, all functions preserved seperately. 30 output = test.run_dumpbin( 31 '/disasm', test.built_file_path('test_opticf_no.exe', chdir=CHDIR)) 32 if output.count('similar_function') != 6: # 3 definitions, 3 calls. 33 test.fail_test() 34 35 # Explicitly on, all but one removed. 36 output = test.run_dumpbin( 37 '/disasm', test.built_file_path('test_opticf_yes.exe', chdir=CHDIR)) 38 if output.count('similar_function') != 4: # 1 definition, 3 calls. 39 test.fail_test() 40 41 test.pass_test() 42