| 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 Check target_rpath generator flag for ninja. |
| 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']) |
| 19 | 19 |
| 20 CHDIR = 'implicit-rpath' | 20 CHDIR = 'target-rpath' |
| 21 test.run_gyp('test.gyp', chdir=CHDIR) | 21 test.run_gyp('test.gyp', '-G', 'target_rpath=/usr/lib/gyptest/', 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 o = proc.communicate()[0] | 28 o = proc.communicate()[0] |
| 29 assert not proc.returncode | 29 assert not proc.returncode |
| 30 return r.findall(o) | 30 return r.findall(o) |
| 31 | 31 |
| 32 if test.format == 'ninja': | 32 expect = '/usr/lib/gyptest/' |
| 33 expect = '$ORIGIN/lib/' | |
| 34 elif test.format == 'make': | |
| 35 expect = '$ORIGIN/lib.target/' | |
| 36 else: | |
| 37 test.fail_test() | |
| 38 | 33 |
| 39 if GetRpaths('shared_executable') != [expect]: | 34 if GetRpaths('shared_executable') != [expect]: |
| 40 test.fail_test() | 35 test.fail_test() |
| 41 | 36 |
| 42 if GetRpaths('shared_executable_no_so_suffix') != [expect]: | 37 if GetRpaths('shared_executable_no_so_suffix') != [expect]: |
| 43 test.fail_test() | 38 test.fail_test() |
| 44 | 39 |
| 45 if GetRpaths('static_executable'): | 40 if GetRpaths('static_executable'): |
| 46 test.fail_test() | 41 test.fail_test() |
| 47 | 42 |
| 48 test.pass_test() | 43 test.pass_test() |
| OLD | NEW |