| Index: test/win/gyptest-link_additional_options.py
|
| diff --git a/test/win/gyptest-link_additional_options.py b/test/win/gyptest-link_additional_options.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d1f0c88bc78a3512d85939d7b978982f456db401
|
| --- /dev/null
|
| +++ b/test/win/gyptest-link_additional_options.py
|
| @@ -0,0 +1,61 @@
|
| +#!/usr/bin/env python
|
| +
|
| +# Copyright (c) 2012 Google Inc. All rights reserved.
|
| +# Use of this source code is governed by a BSD-style license that can be
|
| +# found in the LICENSE file.
|
| +
|
| +"""
|
| +Make sure additional options are handled.
|
| +"""
|
| +
|
| +import TestGyp
|
| +
|
| +import os
|
| +import subprocess
|
| +import sys
|
| +
|
| +# Find /third_party/pefile based on current directory and script path.
|
| +sys.path.append(os.path.join(
|
| + os.path.dirname(__file__), '..', '..', '..', '..', 'third_party', 'pefile'))
|
| +sys.path.append(os.path.join(
|
| + os.path.dirname(__file__), '..', '..', '..', '..', '..',
|
| + 'third_party', 'pefile'))
|
| +import pefile
|
| +
|
| +
|
| +if sys.platform == 'win32':
|
| + test = TestGyp.TestGyp(formats=['ninja', 'msvs'])
|
| +
|
| + CHDIR = 'linker_flags'
|
| + test.run_gyp('additional-options.gyp', chdir=CHDIR)
|
| + test.build('additional-options.gyp', test.ALL, chdir=CHDIR)
|
| +
|
| + # Confirm /safeseh made it to the final binary
|
| + exe_path = test.built_file_path('test_additional_few.exe', chdir=CHDIR)
|
| + pe = pefile.PE(exe_path, fast_load=True)
|
| + pe.parse_data_directories(directories=[
|
| + pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG']])
|
| + NO_SEH_FLAG = 0x0400
|
| + MACHINE_TYPE_AMD64 = 0x8664
|
| + if (pe.OPTIONAL_HEADER.DllCharacteristics & NO_SEH_FLAG or
|
| + (hasattr(pe, "DIRECTORY_ENTRY_LOAD_CONFIG") and
|
| + pe.DIRECTORY_ENTRY_LOAD_CONFIG.struct.SEHandlerCount > 0 and
|
| + pe.DIRECTORY_ENTRY_LOAD_CONFIG.struct.SEHandlerTable != 0) or
|
| + pe.FILE_HEADER.Machine == MACHINE_TYPE_AMD64):
|
| + pass
|
| + else:
|
| + print 'No /SAFESEH flag on %s.' % exe_path
|
| + test.fail_test()
|
| +
|
| +
|
| + if test.format == 'ninja':
|
| + ninja_file = test.built_file_path('obj/test_additional_none.ninja',
|
| + chdir=CHDIR)
|
| + # Just generates OK
|
| +
|
| + ninja_file = test.built_file_path('obj/test_additional_few.ninja',
|
| + chdir=CHDIR)
|
| + test.must_contain(ninja_file, '/safeseh')
|
| + test.must_contain(ninja_file, '/ignore:4199')
|
| +
|
| + test.pass_test()
|
|
|