Home | History | Annotate | Download | only in win
      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 a .def file is handled in the link.
      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 
     20   # Multiple .def files doesn't make any sense, should fail at generate time.
     21   test.run_gyp('deffile-multiple.gyp', chdir=CHDIR, stderr=None, status=1)
     22 
     23   test.run_gyp('deffile.gyp', chdir=CHDIR)
     24   test.build('deffile.gyp', test.ALL, chdir=CHDIR)
     25 
     26   def HasExport(binary, export):
     27     full_path = test.built_file_path(binary, chdir=CHDIR)
     28     output = test.run_dumpbin('/exports', full_path)
     29     return export in output
     30 
     31   # Make sure we only have the export when the .def file is in use.
     32 
     33   if HasExport('test_deffile_dll_notexported.dll', 'AnExportedFunction'):
     34     test.fail_test()
     35   if not HasExport('test_deffile_dll_ok.dll', 'AnExportedFunction'):
     36     test.fail_test()
     37 
     38   if HasExport('test_deffile_exe_notexported.exe', 'AnExportedFunction'):
     39     test.fail_test()
     40   if not HasExport('test_deffile_exe_ok.exe', 'AnExportedFunction'):
     41     test.fail_test()
     42 
     43   test.pass_test()
     44