| Index: test/win/gyptest-link_aslr.py
|
| diff --git a/test/win/gyptest-link_aslr.py b/test/win/gyptest-link_aslr.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..138e97a7d4df092dce3a698ac175b77a1a0cecd2
|
| --- /dev/null
|
| +++ b/test/win/gyptest-link_aslr.py
|
| @@ -0,0 +1,54 @@
|
| +#!/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 aslr setting is extracted properly.
|
| +"""
|
| +
|
| +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('aslr.gyp', chdir=CHDIR)
|
| + test.build('aslr.gyp', test.ALL, chdir=CHDIR)
|
| +
|
| + exe_path = test.built_file_path('test_aslr_yes.exe', chdir=CHDIR)
|
| + pe = pefile.PE(exe_path, fast_load=True)
|
| + pe.parse_data_directories(directories=[
|
| + pefile.DIRECTORY_ENTRY['IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG']])
|
| + DYNAMICBASE_FLAG = 0x0040
|
| + if not (pe.OPTIONAL_HEADER.DllCharacteristics & DYNAMICBASE_FLAG):
|
| + print 'DYNAMICBASE not found.'
|
| + test.fail_test()
|
| +
|
| +
|
| + if test.format == 'ninja':
|
| + ninja_file = test.built_file_path('obj/test_aslr_default.ninja',
|
| + chdir=CHDIR)
|
| + test.must_not_contain(ninja_file, '/DYNAMICBASE')
|
| +
|
| + ninja_file = test.built_file_path('obj/test_aslr_no.ninja', chdir=CHDIR)
|
| + test.must_contain(ninja_file, '/DYNAMICBASE:NO')
|
| +
|
| + ninja_file = test.built_file_path('obj/test_aslr_yes.ninja', chdir=CHDIR)
|
| + test.must_contain(ninja_file, '/DYNAMICBASE')
|
| + test.must_not_contain(ninja_file, '/DYNAMICBASE:NO')
|
| +
|
| + test.pass_test()
|
|
|