1
- # TestSwiftStaticLinkingMacOS.py
2
- #
3
- # This source file is part of the Swift.org open source project
4
- #
5
- # Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
6
- # Licensed under Apache License v2.0 with Runtime Library Exception
7
- #
8
- # See https://swift.org/LICENSE.txt for license information
9
- # See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
- #
11
- # ------------------------------------------------------------------------------
12
1
"""
13
2
Test that macOS can statically link two separately-compiled Swift modules
14
3
with one Objective-C module, link them through the clang driver, and still
15
4
access debug info for each of the Swift modules.
16
5
"""
17
- from __future__ import print_function
18
-
19
-
20
6
# System imports
21
7
import os
22
8
@@ -35,67 +21,33 @@ class SwiftStaticLinkingMacOSTestCase(TestBase):
35
21
36
22
def expect_self_var_available_at_breakpoint (
37
23
self , process , breakpoint , module_name ):
38
- # Frame #0 should be at the given breakpoint
39
- threads = lldbutil .get_threads_stopped_at_breakpoint (
40
- process , breakpoint )
41
-
42
- self .assertEquals (1 , len (threads ))
43
-
44
24
patterns = [
45
25
# Ensure we report a self with an address.
46
- r"self\s* =\s*0x[0-9a-fA-F]+" ,
26
+ r"=\s*0x[0-9a-fA-F]+" ,
47
27
# Ensure we think it is an NSObject.
48
28
r"ObjectiveC.NSObject" ]
49
29
substrs = [
50
30
"(%s.%s)" % (module_name , module_name )
51
31
]
52
- self .expect ("frame variable self" , patterns = patterns ,
32
+ self .expect ("expr self" , patterns = patterns ,
53
33
substrs = substrs )
54
34
55
35
@skipUnlessDarwin
56
- @skipIf (bugnumber = "<rdar://problem/31066897>" )
57
36
def test_variables_print_from_both_swift_modules (self ):
58
37
"""Test that variables from two modules can be accessed."""
59
38
self .build ()
60
39
61
- # I could not find a reasonable way to say "skipUnless(archs=[])".
62
- # That would probably be worth adding.
63
- if self .getArchitecture () != 'x86_64' :
64
- self .skipTest ("This test requires x86_64 as the architecture "
65
- "for the inferior" )
66
-
67
- exe_name = "main"
68
- src_a = lldb .SBFileSpec ("A.swift" )
69
- line_a = 5
70
- src_b = lldb .SBFileSpec ("B.swift" )
71
- line_b = 5
72
- exe = self .getBuildArtifact (exe_name )
73
-
74
40
# Create the target
75
- target = self .dbg .CreateTarget (exe )
76
- self .assertTrue (target , lldbtest .VALID_TARGET )
77
-
78
- # Set the breakpoints
79
- # breakpoint_a = target.BreakpointCreateBySourceRegex(
80
- # 'Set breakpoint here', src_a)
81
- breakpoint_a = target .BreakpointCreateByLocation (
82
- src_a , line_a )
83
- self .assertTrue (breakpoint_a .GetNumLocations () > 0 ,
84
- lldbtest .VALID_BREAKPOINT )
41
+ target , process , _ , breakpoint_a = lldbutil .run_to_line_breakpoint (
42
+ self , lldb .SBFileSpec ("A.swift" ), 5 )
85
43
86
44
# breakpoint_b = target.BreakpointCreateBySourceRegex(
87
45
# 'Set breakpoint here', src_b)
88
46
breakpoint_b = target .BreakpointCreateByLocation (
89
- src_b , line_b )
47
+ lldb . SBFileSpec ( "B.swift" ), 5 )
90
48
self .assertTrue (breakpoint_b .GetNumLocations () > 0 ,
91
49
lldbtest .VALID_BREAKPOINT )
92
50
93
- # Launch the process, and do not stop at the entry point.
94
- envp = ['DYLD_FRAMEWORK_PATH=.' ]
95
- process = target .LaunchSimple (None , envp , os .getcwd ())
96
-
97
- self .assertTrue (process , lldbtest .PROCESS_IS_VALID )
98
-
99
51
# We should be at breakpoint in module A.
100
52
self .expect_self_var_available_at_breakpoint (
101
53
process , breakpoint_a , "A" )
0 commit comments