Skip to content

Commit 32ba33c

Browse files
authored
Merge pull request #1773 from JDevlieghere/fix-on-device-test-playgrounds.py
[lldb] Fix TestPlaygrounds.py when running on-device
2 parents 35d607e + 6fd586d commit 32ba33c

File tree

2 files changed

+37
-16
lines changed

2 files changed

+37
-16
lines changed

lldb/test/API/lang/swift/playgrounds/Makefile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
EXE = PlaygroundStub
22
SWIFT_SOURCES = PlaygroundStub.swift
33

4-
# The setup here is complex. We want to build the file with a deployment target
5-
# earlier than the availability set in the source file. This is made slightly
6-
# more complex by watchOS having misaligned version numbers.
7-
ifeq ($(TRIPLE),)
8-
ARCH_SWIFTFLAGS := -target x86_64-apple-macosx10.10
9-
else
10-
ARCH_SWIFTFLAGS := -target $(shell echo $(TRIPLE) | sed 's/os[0-9.]*/os7.0/' | sed 's/watchos7.0/watchos5.0/')
11-
endif
12-
134
# The deployment target we set is pre-ABI stability. The Swift driver will not
145
# point the RPATH at the system library. Do it manually.
156
LD_EXTRAS := -Xlinker -rpath -Xlinker /usr/lib/swift

lldb/test/API/lang/swift/playgrounds/TestPlaygrounds.py

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@
2121
import os.path
2222
import platform
2323
import unittest2
24+
from lldbsuite.test.builders.darwin import get_triple
2425

2526
import sys
2627
if sys.version_info.major == 2:
2728
import commands as subprocess
2829
else:
2930
import subprocess
3031

32+
3133
def execute_command(command):
3234
(exit_status, output) = subprocess.getstatusoutput(command)
3335
return exit_status
@@ -37,12 +39,42 @@ class TestSwiftPlaygrounds(TestBase):
3739

3840
mydir = TestBase.compute_mydir(__file__)
3941

42+
def get_build_triple(self):
43+
"""We want to build the file with a deployment target earlier than the
44+
availability set in the source file."""
45+
if lldb.remote_platform:
46+
arch = self.getArchitecture()
47+
vendor, os, version, _ = get_triple()
48+
# This is made slightly more complex by watchOS having misaligned
49+
# version numbers.
50+
if os == 'watchos':
51+
version = '5.0'
52+
else:
53+
version = '7.0'
54+
triple = '{}-{}-{}{}'.format(arch, vendor, os, version)
55+
else:
56+
triple = 'x86_64-apple-macosx10.10'
57+
return triple
58+
59+
def get_run_triple(self):
60+
if lldb.remote_platform:
61+
arch = self.getArchitecture()
62+
vendor, os, version, _ = get_triple()
63+
triple = '{}-{}-{}{}'.format(arch, vendor, os, version)
64+
else:
65+
version, _, machine = platform.mac_ver()
66+
triple = '{}-apple-macosx{}'.format(machine, version)
67+
return triple
68+
4069
@skipUnlessDarwin
4170
@swiftTest
4271
@skipIf(debug_info=decorators.no_match("dsym"))
4372
def test_cross_module_extension(self):
4473
"""Test that playgrounds work"""
45-
self.build()
74+
self.build(dictionary={
75+
'ARCH_SWIFTFLAGS':
76+
'-target {}'.format(self.get_build_triple()),
77+
})
4678
self.do_test(True)
4779
self.do_test(False)
4880

@@ -59,15 +91,14 @@ def do_test(self, force_target):
5991

6092
# Create the target
6193
if force_target:
62-
# FIXME: Construct the triple for remote runs.
63-
version, _, machine = platform.mac_ver()
64-
triple = '%s-apple-macosx%s' % (machine, version)
65-
target = self.dbg.CreateTargetWithFileAndArch(exe, str(triple))
94+
target = self.dbg.CreateTargetWithFileAndArch(
95+
exe, self.get_run_triple())
6696
else:
6797
target = self.dbg.CreateTarget(exe)
6898

6999
self.assertTrue(target, VALID_TARGET)
70-
self.registerSharedLibrariesWithTarget(target, ['libPlaygroundsRuntime.dylib'])
100+
self.registerSharedLibrariesWithTarget(target,
101+
['libPlaygroundsRuntime.dylib'])
71102

72103
# Set the breakpoints
73104
breakpoint = target.BreakpointCreateBySourceRegex(
@@ -108,4 +139,3 @@ def do_test(self, force_target):
108139
self.assertTrue("b=\\'5\\'" in playground_output)
109140
self.assertTrue("=\\'8\\'" in playground_output)
110141
self.assertTrue("=\\'11\\'" in playground_output)
111-

0 commit comments

Comments
 (0)