Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame^] | 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 | """ |
| 8 | Verify that relinking a solib doesn't relink a dependent executable if the |
| 9 | solib's public API hasn't changed. |
| 10 | """ |
| 11 | |
| 12 | import os |
| 13 | import sys |
| 14 | import TestCommon |
| 15 | import TestGyp |
| 16 | |
| 17 | # NOTE(fischman): This test will not work with other generators because the |
| 18 | # API-hash-based-mtime-preservation optimization is only implemented in |
| 19 | # ninja.py. It could be extended to the make.py generator as well pretty |
| 20 | # easily, probably. |
| 21 | # (also, it tests ninja-specific out paths, which would have to be generalized |
| 22 | # if this was extended to other generators). |
| 23 | test = TestGyp.TestGyp(formats=['ninja']) |
| 24 | |
| 25 | if not os.environ.get('ProgramFiles(x86)'): |
| 26 | # TODO(scottmg) |
| 27 | print 'Skipping test on x86, http://crbug.com/365833' |
| 28 | test.pass_test() |
| 29 | |
| 30 | test.run_gyp('solibs_avoid_relinking.gyp') |
| 31 | |
| 32 | # Build the executable, grab its timestamp, touch the solib's source, rebuild |
| 33 | # executable, ensure timestamp hasn't changed. |
| 34 | test.build('solibs_avoid_relinking.gyp', 'b') |
| 35 | test.built_file_must_exist('b' + TestCommon.exe_suffix) |
| 36 | pre_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix)) |
| 37 | os.utime(os.path.join(test.workdir, 'solib.cc'), |
| 38 | (pre_stat.st_atime, pre_stat.st_mtime + 100)) |
| 39 | test.sleep() |
| 40 | test.build('solibs_avoid_relinking.gyp', 'b') |
| 41 | post_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix)) |
| 42 | |
| 43 | if pre_stat.st_mtime != post_stat.st_mtime: |
| 44 | test.fail_test() |
| 45 | else: |
| 46 | test.pass_test() |