summaryrefslogtreecommitdiffstats
path: root/media/webrtc/trunk/tools/gyp/test/mac/gyptest-installname.py
blob: 3fc71522420a0d596c465c24508d9e6122b6fa4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python

# Copyright (c) 2012 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

"""
Verifies that LD_DYLIB_INSTALL_NAME and DYLIB_INSTALL_NAME_BASE are handled
correctly.
"""

import TestGyp

import re
import subprocess
import sys

if sys.platform == 'darwin':
  print "This test is currently disabled: https://crbug.com/483696."
  sys.exit(0)

  test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])

  CHDIR = 'installname'
  test.run_gyp('test.gyp', chdir=CHDIR)

  test.build('test.gyp', test.ALL, chdir=CHDIR)

  def GetInstallname(p):
    p = test.built_file_path(p, chdir=CHDIR)
    r = re.compile(r'cmd LC_ID_DYLIB.*?name (.*?) \(offset \d+\)', re.DOTALL)
    proc = subprocess.Popen(['otool', '-l', p], stdout=subprocess.PIPE)
    o = proc.communicate()[0]
    assert not proc.returncode
    m = r.search(o)
    assert m
    return m.group(1)

  if (GetInstallname('libdefault_installname.dylib') !=
      '/usr/local/lib/libdefault_installname.dylib'):
    test.fail_test()

  if (GetInstallname('My Framework.framework/My Framework') !=
      '/Library/Frameworks/My Framework.framework/'
      'Versions/A/My Framework'):
    test.fail_test()

  if (GetInstallname('libexplicit_installname.dylib') !=
      'Trapped in a dynamiclib factory'):
    test.fail_test()

  if (GetInstallname('libexplicit_installname_base.dylib') !=
      '@executable_path/../../../libexplicit_installname_base.dylib'):
    test.fail_test()

  if (GetInstallname('My Other Framework.framework/My Other Framework') !=
      '@executable_path/../../../My Other Framework.framework/'
      'Versions/A/My Other Framework'):
    test.fail_test()

  if (GetInstallname('libexplicit_installname_with_base.dylib') !=
      '/usr/local/lib/libexplicit_installname_with_base.dylib'):
    test.fail_test()

  if (GetInstallname('libexplicit_installname_with_explicit_base.dylib') !=
      '@executable_path/../libexplicit_installname_with_explicit_base.dylib'):
    test.fail_test()

  if (GetInstallname('libboth_base_and_installname.dylib') !=
      'Still trapped in a dynamiclib factory'):
    test.fail_test()

  if (GetInstallname('install_name_with_info_plist.framework/'
                     'install_name_with_info_plist') !=
      '/Library/Frameworks/install_name_with_info_plist.framework/'
      'Versions/A/install_name_with_info_plist'):
    test.fail_test()

  if ('DYLIB_INSTALL_NAME_BASE:standardizepath: command not found' in
          test.stdout()):
    test.fail_test()

  test.pass_test()