blob: cec0ea1870df9c5dda21e5eacd63a0e77b54810b [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/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"""
8Make sure a relink is performed when a .def file is touched.
9"""
10
11import TestGyp
12
13import sys
14
15if 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()