19915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org#!/usr/bin/env python 29915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 39915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org# Copyright (c) 2012 Google Inc. All rights reserved. 49915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org# Use of this source code is governed by a BSD-style license that can be 59915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org# found in the LICENSE file. 69915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 79915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org""" 89915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.orgMake sure reference optimization setting is extracted properly. 99915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org""" 109915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 119915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.orgimport TestGyp 129915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 139915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.orgimport sys 149915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 159915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.orgif sys.platform == 'win32': 169915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test = TestGyp.TestGyp(formats=['msvs', 'ninja']) 179915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 189915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org CHDIR = 'linker-flags' 199915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test.run_gyp('opt-ref.gyp', chdir=CHDIR) 209915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test.build('opt-ref.gyp', chdir=CHDIR) 219915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 229915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org # We're specifying /DEBUG so the default is to not remove unused functions. 239915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org output = test.run_dumpbin( 249915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org '/disasm', test.built_file_path('test_optref_default.exe', chdir=CHDIR)) 259915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org if 'unused_function' not in output: 269915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test.fail_test() 279915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 289915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org # Explicitly off, unused_function preserved. 299915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org output = test.run_dumpbin( 309915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org '/disasm', test.built_file_path('test_optref_no.exe', chdir=CHDIR)) 319915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org if 'unused_function' not in output: 329915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test.fail_test() 339915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 349915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org # Explicitly on, should be removed. 359915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org output = test.run_dumpbin( 369915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org '/disasm', test.built_file_path('test_optref_yes.exe', chdir=CHDIR)) 379915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org if 'unused_function' in output: 389915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test.fail_test() 399915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org 409915ca1cff1734983a5fc4afb0cfd43b0e858c88scottmg@chromium.org test.pass_test() 41