1#!/usr/bin/env python
2
3# Copyright (c) 2014 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"""
8Test VCCLCompilerTool EnableEnhancedInstructionSet setting.
9"""
10
11import TestGyp
12
13import os
14import sys
15
16if sys.platform == 'win32':
17  test = TestGyp.TestGyp()
18
19  CHDIR = 'compiler-flags'
20  test.run_gyp('enable-enhanced-instruction-set.gyp', chdir=CHDIR)
21
22  test.build('enable-enhanced-instruction-set.gyp', test.ALL, chdir=CHDIR)
23
24  test.run_built_executable('sse_extensions', chdir=CHDIR,
25                            stdout='/arch:SSE\n')
26  test.run_built_executable('sse2_extensions', chdir=CHDIR,
27                            stdout='/arch:SSE2\n')
28
29  # /arch:AVX introduced in VS2010, but MSBuild support lagged until 2012.
30  if os.path.exists(test.built_file_path('avx_extensions')):
31    test.run_built_executable('no_extensions', chdir=CHDIR,
32                              stdout='/arch:AVX\n')
33
34  # /arch:IA32 introduced in VS2012.
35  if os.path.exists(test.built_file_path('no_extensions')):
36    test.run_built_executable('no_extensions', chdir=CHDIR,
37                              stdout='/arch:IA32\n')
38
39  test.pass_test()
40