• 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  print "This test is currently disabled: https://crbug.com/483696."
20  sys.exit(0)
21
22  test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
23
24  CHDIR = 'installname'
25  test.run_gyp('test.gyp', chdir=CHDIR)
26
27  test.build('test.gyp', test.ALL, chdir=CHDIR)
28
29  def GetInstallname(p):
30    p = test.built_file_path(p, chdir=CHDIR)
31    r = re.compile(r'cmd LC_ID_DYLIB.*?name (.*?) \(offset \d+\)', re.DOTALL)
32    proc = subprocess.Popen(['otool', '-l', p], stdout=subprocess.PIPE)
33    o = proc.communicate()[0]
34    assert not proc.returncode
35    m = r.search(o)
36    assert m
37    return m.group(1)
38
39  if (GetInstallname('libdefault_installname.dylib') !=
40      '/usr/local/lib/libdefault_installname.dylib'):
41    test.fail_test()
42
43  if (GetInstallname('My Framework.framework/My Framework') !=
44      '/Library/Frameworks/My Framework.framework/'
45      'Versions/A/My Framework'):
46    test.fail_test()
47
48  if (GetInstallname('libexplicit_installname.dylib') !=
49      'Trapped in a dynamiclib factory'):
50    test.fail_test()
51
52  if (GetInstallname('libexplicit_installname_base.dylib') !=
53      '@executable_path/../../../libexplicit_installname_base.dylib'):
54    test.fail_test()
55
56  if (GetInstallname('My Other Framework.framework/My Other Framework') !=
57      '@executable_path/../../../My Other Framework.framework/'
58      'Versions/A/My Other Framework'):
59    test.fail_test()
60
61  if (GetInstallname('libexplicit_installname_with_base.dylib') !=
62      '/usr/local/lib/libexplicit_installname_with_base.dylib'):
63    test.fail_test()
64
65  if (GetInstallname('libexplicit_installname_with_explicit_base.dylib') !=
66      '@executable_path/../libexplicit_installname_with_explicit_base.dylib'):
67    test.fail_test()
68
69  if (GetInstallname('libboth_base_and_installname.dylib') !=
70      'Still trapped in a dynamiclib factory'):
71    test.fail_test()
72
73  if (GetInstallname('install_name_with_info_plist.framework/'
74                     'install_name_with_info_plist') !=
75      '/Library/Frameworks/install_name_with_info_plist.framework/'
76      'Versions/A/install_name_with_info_plist'):
77    test.fail_test()
78
79  if ('DYLIB_INSTALL_NAME_BASE:standardizepath: command not found' in
80          test.stdout()):
81    test.fail_test()
82
83  test.pass_test()
84