• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/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"""
8Verifies that LD_DYLIB_INSTALL_NAME and DYLIB_INSTALL_NAME_BASE are handled
9correctly.
10"""
11
12import TestGyp
13
14import re
15import subprocess
16import sys
17
18if sys.platform == 'darwin':
19  test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
20
21  CHDIR = 'rpath'
22  test.run_gyp('test.gyp', chdir=CHDIR)
23
24  test.build('test.gyp', test.ALL, chdir=CHDIR)
25
26  def GetRpaths(p):
27    p = test.built_file_path(p, chdir=CHDIR)
28    r = re.compile(r'cmd LC_RPATH.*?path (.*?) \(offset \d+\)', re.DOTALL)
29    proc = subprocess.Popen(['otool', '-l', p], stdout=subprocess.PIPE)
30    o = proc.communicate()[0]
31    assert not proc.returncode
32    return r.findall(o)
33
34  if GetRpaths('libdefault_rpath.dylib') != []:
35    test.fail_test()
36
37  if GetRpaths('libexplicit_rpath.dylib') != ['@executable_path/.']:
38    test.fail_test()
39
40  if (GetRpaths('libexplicit_rpaths_escaped.dylib') !=
41      ['First rpath', 'Second rpath']):
42    test.fail_test()
43
44  if GetRpaths('My Framework.framework/My Framework') != ['@loader_path/.']:
45    test.fail_test()
46
47  if GetRpaths('executable') != ['@executable_path/.']:
48    test.fail_test()
49
50  test.pass_test()
51