Skip to content

[lldb] Fix TestPlaygrounds.py when running on-device #1773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions lldb/test/API/lang/swift/playgrounds/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
EXE = PlaygroundStub
SWIFT_SOURCES = PlaygroundStub.swift

# The setup here is complex. We want to build the file with a deployment target
# earlier than the availability set in the source file. This is made slightly
# more complex by watchOS having misaligned version numbers.
ifeq ($(TRIPLE),)
ARCH_SWIFTFLAGS := -target x86_64-apple-macosx10.10
else
ARCH_SWIFTFLAGS := -target $(shell echo $(TRIPLE) | sed 's/os[0-9.]*/os7.0/' | sed 's/watchos7.0/watchos5.0/')
endif

# The deployment target we set is pre-ABI stability. The Swift driver will not
# point the RPATH at the system library. Do it manually.
LD_EXTRAS := -Xlinker -rpath -Xlinker /usr/lib/swift
Expand Down
44 changes: 37 additions & 7 deletions lldb/test/API/lang/swift/playgrounds/TestPlaygrounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
import os.path
import platform
import unittest2
from lldbsuite.test.builders.darwin import get_triple

import sys
if sys.version_info.major == 2:
import commands as subprocess
else:
import subprocess


def execute_command(command):
(exit_status, output) = subprocess.getstatusoutput(command)
return exit_status
Expand All @@ -37,12 +39,42 @@ class TestSwiftPlaygrounds(TestBase):

mydir = TestBase.compute_mydir(__file__)

def get_build_triple(self):
"""We want to build the file with a deployment target earlier than the
availability set in the source file."""
if lldb.remote_platform:
arch = self.getArchitecture()
vendor, os, version, _ = get_triple()
# This is made slightly more complex by watchOS having misaligned
# version numbers.
if os == 'watchos':
version = '5.0'
else:
version = '7.0'
triple = '{}-{}-{}{}'.format(arch, vendor, os, version)
else:
triple = 'x86_64-apple-macosx10.10'
return triple

def get_run_triple(self):
if lldb.remote_platform:
arch = self.getArchitecture()
vendor, os, version, _ = get_triple()
triple = '{}-{}-{}{}'.format(arch, vendor, os, version)
else:
version, _, machine = platform.mac_ver()
triple = '{}-apple-macosx{}'.format(machine, version)
return triple

@skipUnlessDarwin
@swiftTest
@skipIf(debug_info=decorators.no_match("dsym"))
def test_cross_module_extension(self):
"""Test that playgrounds work"""
self.build()
self.build(dictionary={
'ARCH_SWIFTFLAGS':
'-target {}'.format(self.get_build_triple()),
})
self.do_test(True)
self.do_test(False)

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

# Create the target
if force_target:
# FIXME: Construct the triple for remote runs.
version, _, machine = platform.mac_ver()
triple = '%s-apple-macosx%s' % (machine, version)
target = self.dbg.CreateTargetWithFileAndArch(exe, str(triple))
target = self.dbg.CreateTargetWithFileAndArch(
exe, self.get_run_triple())
else:
target = self.dbg.CreateTarget(exe)

self.assertTrue(target, VALID_TARGET)
self.registerSharedLibrariesWithTarget(target, ['libPlaygroundsRuntime.dylib'])
self.registerSharedLibrariesWithTarget(target,
['libPlaygroundsRuntime.dylib'])

# Set the breakpoints
breakpoint = target.BreakpointCreateBySourceRegex(
Expand Down Expand Up @@ -108,4 +139,3 @@ def do_test(self, force_target):
self.assertTrue("b=\\'5\\'" in playground_output)
self.assertTrue("=\\'8\\'" in playground_output)
self.assertTrue("=\\'11\\'" in playground_output)