Skip to content

Commit 3bfa58f

Browse files
Merge pull request #3399 from adrian-prantl/test-cleanups
Test cleanups
2 parents 44d5b40 + 14fe0b3 commit 3bfa58f

File tree

6 files changed

+51
-38
lines changed

6 files changed

+51
-38
lines changed
Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
1-
all: a.out dlopen_module
1+
all: libNewerTarget.dylib a.out dlopen_module
2+
3+
SWIFT_SOURCES=main.swift
4+
SWIFTFLAGS_EXTRAS=-target x86_64-apple-macosx10.10 -Xfrontend -disable-target-os-checking -I$(BUILDDIR)
5+
LD_EXTRAS=-lNewerTarget -L$(BUILDDIR)
26

37
include Makefile.rules
48

59
# This test only works on macOS 10.11+.
610

711
a.out: main.swift libNewerTarget.dylib
8-
$(SWIFTC) -sdk "$(SWIFTSDKROOT)" -target x86_64-apple-macosx10.10 -g -Onone $^ -lNewerTarget -L$(shell pwd) -o $@ $(SWIFTFLAGS) -I$(shell pwd) -Xfrontend -disable-target-os-checking
9-
ifneq "$(CODESIGN)" ""
10-
$(CODESIGN) -s - "$@"
11-
endif
1212

13-
dlopen_module: main.m libNewerTarget.dylib
14-
$(CC) -framework Foundation $^ -mmacos-version-min=10.8 -o $@ $(CFLAGS)
15-
ifneq "$(CODESIGN)" ""
16-
$(CODESIGN) -s - "$@"
17-
endif
13+
dlopen_module: dlopen_module.m libNewerTarget.dylib
14+
$(MAKE) -f $(MAKEFILE_RULES) \
15+
CXX= \
16+
OBJC_SOURCES=dlopen_module.m \
17+
EXE=dlopen_module \
18+
LD_EXTRAS="-framework Foundation -mmacos-version-min=10.8"
1819

1920
lib%.dylib: %.swift
20-
$(SWIFTC) -sdk "$(SWIFTSDKROOT)" -target x86_64-apple-macosx10.11 -g -Onone $^ -emit-library -module-name $(shell basename $< .swift) -emit-module -Xlinker -install_name -Xlinker @executable_path/$@
21-
ifneq "$(CODESIGN)" ""
22-
$(CODESIGN) -s - "$@"
23-
endif
21+
$(MAKE) -f $(MAKEFILE_RULES) \
22+
DYLIB_ONLY=YES \
23+
DYLIB_NAME=$(patsubst lib%.dylib,%,$@) \
24+
DYLIB_SWIFT_SOURCES=$(patsubst lib%.dylib,%.swift,$@) \
25+
SWIFTFLAGS_EXTRAS="-target x86_64-apple-macosx10.11"
2426

2527
clean::
2628
rm -rf *.swiftmodule *.swiftdoc *.dSYM *~ lib*.dylib a.out dlopen_module *.o

lldb/test/API/lang/swift/deployment_target/TestSwiftDeploymentTarget.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ def test_swift_deployment_target(self):
4141
@skipIf(bugnumber="rdar://60396797", # should work but crashes.
4242
setting=('symbols.use-swift-clangimporter', 'false'))
4343
@skipUnlessDarwin
44-
@skipIfDarwinEmbedded # This test uses macOS triples explicitely.
44+
@skipIfDarwinEmbedded # This test uses macOS triples explicitly.
4545
@skipIf(macos_version=["<", "10.11"])
4646
@swiftTest
4747
def test_swift_deployment_target_dlopen(self):
4848
self.build()
49-
lldbutil.run_to_source_breakpoint(
50-
self, 'break here', lldb.SBFileSpec('NewerTarget.swift'),
51-
exe_name="dlopen_module")
49+
target, process, _, _, = lldbutil.run_to_name_breakpoint(
50+
self, 'main', exe_name="dlopen_module")
51+
bkpt = target.BreakpointCreateBySourceRegex(
52+
'break here', lldb.SBFileSpec('NewerTarget.swift'))
53+
lldbutil.continue_to_breakpoint(process, bkpt)
5254
self.expect("p self", substrs=['i = 23'])
5355

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <Foundation/Foundation.h>
2+
#include <dlfcn.h>
3+
#include <libgen.h>
4+
#include <limits.h>
5+
6+
@protocol FooProtocol
7+
- (void)f;
8+
@end
9+
10+
int main(int argc, const char **argv) {
11+
char dylib[PATH_MAX];
12+
strlcpy(dylib, dirname(argv[0]), PATH_MAX);
13+
strlcat(dylib, "/libNewerTarget.dylib", PATH_MAX);
14+
dlopen(dylib, RTLD_LAZY);
15+
Class<FooProtocol> fooClass = NSClassFromString(@"NewerTarget.Foo");
16+
[[[fooClass alloc] init] f];
17+
return 0;
18+
}

lldb/test/API/lang/swift/deployment_target/main.m

Lines changed: 0 additions & 14 deletions
This file was deleted.

lldb/test/API/lang/swift/late_dylib_clangdeps/loader.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
#include <dlfcn.h>
2+
#include <libgen.h>
3+
#include <limits.h>
24
#include <stdio.h>
35
#include <string.h>
4-
#include <libgen.h>
56

67
int main(int argc, const char **argv) {
7-
char *dylib_name = strcat(dirname(argv[0]),"/dylib.dylib");
8+
char dylib_name[PATH_MAX];
9+
strlcpy(dylib_name, dirname(argv[0]), PATH_MAX);
10+
strlcat(dylib_name, "/dylib.dylib", PATH_MAX);
811
void *dylib = dlopen(dylib_name, RTLD_NOW);
912
void (*f)() = dlsym(dylib, "f");
1013
f();

lldb/test/API/lang/swift/unit-tests/xctest.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include <dlfcn.h>
14+
#include <libgen.h>
15+
#include <limits.h>
1416
#include <stdio.h>
1517
#include <string.h>
16-
#include <libgen.h>
1718

18-
int main(int argc, const char **argv)
19-
{
20-
char *dylib = strcat(dirname(argv[0]),"/UnitTest.xctest/Contents/MacOS/test");
19+
int main(int argc, const char **argv) {
20+
char dylib[PATH_MAX];
21+
strlcpy(dylib, dirname(argv[0]), PATH_MAX);
22+
strlcat(dylib, "/UnitTest.xctest/Contents/MacOS/test", PATH_MAX);
2123
void *test_case = dlopen(dylib, RTLD_NOW);
2224

2325
printf("%p\n", test_case); // Set breakpoint here

0 commit comments

Comments
 (0)