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