Home | History | Annotate | Download | only in win
      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 a relink is performed when a .def file is touched.
      9 """
     10 
     11 import TestGyp
     12 
     13 import sys
     14 
     15 if sys.platform == 'win32':
     16   print "This test is currently disabled: https://crbug.com/483696."
     17   sys.exit(0)
     18 
     19   test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
     20 
     21   CHDIR = 'linker-flags'
     22   target = 'test_deffile_dll_ok'
     23   def_contents = test.read('linker-flags/deffile.def')
     24 
     25   # This first build makes sure everything is up to date.
     26   test.run_gyp('deffile.gyp', chdir=CHDIR)
     27   test.build('deffile.gyp', target, chdir=CHDIR)
     28   test.up_to_date('deffile.gyp', target, chdir=CHDIR)
     29 
     30   def HasExport(binary, export):
     31     full_path = test.built_file_path(binary, chdir=CHDIR)
     32     output = test.run_dumpbin('/exports', full_path)
     33     return export in output
     34 
     35   # Verify that only one function is exported.
     36   if not HasExport('test_deffile_dll_ok.dll', 'AnExportedFunction'):
     37     test.fail_test()
     38   if HasExport('test_deffile_dll_ok.dll', 'AnotherExportedFunction'):
     39     test.fail_test()
     40 
     41   # Add AnotherExportedFunction to the def file, then rebuild.  If it doesn't
     42   # relink the DLL, then the subsequent check for AnotherExportedFunction will
     43   # fail.
     44   new_def_contents = def_contents + "\n    AnotherExportedFunction"
     45   test.write('linker-flags/deffile.def', new_def_contents)
     46   test.build('deffile.gyp', target, chdir=CHDIR)
     47   test.up_to_date('deffile.gyp', target, chdir=CHDIR)
     48 
     49   if not HasExport('test_deffile_dll_ok.dll', 'AnExportedFunction'):
     50     test.fail_test()
     51   if not HasExport('test_deffile_dll_ok.dll', 'AnotherExportedFunction'):
     52     test.fail_test()
     53 
     54   test.pass_test()
     55