| OLD | NEW | 
|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python | 
| 2 | 2 | 
| 3 # Copyright (c) 2012 Google Inc. All rights reserved. | 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 | 4 # Use of this source code is governed by a BSD-style license that can be | 
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. | 
| 6 | 6 | 
| 7 """ | 7 """ | 
| 8 Verify that relinking a solib doesn't relink a dependent executable if the | 8 Verify that relinking a solib doesn't relink a dependent executable if the | 
| 9 solib's public API hasn't changed. | 9 solib's public API hasn't changed. | 
| 10 """ | 10 """ | 
| 11 | 11 | 
| 12 import os | 12 import os | 
| 13 import sys | 13 import sys | 
| 14 import TestGyp | 14 import TestGyp | 
| 15 | 15 | 
| 16 # NOTE(fischman): This test will not work with other generators because the | 16 # NOTE(fischman): This test will not work with other generators because the | 
| 17 # API-hash-based-mtime-preservation optimization is only implemented in | 17 # API-hash-based-mtime-preservation optimization is only implemented in | 
| 18 # ninja.py.  It could be extended to the make.py generator as well pretty | 18 # ninja.py.  It could be extended to the make.py generator as well pretty | 
| 19 # easily, probably. | 19 # easily, probably. | 
| 20 # (also, it tests ninja-specific out paths, which would have to be generalized | 20 # (also, it tests ninja-specific out paths, which would have to be generalized | 
| 21 # if this was extended to other generators). | 21 # if this was extended to other generators). | 
| 22 test = TestGyp.TestGyp(formats=['ninja']) | 22 test = TestGyp.TestGyp(formats=['ninja']) | 
| 23 | 23 | 
| 24 # The optimization being tested for is only implemented on linux. | 24 # The optimization being tested for is only implemented on linux and mac. | 
| 25 if sys.platform in ['win32', 'cygwin', 'darwin']: | 25 if sys.platform in ['win32', 'cygwin']: | 
| 26   test.pass_test() | 26   test.pass_test() | 
| 27   sys.exit(0) | 27   sys.exit(0) | 
| 28 | 28 | 
| 29 test.run_gyp('solibs_avoid_relinking.gyp') | 29 test.run_gyp('solibs_avoid_relinking.gyp') | 
| 30 | 30 | 
| 31 # Build the executable, grab its timestamp, touch the solib's source, rebuild | 31 # Build the executable, grab its timestamp, touch the solib's source, rebuild | 
| 32 # executable, ensure timestamp hasn't changed. | 32 # executable, ensure timestamp hasn't changed. | 
| 33 test.build('solibs_avoid_relinking.gyp', 'b') | 33 test.build('solibs_avoid_relinking.gyp', 'b') | 
| 34 test.built_file_must_exist('b') | 34 test.built_file_must_exist('b') | 
| 35 pre_stat = os.stat(test.built_file_path('b')) | 35 pre_stat = os.stat(test.built_file_path('b')) | 
| 36 os.utime(os.path.join(test.workdir, 'solib.cc'), | 36 os.utime(os.path.join(test.workdir, 'solib.cc'), | 
| 37          (pre_stat.st_atime, pre_stat.st_mtime + 100)) | 37          (pre_stat.st_atime, pre_stat.st_mtime + 100)) | 
| 38 test.sleep() | 38 test.sleep() | 
| 39 test.build('solibs_avoid_relinking.gyp', 'b') | 39 test.build('solibs_avoid_relinking.gyp', 'b') | 
| 40 post_stat = os.stat(test.built_file_path('b')) | 40 post_stat = os.stat(test.built_file_path('b')) | 
| 41 | 41 | 
| 42 if pre_stat.st_mtime != post_stat.st_mtime: | 42 if pre_stat.st_mtime != post_stat.st_mtime: | 
| 43   test.fail_test() | 43   test.fail_test() | 
| 44 else: | 44 else: | 
| 45   test.pass_test() | 45   test.pass_test() | 
| OLD | NEW | 
|---|