Skip to content
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

[lldb] Add an expression evaluation test for modules built with ... #9809

Open
wants to merge 1 commit into
base: stable/20240723
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lldb/test/API/lang/swift/enable_testing/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
SWIFT_SOURCES := main.swift

all: libPublic.dylib a.out

include Makefile.rules
LD_EXTRAS = -lPublic -L$(BUILDDIR)
SWIFTFLAGS_EXTRAS = -I$(BUILDDIR)

libPublic.dylib: Public.swift
"$(MAKE)" MAKE_DSYM=YES CC=$(CC) SWIFTC=$(SWIFTC) \
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
BASENAME=Public \
SWIFTFLAGS_EXTRAS="-I$(BUILDDIR) -enable-library-evolution -enable-testing" \
VPATH=$(SRCDIR) -I $(SRCDIR) \
DYLIB_ONLY:=YES DYLIB_NAME=Public \
DYLIB_SWIFT_SOURCES:=Public.swift \
-f $(MAKEFILE_RULES)

clean::

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is no longer required.

"$(MAKE)" BASENAME=Public VPATH=$(SRCDIR) -I $(SRCDIR) -f $(SRCDIR)/dylib.mk clean


15 changes: 15 additions & 0 deletions lldb/test/API/lang/swift/enable_testing/Public.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class SomeClass {
let value = 42
}

class ClassWithProperty {
private var v = SomeClass()

func f() {
print("break here")
}
}

public func entry() {
ClassWithProperty().f()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil


class TestSwiftEnableTesting(TestBase):

def setUp(self):
TestBase.setUp(self)

@swiftTest
def test(self):
"""Test that expression evaluation generates a direct member access to a private property in a module compiled with -enable-library-evolution and -enable-testing"""

self.build()
target, process, _, _ = lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("Public.swift"), extra_images=["Public"]
)

self.expect("expression v", substrs=["Public.SomeClass", "value = 42"])
3 changes: 3 additions & 0 deletions lldb/test/API/lang/swift/enable_testing/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Public

entry()