blob: 1b8e812eb228c4d7c5b920ca5ddd6a434bccb4b1 [file] [log] [blame]
Ben Murdoch097c5b22016-05-18 11:27:45 +01001#!/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"""
8Verify that relinking a solib doesn't relink a dependent executable if the
9solib's public API hasn't changed.
10"""
11
12import os
13import sys
14import TestCommon
15import 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).
23test = TestGyp.TestGyp(formats=['ninja'])
24
25if not os.environ.get('ProgramFiles(x86)'):
26 # TODO(scottmg)
27 print 'Skipping test on x86, http://crbug.com/365833'
28 test.pass_test()
29
30test.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.
34test.build('solibs_avoid_relinking.gyp', 'b')
35test.built_file_must_exist('b' + TestCommon.exe_suffix)
36pre_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix))
37os.utime(os.path.join(test.workdir, 'solib.cc'),
38 (pre_stat.st_atime, pre_stat.st_mtime + 100))
39test.sleep()
40test.build('solibs_avoid_relinking.gyp', 'b')
41post_stat = os.stat(test.built_file_path('b' + TestCommon.exe_suffix))
42
43if pre_stat.st_mtime != post_stat.st_mtime:
44 test.fail_test()
45else:
46 test.pass_test()