Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
27 changes: 27 additions & 0 deletions lldb/packages/Python/lldbsuite/test/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,33 @@ def is_not_swift_compatible(self):

return skipTestIfFn(is_not_swift_compatible)(func)

def skipEmbeddedSwift(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded == "swift_embedded":
return "not supported in embedded Swift"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipEmbeddedSwiftOnLinux(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded == "swift_embedded" and lldbplatformutil.getPlatform() == "linux":
return "not supported in embedded Swift on Linux"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipEmbeddedSwiftOnWindows(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded == "swift_embedded" and lldbplatformutil.getPlatform() == "windows":
return "not supported in embedded Swift on Windows"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipUnlessEmbeddedSwift(func):
def skip_fn(swift_embedded=None, **kwargs):
if swift_embedded != "swift_embedded":
return "Only supported in embedded Swift"
return None
return _skipForVariant("swift_embedded", skip_fn, func)

def skipIfHostIncompatibleWithTarget(func):
"""Decorate the item to skip tests when the host and target are incompatible."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ def did_crash(self, result):
error = self.get_stream_data(result)
print("Crash Error: {}".format(error))

@skipEmbeddedSwift
@swiftTest
def test_playgrounds(self):
# Build
Expand Down
19 changes: 19 additions & 0 deletions lldb/packages/Python/lldbsuite/test/lldbtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ def setUpClass(cls):
if not cls.mydir:
raise Exception("Subclasses must override the 'mydir' attribute.")

cls.extra_make_flags = {}

# Save old working directory.
cls.oldcwd = os.getcwd()

Expand Down Expand Up @@ -1539,6 +1541,8 @@ def build(
if command is None:
raise Exception("Don't know how to build binary")

command += [f"{k}={v}" for k, v in self.extra_make_flags.items()]

self.runBuildCommand(command)

def runBuildCommand(self, command):
Expand Down Expand Up @@ -1944,6 +1948,14 @@ def _swift_module_importer_setup(test_instance, variant_value):
elif variant_value == "clangimporter":
test_instance.runCmd("settings set symbols.use-swift-clangimporter true")

def _embedded_swift_setup(test_instance, variant_value):
if variant_value == "swift_embedded":
test_instance.extra_make_flags["SWIFT_EMBEDDED_MODE"] = "1"
elif variant_value == "swift":
test_instance.extra_make_flags["SWIFT_EMBEDDED_MODE"] = "0"
else:
assert False, f"Unknown variant: {variant_value}"


_test_variants = [
TestVariant(
Expand All @@ -1953,6 +1965,13 @@ def _swift_module_importer_setup(test_instance, variant_value):
setup_fn=_swift_module_importer_setup,
attrs_to_preserve=("debug_info",),
),
TestVariant(
name="swift_embedded",
values=test_categories.embedded_swift_categories,
predicate=lambda m: getattr(m, "__swift_test__", False),
setup_fn=_embedded_swift_setup,
attrs_to_preserve=("debug_info",),
),
]


Expand Down
7 changes: 7 additions & 0 deletions lldb/packages/Python/lldbsuite/test/test_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
"dwarfimporter": True,
}

embedded_swift_categories = {
"swift": True,
"swift_embedded": True,
}

all_categories = {
"basic_process": "Basic process execution sniff tests.",
"cmdline": "Tests related to the LLDB command-line interface",
Expand Down Expand Up @@ -56,6 +61,8 @@
"watchpoint": "Watchpoint-related tests",
"clangimporter": "Tests run with the Swift ClangImporter",
"dwarfimporter": "Tests run with the Swift DWARFImporter",
"swift_embedded": "Tests are compiled as embedded Swift",
"swift": "Tests are compiled as normal Swift",
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import lldbsuite.test.lldbutil as lldbutil

class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
@skipIfWindows # rdar://173245096
def test_swift_po_address(self):
Expand All @@ -21,6 +22,7 @@ def test_swift_po_address(self):
self.expect(f"dwim-print -O -- 0x{hex_addr}", patterns=[f"Object@0x0*{hex_addr}"])
self.expect(f"dwim-print -O -- {addr}", patterns=[f"Object@0x0*{hex_addr}"])

@skipEmbeddedSwift
@swiftTest
@skipIfWindows # rdar://173245096
def test_swift_po_non_address_hex(self):
Expand All @@ -31,6 +33,7 @@ def test_swift_po_non_address_hex(self):
)
self.expect(f"dwim-print -O -- 0x1000", substrs=["4096"])

@skipEmbeddedSwift
@swiftTest
@skipIfWindows # rdar://173245096
def test_print_swift_object_does_not_show_name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class TestCase(TestBase):
@swiftTest
@skipEmbeddedSwiftOnWindows
def test_enable_persistent_result(self):
"""Test explicitly enabling result variables persistence."""
self.build()
Expand All @@ -21,6 +22,7 @@ def test_enable_persistent_result(self):
self.expect("expression $R0", startstr="(Int) $R1 = 30")

@swiftTest
@skipEmbeddedSwiftOnWindows
def test_disable_persistent_result(self):
"""Test explicitly disabling persistent result variables."""
self.build()
Expand All @@ -32,6 +34,7 @@ def test_disable_persistent_result(self):
self.expect("expression $R0", error=True)

@swiftTest
@skipEmbeddedSwiftOnWindows
def test_expression_persists_result(self):
"""Test `expression`'s default behavior is to persist a result variable."""
self.build()
Expand All @@ -42,6 +45,7 @@ def test_expression_persists_result(self):
self.expect("expression $R0", startstr="(Int) $R1 = 30")

@swiftTest
@skipEmbeddedSwiftOnWindows
def test_p_does_not_persist_results(self):
"""Test `p` does not persist a result variable."""
self.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
@skipUnlessDarwin
def test_objc_self(self):
self.build()
lldbutil.run_to_source_breakpoint(self, "check self", lldb.SBFileSpec("main.swift"))
self.expect("frame variable _prop", startstr="(Int) _prop = 30")

@skipEmbeddedSwift
@swiftTest
@skipUnlessDarwin
def test_objc_self_capture_idiom(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class SwiftAddressExpressionTest(TestBase):
@swiftTest
@skipEmbeddedSwiftOnWindows
def test(self):
"""Test that you can use register names in image lookup in a swift frame."""
self.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class AsanSwiftTestCase(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
@skipIfLinux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@


class TestSwiftErrorBreakpoint(TestBase):
@skipEmbeddedSwift
@decorators.skipIfLinux # <rdar://problem/30909618>
@swiftTest
def test_swift_error_no_typename(self):
"""Tests that swift error throws are correctly caught by the Swift Error breakpoint"""
self.build()
self.do_tests(None)

@skipEmbeddedSwift
@swiftTest
def test_swift_error_matching_base_typename(self):
"""Tests that swift error throws are correctly caught by the Swift Error breakpoint"""
self.build()
self.do_tests("EnumError")

@skipEmbeddedSwift
@swiftTest
def test_swift_error_matching_full_typename(self):
"""Tests that swift error throws are correctly caught by the Swift Error breakpoint"""
self.build()
self.do_tests("a.EnumError")

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
def test_swift_error_bogus_typename(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
def test(self):
"""Test that a breakpoint on a property accessor can be set by name."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@


class PrintObjectArrayTestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessDarwin
def test_print_array(self):
"""Test that expr -O -Z works"""
self.build()
self.printarray_data_formatter_commands()

@skipEmbeddedSwift
@skipUnlessDarwin
def test_print_array_no_const(self):
"""Test that expr -O -Z works"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

class TestSwiftTypeAliasFormatters(TestBase):
@swiftTest
@skipEmbeddedSwiftOnWindows
def test_swift_type_alias_formatters(self):
"""Test that Swift typealiases get formatted properly"""
self.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
import lldbsuite.test.lldbinline as lldbinline
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest])
lldbinline.MakeInlineTest(__file__, globals(), decorators=[skipEmbeddedSwift, swiftTest])
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class TestCase(TestBase):
@swiftTest
@skipEmbeddedSwiftOnWindows
def test_swift_array_slice_formatters(self):
"""Test ArraySlice synthetic types."""
self.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class TestCase(TestBase):

@skipEmbeddedSwift
@swiftTest
@skipUnlessFoundation
def test(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessFoundation
@swiftTest
def test_swift_date_formatters(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessFoundation
@swiftTest
def test_swift_string_index_formatters(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


class TestCase(TestBase):
@skipEmbeddedSwift
@swiftTest
def test_swift_substring_formatters(self):
"""Test Subtring summary strings."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


class MTCSwiftPropertyTestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessDarwin
@swiftTest
def test(self):
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/functionalities/mtc/swift/TestSwiftMTC.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@


class MTCSwiftTestCase(TestBase):
@skipEmbeddedSwift
@skipUnlessDarwin
@swiftTest
def test(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def setUp(self):
self.listener = lldbutil.start_listening_from(self.broadcaster,
lldb.SBDebugger.eBroadcastBitProgress)

@skipEmbeddedSwift
# Don't run ClangImporter tests if Clangimporter is disabled.
@skipIf(setting=('symbols.use-swift-clangimporter', 'false'))
@skipUnlessDarwin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SwiftRuntimeReportingExclusivityViolationTestCase(lldbtest.TestBase):
mydir = lldbtest.TestBase.compute_mydir(__file__)

@decorators.swiftTest
@decorators.skipEmbeddedSwift
@decorators.skipIfLinux
@decorators.expectedFailureWindows
def test_swift_runtime_reporting(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TsanSwiftAccessRaceTestCase(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
@skipIfLinux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class TsanSwiftTestCase(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
@skipIfWindows
@skipIfLinux
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lldbsuite.test.lldbinline as lldbinline
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest])
lldbinline.MakeInlineTest(__file__, globals(), decorators=[skipEmbeddedSwift, swiftTest])
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def check_variable(self, name, is_reference, contents = 0):
self.assertSuccess(error)


@skipEmbeddedSwift
@swiftTest
def test(self):
self.build()
Expand Down
1 change: 1 addition & 0 deletions lldb/test/API/lang/swift/any/TestSwiftAnyType.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class TestSwiftAnyType(lldbtest.TestBase):

mydir = lldbtest.TestBase.compute_mydir(__file__)

@skipEmbeddedSwift
@swiftTest
def test_any_type(self):
"""Test the Any type"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

class TestSwiftAnyObjectType(TestBase):
@swiftTest
@skipEmbeddedSwiftOnWindows
def test_any_object_type(self):
"""Test the AnyObject type"""
self.build()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import lldbsuite.test.lldbinline as lldbinline
from lldbsuite.test.decorators import *

lldbinline.MakeInlineTest(__file__, globals(), decorators=[swiftTest])
lldbinline.MakeInlineTest(__file__, globals(), decorators=[skipEmbeddedSwift, swiftTest])
Loading