OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2013 Google Inc. All rights reserved. | 3 # Copyright (c) 2013 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 Verifies that the implicit rpath is added only when needed. | 8 Verifies that the implicit rpath is added only when needed. |
9 """ | 9 """ |
10 | 10 |
11 import TestGyp | 11 import TestGyp |
12 | 12 |
13 import re | 13 import re |
14 import subprocess | 14 import subprocess |
15 import sys | 15 import sys |
16 | 16 |
17 if sys.platform.startswith('linux'): | 17 if sys.platform.startswith('linux'): |
18 test = TestGyp.TestGyp(formats=['ninja', 'make']) | 18 test = TestGyp.TestGyp(formats=['ninja', 'make']) |
19 | 19 |
20 CHDIR = 'implicit-rpath' | 20 CHDIR = 'implicit-rpath' |
21 test.run_gyp('test.gyp', chdir=CHDIR) | 21 test.run_gyp('test.gyp', chdir=CHDIR) |
22 test.build('test.gyp', test.ALL, chdir=CHDIR) | 22 test.build('test.gyp', test.ALL, chdir=CHDIR) |
23 | 23 |
24 def GetRpaths(p): | 24 def GetRpaths(p): |
25 p = test.built_file_path(p, chdir=CHDIR) | 25 p = test.built_file_path(p, chdir=CHDIR) |
26 r = re.compile(r'Library rpath: \[([^\]]+)\]') | 26 r = re.compile(r'Library rpath: \[([^\]]+)\]') |
27 proc = subprocess.Popen(['readelf', '-d', p], stdout=subprocess.PIPE) | 27 proc = subprocess.Popen(['readelf', '-d', p], stdout=subprocess.PIPE, |
| 28 universal_newlines=True) |
28 o = proc.communicate()[0] | 29 o = proc.communicate()[0] |
29 assert not proc.returncode | 30 assert not proc.returncode |
30 return r.findall(o) | 31 return r.findall(o) |
31 | 32 |
32 if test.format == 'ninja': | 33 if test.format == 'ninja': |
33 expect = '$ORIGIN/lib/' | 34 expect = '$ORIGIN/lib/' |
34 elif test.format == 'make': | 35 elif test.format == 'make': |
35 expect = '$ORIGIN/lib.target/' | 36 expect = '$ORIGIN/lib.target/' |
36 else: | 37 else: |
37 test.fail_test() | 38 test.fail_test() |
38 | 39 |
39 if GetRpaths('shared_executable') != [expect]: | 40 if GetRpaths('shared_executable') != [expect]: |
40 test.fail_test() | 41 test.fail_test() |
41 | 42 |
42 if GetRpaths('shared_executable_no_so_suffix') != [expect]: | 43 if GetRpaths('shared_executable_no_so_suffix') != [expect]: |
43 test.fail_test() | 44 test.fail_test() |
44 | 45 |
45 if GetRpaths('static_executable'): | 46 if GetRpaths('static_executable'): |
46 test.fail_test() | 47 test.fail_test() |
47 | 48 |
48 test.pass_test() | 49 test.pass_test() |
OLD | NEW |