gyptest-link-opt-icf.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env python
  2. # Copyright (c) 2012 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """
  6. Make sure comdat folding optimization setting is extracted properly.
  7. """
  8. import TestGyp
  9. import sys
  10. if sys.platform == 'win32':
  11. test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
  12. CHDIR = 'linker-flags'
  13. test.run_gyp('opt-icf.gyp', chdir=CHDIR)
  14. test.build('opt-icf.gyp', chdir=CHDIR)
  15. # We're specifying /DEBUG so the default is to not merge identical
  16. # functions, so all of the similar_functions should be preserved.
  17. output = test.run_dumpbin(
  18. '/disasm', test.built_file_path('test_opticf_default.exe', chdir=CHDIR))
  19. if output.count('similar_function') != 6: # 3 definitions, 3 calls.
  20. test.fail_test()
  21. # Explicitly off, all functions preserved seperately.
  22. output = test.run_dumpbin(
  23. '/disasm', test.built_file_path('test_opticf_no.exe', chdir=CHDIR))
  24. if output.count('similar_function') != 6: # 3 definitions, 3 calls.
  25. test.fail_test()
  26. # Explicitly on, all but one removed.
  27. output = test.run_dumpbin(
  28. '/disasm', test.built_file_path('test_opticf_yes.exe', chdir=CHDIR))
  29. if output.count('similar_function') != 4: # 1 definition, 3 calls.
  30. test.fail_test()
  31. test.pass_test()