Skip to content

Commit 04d37ad

Browse files
committed
Modernize test and make it compatible with on-device testing
1 parent d270638 commit 04d37ad

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

lldb/packages/Python/lldbsuite/test/repl/cpp_exceptions/CppLib/Makefile

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
LEVEL = ../../make
2-
SRCDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
3-
CURDIR = $(shell pwd)
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS = -L$(BUILDDIR) -I$(BUILDDIR) -I$(SRCDIR) -lWrapper
3+
LD_EXTRAS = -Xlinker -rpath -Xlinker $(BUILDDIR)
44

5-
include $(LEVEL)/Makefile.rules
6-
7-
a.out: main.swift libCppLib.dylib libWrapper.dylib
8-
$(SWIFTC) $(SWIFTFLAGS) -Xlinker -rpath -Xlinker $(CURDIR) -I$(CURDIR) -lWrapper -L$(CURDIR) -o $@ $< \
9-
-toolchain-stdlib-rpath
10-
ifneq "$(CODESIGN)" ""
11-
$(CODESIGN) -s - "$@"
12-
endif
5+
all: libWrapper.dylib a.out
136

7+
include Makefile.rules
148

159
libCppLib.dylib: CppLib/CppLib.cpp
1610
mkdir -p CppLib
17-
$(MAKE) VPATH=$(VPATH) -f $(SRCDIR)/CppLib/Makefile
11+
$(MAKE) -f $(MAKEFILE_RULES) \
12+
DYLIB_NAME=CppLib DYLIB_ONLY=YES CXXFLAGS_EXTRAS=-fPIC \
13+
DYLIB_CXX_SOURCES="CppLib/CppLib.cpp CppLib/CppLibWrapper.cpp"
1814
install_name_tool -id $@ $@
1915

20-
libWrapper.dylib: wrapper.swift libCppLib.dylib
21-
$(SWIFTC) $(SWIFTFLAGS) -emit-module -emit-library -module-link-name Wrapper -module-name Wrapper -o $@ -L$(CURDIR) -lCppLib -I$(SRCDIR)/CppLib -o $@ -Xlinker -install_name -Xlinker @executable_path/$@ $< \
22-
-toolchain-stdlib-rpath
23-
ifneq "$(CODESIGN)" ""
24-
$(CODESIGN) -s - "$@"
25-
endif
26-
27-
clean::
28-
rm -rf *.swiftmodule *.swiftdoc *.dSYM *~ lib*.dylib a.out *.o
16+
libWrapper.dylib: libCppLib.dylib
17+
$(MAKE) -f $(MAKEFILE_RULES) \
18+
DYLIB_NAME=Wrapper DYLIB_SWIFT_SOURCES=wrapper.swift \
19+
SWIFTFLAGS_EXTRAS="-I$(SRCDIR) -L. -lCppLib -module-link-name Wrapper"

lldb/packages/Python/lldbsuite/test/repl/cpp_exceptions/TestCPPExceptionsInREPL.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def setUp(self):
4242
# Call super's setUp().
4343
TestBase.setUp(self)
4444

45+
@decorators.skipIfRemote
4546
def do_repl_test(self):
4647
sdk_root = swift.getSwiftSDKRoot()
4748
build_dir = self.getBuildDir()
@@ -54,6 +55,17 @@ def do_repl_test(self):
5455
self.assertTrue("I called it successfully" in stdoutdata, "Didn't call call_cpp successfully: out: \n%s\nerr: %s"%(stdoutdata, stderrdata))
5556

5657
def do_repl_mode_test(self):
58+
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
59+
self.assertTrue(target, VALID_TARGET)
60+
self.registerSharedLibrariesWithTarget(target, ['Wrapper'])
61+
62+
if lldb.remote_platform:
63+
wd = lldb.remote_platform.GetWorkingDirectory()
64+
filename = 'libCppLib.dylib'
65+
err = lldb.remote_platform.Put(
66+
lldb.SBFileSpec(self.getBuildArtifact(filename)),
67+
lldb.SBFileSpec(os.path.join(wd, filename)))
68+
self.assertFalse(err.Fail(), 'Failed to copy ' + filename)
5769
(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self,
5870
"Set a breakpoint here", self.main_source_file)
5971

0 commit comments

Comments
 (0)