gyptest-link-deffile.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 a .def file is handled in the link.
  7. """
  8. import TestGyp
  9. import sys
  10. if sys.platform == 'win32':
  11. test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
  12. CHDIR = 'linker-flags'
  13. # Multiple .def files doesn't make any sense, should fail at generate time.
  14. test.run_gyp('deffile-multiple.gyp', chdir=CHDIR, stderr=None, status=1)
  15. test.run_gyp('deffile.gyp', chdir=CHDIR)
  16. test.build('deffile.gyp', test.ALL, chdir=CHDIR)
  17. def HasExport(binary, export):
  18. full_path = test.built_file_path(binary, chdir=CHDIR)
  19. output = test.run_dumpbin('/exports', full_path)
  20. return export in output
  21. # Make sure we only have the export when the .def file is in use.
  22. if HasExport('test_deffile_dll_notexported.dll', 'AnExportedFunction'):
  23. test.fail_test()
  24. if not HasExport('test_deffile_dll_ok.dll', 'AnExportedFunction'):
  25. test.fail_test()
  26. if HasExport('test_deffile_exe_notexported.exe', 'AnExportedFunction'):
  27. test.fail_test()
  28. if not HasExport('test_deffile_exe_ok.exe', 'AnExportedFunction'):
  29. test.fail_test()
  30. test.pass_test()