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"""
8Make sure nxcompat setting is extracted properly.
9"""
10
11import TestGyp
12
13import sys
14
15if sys.platform == 'win32':
16  test = TestGyp.TestGyp(formats=['msvs', 'ninja'])
17
18  CHDIR = 'linker-flags'
19  test.run_gyp('nxcompat.gyp', chdir=CHDIR)
20  test.build('nxcompat.gyp', test.ALL, chdir=CHDIR)
21
22  def GetHeaders(exe):
23    return test.run_dumpbin('/headers', test.built_file_path(exe, chdir=CHDIR))
24
25  # NXCOMPAT is on by default.
26  if 'NX compatible' not in GetHeaders('test_nxcompat_default.exe'):
27    test.fail_test()
28
29  # Explicitly off, should not be marked NX compatiable.
30  if 'NX compatible' in GetHeaders('test_nxcompat_no.exe'):
31    test.fail_test()
32
33  # Explicitly on.
34  if 'NX compatible' not in GetHeaders('test_nxcompat_yes.exe'):
35    test.fail_test()
36
37  test.pass_test()
38