Skip to content

Commit cd8287c

Browse files
authored
Merge pull request #2066 from fredriss/some-testsuite-improvements
apple-llvm-split-commit: e12ba79663f11b607853cafabf25f47963eebcc1 apple-llvm-split-dir: lldb/
2 parents cf64d6f + 766f30a commit cd8287c

File tree

8 files changed

+54
-62
lines changed

8 files changed

+54
-62
lines changed

lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/TestMTCSimple.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,12 @@ class MTCSimpleTestCase(TestBase):
1515
mydir = TestBase.compute_mydir(__file__)
1616

1717
@skipUnlessDarwin
18-
@skipIfDarwinEmbedded # Test file depends on AppKit which is not present on iOS etc.
1918
def test(self):
2019
self.mtc_dylib_path = findMainThreadCheckerDylib()
21-
if self.mtc_dylib_path == "":
22-
self.skipTest("This test requires libMainThreadChecker.dylib.")
23-
20+
self.assertTrue(self.mtc_dylib_path != "")
2421
self.build()
2522
self.mtc_tests()
2623

27-
def setUp(self):
28-
# Call super's setUp().
29-
TestBase.setUp(self)
30-
3124
@skipIf(archs=['i386'])
3225
def mtc_tests(self):
3326
# Load the test
@@ -41,7 +34,11 @@ def mtc_tests(self):
4134
thread = process.GetSelectedThread()
4235
frame = thread.GetSelectedFrame()
4336

44-
self.expect("thread info", substrs=['stop reason = -[NSView superview] must be used from main thread only'])
37+
view = "NSView" if lldbplatformutil.getPlatform() == "macosx" else "UIView"
38+
39+
self.expect("thread info",
40+
substrs=['stop reason = -[' + view +
41+
' superview] must be used from main thread only'])
4542

4643
self.expect(
4744
"thread info -s",
@@ -51,7 +48,7 @@ def mtc_tests(self):
5148
json_line = '\n'.join(output_lines[2:])
5249
data = json.loads(json_line)
5350
self.assertEqual(data["instrumentation_class"], "MainThreadChecker")
54-
self.assertEqual(data["api_name"], "-[NSView superview]")
55-
self.assertEqual(data["class_name"], "NSView")
51+
self.assertEqual(data["api_name"], "-[" + view + " superview]")
52+
self.assertEqual(data["class_name"], view)
5653
self.assertEqual(data["selector"], "superview")
57-
self.assertEqual(data["description"], "-[NSView superview] must be used from main thread only")
54+
self.assertEqual(data["description"], "-[" + view + " superview] must be used from main thread only")

lldb/packages/Python/lldbsuite/test/functionalities/mtc/simple/main.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
#import <Foundation/Foundation.h>
2+
#if __has_include(<AppKit/AppKit.h>)
23
#import <AppKit/AppKit.h>
4+
#define XXView NSView
5+
#else
6+
#import <UIKit/UIKit.h>
7+
#define XXView UIView
8+
#endif
39

410
int main() {
5-
NSView *view = [[NSView alloc] init];
11+
XXView *view = [[XXView alloc] init];
612
dispatch_group_t g = dispatch_group_create();
713
dispatch_group_enter(g);
814
[NSThread detachNewThreadWithBlock:^{

lldb/packages/Python/lldbsuite/test/lldbplatformutil.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# LLDB modules
1818
from . import configuration
1919
import lldb
20+
import lldbsuite.test.lldbplatform as lldbplatform
2021

2122

2223
def check_first_register_readable(test_case):
@@ -145,6 +146,9 @@ def findMainThreadCheckerDylib():
145146
if not platformIsDarwin():
146147
return ""
147148

149+
if getPlatform() in lldbplatform.translate(lldbplatform.darwin_embedded):
150+
return "/Developer/usr/lib/libMainThreadChecker.dylib"
151+
148152
with os.popen('xcode-select -p') as output:
149153
xcode_developer_path = output.read().strip()
150154
mtc_dylib_path = '%s/usr/lib/libMainThreadChecker.dylib' % xcode_developer_path
Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,16 @@
1-
include Makefile.rules
2-
3-
LIB_PREFIX := lib
4-
5-
ifeq "$(OS)" "Darwin"
6-
CFLAGS += -arch $(ARCH)
7-
DS := dsymutil
8-
LD_FLAGS := -dynamiclib
9-
LIB_INDIRECT := $(LIB_PREFIX)indirect.dylib
10-
LIB_REEXPORT := $(LIB_PREFIX)reexport.dylib
11-
EXEC_PATH := "@executable_path"
12-
EXEC_PATH_INDIRECT := -install_name $(EXEC_PATH)/$(LIB_INDIRECT)
13-
EXEC_PATH_REEXPORT := -install_name $(EXEC_PATH)/$(LIB_REEXPORT)
14-
endif
15-
16-
all: a.out $(LIB_INDIRECT) $(LIB_REEXPORT)
1+
C_SOURCES := main.c
2+
LD_EXTRAS := -L. -lindirect -lreexport
173

18-
a.out: main.o $(LIB_INDIRECT) $(LIB_REEXPORT)
19-
$(CC) $(CFLAGS) -o a.out main.o -L. $(LIB_INDIRECT) $(LIB_REEXPORT)
4+
.PHONY: build-libindirect build-libreepxoprt
5+
all: build-libindirect build-libreepxoprt a.out
206

21-
main.o: $(SRCDIR)/main.c
22-
$(CC) $(CFLAGS) -c $(SRCDIR)/main.c
23-
24-
$(LIB_INDIRECT): indirect.o
25-
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_INDIRECT) -o $(LIB_INDIRECT) indirect.o
26-
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_INDIRECT); fi
27-
28-
indirect.o: $(SRCDIR)/indirect.c
29-
$(CC) $(CFLAGS) -c $(SRCDIR)/indirect.c
7+
include Makefile.rules
308

31-
$(LIB_REEXPORT): reexport.o $(LIB_INDIRECT)
32-
$(CC) $(CFLAGS) $(LD_FLAGS) $(EXEC_PATH_REEXPORT) -o $(LIB_REEXPORT) reexport.o -L. -lindirect -Wl,-alias_list,$(SRCDIR)/alias.list
33-
if [ "$(OS)" = "Darwin" ]; then dsymutil $(LIB_REEXPORT); fi
9+
build-libindirect: indirect.c
10+
$(MAKE) -f $(MAKEFILE_RULES) \
11+
DYLIB_C_SOURCES=indirect.c DYLIB_NAME=indirect DYLIB_ONLY=YES
3412

35-
reexport.o: $(SRCDIR)/reexport.c
36-
$(CC) $(CFLAGS) -c $(SRCDIR)/reexport.c
37-
clean::
38-
rm -rf $(wildcard *.o *~ *.dylib *.so a.out *.dSYM)
13+
build-libreepxoprt: reexport.c
14+
$(MAKE) -f $(MAKEFILE_RULES) \
15+
DYLIB_C_SOURCES=reexport.c DYLIB_NAME=reexport DYLIB_ONLY=YES \
16+
LD_EXTRAS="-L. -lindirect -Wl,-alias_list,$(SRCDIR)/alias.list"

lldb/packages/Python/lldbsuite/test/macosx/indirect_symbol/TestIndirectSymbols.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def setUp(self):
2020
self.main_source = "main.c"
2121

2222
@skipUnlessDarwin
23+
@expectedFailureAll(oslist=no_match(["macosx"]), bugnumber="rdar://55952764")
2324
@add_test_categories(['pyapi'])
2425
def test_with_python_api(self):
2526
"""Test stepping and setting breakpoints in indirect and re-exported symbols."""
@@ -61,8 +62,7 @@ def test_with_python_api(self):
6162
# indirect function.
6263
thread.StepInto()
6364
curr_function = thread.GetFrameAtIndex(0).GetFunctionName()
64-
self.assertTrue(
65-
curr_function == "call_through_indirect_hidden",
65+
self.assertEqual(curr_function, "call_through_indirect_hidden",
6666
"Stepped into indirect symbols.")
6767

6868
# Now set a breakpoint using the indirect symbol name, and make sure we

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,9 @@ ifneq "$(DYLIB_NAME)" ""
746746
ifeq "$(DYLIB_ONLY)" ""
747747
$(EXE) : $(OBJECTS) $(ARCHIVE_NAME) $(DYLIB_FILENAME)
748748
$(LD) $(OBJECTS) $(ARCHIVE_NAME) -L. -l$(DYLIB_NAME) $(LDFLAGS) -o "$(EXE)"
749+
ifneq "$(CODESIGN)" ""
750+
$(CODESIGN) -s - "$(EXE)"
751+
endif
749752
else
750753
EXE = $(DYLIB_FILENAME)
751754
endif

lldb/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,19 @@ def test_with_process_launch_api(self):
7878
@expectedFailureNetBSD
7979
def test_with_attach_to_process_with_id_api(self):
8080
"""Create target, spawn a process, and attach to it with process id."""
81-
exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
81+
exe = '%s_%d'%(self.testMethodName, os.getpid())
8282
d = {'EXE': exe}
8383
self.build(dictionary=d)
8484
self.setTearDownCleanup(dictionary=d)
85-
target = self.dbg.CreateTarget(exe)
85+
target = self.dbg.CreateTarget(self.getBuildArtifact(exe))
8686

8787
# Spawn a new process
8888
token = exe+'.token'
89-
if os.path.exists(token):
90-
os.remove(token)
91-
popen = self.spawnSubprocess(exe, [token])
89+
if not lldb.remote_platform:
90+
token = self.getBuildArtifact(token)
91+
if os.path.exists(token):
92+
os.remove(token)
93+
popen = self.spawnSubprocess(self.getBuildArtifact(exe), [token])
9294
self.addTearDownHook(self.cleanupSubprocesses)
9395
lldbutil.wait_for_file_on_target(self, token)
9496

@@ -110,17 +112,19 @@ def test_with_attach_to_process_with_id_api(self):
110112
@expectedFailureNetBSD
111113
def test_with_attach_to_process_with_name_api(self):
112114
"""Create target, spawn a process, and attach to it with process name."""
113-
exe = '%s_%d'%(self.getBuildArtifact(self.testMethodName), os.getpid())
115+
exe = '%s_%d'%(self.testMethodName, os.getpid())
114116
d = {'EXE': exe}
115117
self.build(dictionary=d)
116118
self.setTearDownCleanup(dictionary=d)
117-
target = self.dbg.CreateTarget(exe)
119+
target = self.dbg.CreateTarget(self.getBuildArtifact(exe))
118120

119121
# Spawn a new process.
120122
token = exe+'.token'
121-
if os.path.exists(token):
122-
os.remove(token)
123-
popen = self.spawnSubprocess(exe, [token])
123+
if not lldb.remote_platform:
124+
token = self.getBuildArtifact(token)
125+
if os.path.exists(token):
126+
os.remove(token)
127+
popen = self.spawnSubprocess(self.getBuildArtifact(exe), [token])
124128
self.addTearDownHook(self.cleanupSubprocesses)
125129
lldbutil.wait_for_file_on_target(self, token)
126130

lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestAppleSimulatorOSType.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,21 +104,21 @@ def check_simulator_ostype(self, sdk, platform, arch='x86_64'):
104104

105105
@apple_simulator_test('iphone')
106106
@debugserver_test
107-
@skipIfDarwinEmbedded
107+
@skipIfRemote
108108
def test_simulator_ostype_ios(self):
109109
self.check_simulator_ostype(sdk='iphonesimulator',
110110
platform='ios')
111111

112112
@apple_simulator_test('appletv')
113113
@debugserver_test
114-
@skipIfDarwinEmbedded
114+
@skipIfRemote
115115
def test_simulator_ostype_tvos(self):
116116
self.check_simulator_ostype(sdk='appletvsimulator',
117117
platform='tvos')
118118

119119
@apple_simulator_test('watch')
120120
@debugserver_test
121-
@skipIfDarwinEmbedded
121+
@skipIfRemote
122122
def test_simulator_ostype_watchos(self):
123123
self.check_simulator_ostype(sdk='watchsimulator',
124124
platform='watchos', arch='i386')

0 commit comments

Comments
 (0)