Skip to content

Commit e50ea7d

Browse files
committed
[lldb-dap] Test gardening, enabling tests and improving doc comments.
A bit of test gardenining. Enabling tests that were marked as skipped as part of #137660. Fixed up some comments and doc comments and fixed some test helpers.
1 parent e8dff7b commit e50ea7d

36 files changed

+124
-212
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# System modules
22
from functools import wraps
3+
from typing import Optional
34
from packaging import version
45
import ctypes
56
import locale
@@ -1102,3 +1103,28 @@ def is_feature_enabled():
11021103
return "%s is not supported on this system." % feature
11031104

11041105
return skipTestIfFn(is_feature_enabled)
1106+
1107+
1108+
def skipIfBinaryToLarge(path: Optional[str], maxSize: int):
1109+
"""Skip the test if a binary is to large.
1110+
1111+
We skip this test for debug builds because it takes too long
1112+
parsing lldb's own debug info. Release builds are fine.
1113+
Checking the size of the lldb-dap binary seems to be a decent
1114+
proxy for a quick detection. It should be far less than 1 MB in
1115+
Release builds.
1116+
"""
1117+
1118+
def check_binary_size():
1119+
if not path or not os.path.exists(path):
1120+
return "invalid path"
1121+
1122+
try:
1123+
size = os.path.getsize(path)
1124+
if size <= maxSize:
1125+
return None
1126+
return f"binary {path} (size = {size} is to larger than {maxSize}"
1127+
except:
1128+
return f"failed to read size of {path}"
1129+
1130+
return skipTestIfFn(check_binary_size)

lldb/test/API/tools/lldb-dap/attach/TestDAP_attachByPortNum.py

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,16 @@
22
Test lldb-dap "port" configuration to "attach" request
33
"""
44

5-
import dap_server
65
from lldbsuite.test.decorators import *
76
from lldbsuite.test.lldbtest import *
8-
from lldbsuite.test import lldbutil
97
from lldbsuite.test import lldbplatformutil
108
from lldbgdbserverutils import Pipe
119
import lldbdap_testcase
12-
import os
13-
import shutil
14-
import subprocess
15-
import tempfile
16-
import threading
17-
import sys
18-
import socket
10+
import lldb
1911

2012

21-
@skip("https://github.com/llvm/llvm-project/issues/138803")
13+
@skip(bugnumber="https://github.com/llvm/llvm-project/issues/138803")
2214
class TestDAP_attachByPortNum(lldbdap_testcase.DAPTestCaseBase):
23-
default_timeout = 20
24-
2515
def set_and_hit_breakpoint(self, continueToExit=True):
2616
self.dap_server.wait_for_stopped()
2717

@@ -50,7 +40,7 @@ def get_debug_server_command_line_args(self):
5040
def get_debug_server_pipe(self):
5141
pipe = Pipe(self.getBuildDir())
5242
self.addTearDownHook(lambda: pipe.close())
53-
pipe.finish_connection(self.default_timeout)
43+
pipe.finish_connection(self.DEFAULT_TIMEOUT)
5444
return pipe
5545

5646
@skipIfWindows
@@ -73,28 +63,33 @@ def test_by_port(self):
7363
)
7464

7565
# Read the port number from the debug server pipe.
76-
port = pipe.read(10, self.default_timeout)
66+
port = pipe.read(10, self.DEFAULT_TIMEOUT)
7767
# Trim null byte, convert to int
7868
port = int(port[:-1])
7969
self.assertIsNotNone(
8070
port, " Failed to read the port number from debug server pipe"
8171
)
8272

83-
self.attach(program=program, gdbRemotePort=port, sourceInitFile=True)
73+
self.attach(
74+
program=program,
75+
gdbRemotePort=port,
76+
sourceInitFile=True,
77+
stopOnEntry=True,
78+
)
8479
self.set_and_hit_breakpoint(continueToExit=True)
85-
self.process.terminate()
8680

8781
@skipIfWindows
8882
@skipIfNetBSD
89-
def test_by_port_and_pid(self):
83+
def test_fails_if_both_port_and_pid_are_set(self):
9084
"""
9185
Tests attaching to a process by process ID and port number.
9286
"""
9387
program = self.build_and_create_debug_adapter_for_attach()
9488

95-
# It is not necessary to launch "lldb-server" to obtain the actual port and pid for attaching.
96-
# However, when providing the port number and pid directly, "lldb-dap" throws an error message, which is expected.
97-
# So, used random pid and port numbers here.
89+
# It is not necessary to launch "lldb-server" to obtain the actual port
90+
# and pid for attaching. However, when providing the port number and pid
91+
# directly, "lldb-dap" throws an error message, which is expected. So,
92+
# used random pid and port numbers here.
9893

9994
pid = 1354
10095
port = 1234
@@ -106,10 +101,9 @@ def test_by_port_and_pid(self):
106101
sourceInitFile=True,
107102
expectFailure=True,
108103
)
109-
if not (response and response["success"]):
110-
self.assertFalse(
111-
response["success"], "The user can't specify both pid and port"
112-
)
104+
self.assertFalse(
105+
response["success"], "The user can't specify both pid and port"
106+
)
113107

114108
@skipIfWindows
115109
@skipIfNetBSD
@@ -123,11 +117,10 @@ def test_by_invalid_port(self):
123117
response = self.attach(
124118
program=program, gdbRemotePort=port, sourceInitFile=True, expectFailure=True
125119
)
126-
if not (response and response["success"]):
127-
self.assertFalse(
128-
response["success"],
129-
"The user can't attach with invalid port (%s)" % port,
130-
)
120+
self.assertFalse(
121+
response["success"],
122+
"The user can't attach with invalid port (%s)" % port,
123+
)
131124

132125
@skipIfWindows
133126
@skipIfNetBSD
@@ -147,9 +140,7 @@ def test_by_illegal_port(self):
147140
response = self.attach(
148141
program=program, gdbRemotePort=port, sourceInitFile=True, expectFailure=True
149142
)
150-
if not (response and response["success"]):
151-
self.assertFalse(
152-
response["success"],
153-
"The user can't attach with illegal port (%s)" % port,
154-
)
155-
self.process.terminate()
143+
self.assertFalse(
144+
response["success"],
145+
"The user can't attach with illegal port (%s)" % port,
146+
)

lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import os
1313

1414

15-
@skip("Temporarily disable the breakpoint tests")
1615
class TestDAP_setBreakpoints(lldbdap_testcase.DAPTestCaseBase):
1716
def setUp(self):
1817
lldbdap_testcase.DAPTestCaseBase.setUp(self)

lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import lldbdap_testcase
1111

1212

13-
@skip("Temporarily disable the breakpoint tests")
1413
class TestDAP_setExceptionBreakpoints(lldbdap_testcase.DAPTestCaseBase):
1514
@skipIfWindows
1615
def test_functionality(self):

lldb/test/API/tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import lldbdap_testcase
1111

1212

13-
@skip("Temporarily disable the breakpoint tests")
1413
class TestDAP_setFunctionBreakpoints(lldbdap_testcase.DAPTestCaseBase):
1514
@skipIfWindows
1615
def test_set_and_clear(self):

lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Test lldb-dap cancel request
33
"""
44

5-
import time
6-
75
from lldbsuite.test.decorators import *
86
from lldbsuite.test.lldbtest import *
97
import lldbdap_testcase

lldb/test/API/tools/lldb-dap/console/TestDAP_console.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11
"""
2-
Test lldb-dap setBreakpoints request
2+
Test lldb-dap console output
33
"""
44

5-
import dap_server
65
import lldbdap_testcase
7-
from lldbsuite.test import lldbutil
86
from lldbsuite.test.decorators import *
97
from lldbsuite.test.lldbtest import *
108

119

12-
def get_subprocess(root_process, process_name):
13-
queue = [root_process]
14-
while queue:
15-
process = queue.pop()
16-
if process.name() == process_name:
17-
return process
18-
queue.extend(process.children())
19-
20-
self.assertTrue(False, "No subprocess with name %s found" % process_name)
10+
class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
11+
def get_subprocess(self, root_process, process_name):
12+
queue = [root_process]
13+
while queue:
14+
process = queue.pop()
15+
if process.name() == process_name:
16+
return process
17+
queue.extend(process.children())
2118

19+
self.assertTrue(False, "No subprocess with name %s found" % process_name)
2220

23-
class TestDAP_console(lldbdap_testcase.DAPTestCaseBase):
2421
def check_lldb_command(
2522
self, lldb_command, contains_string, assert_msg, command_escape_prefix="`"
2623
):
@@ -134,7 +131,7 @@ def test_exit_status_message_sigterm(self):
134131
file=sys.stderr,
135132
)
136133
return
137-
process = get_subprocess(psutil.Process(os.getpid()), process_name)
134+
process = self.get_subprocess(psutil.Process(os.getpid()), process_name)
138135
process.terminate()
139136
process.wait()
140137

lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
Test lldb-dap coreFile attaching
33
"""
44

5-
import dap_server
65
from lldbsuite.test.decorators import *
76
from lldbsuite.test.lldbtest import *
8-
from lldbsuite.test import lldbutil
97
import lldbdap_testcase
108
import os
119

lldb/test/API/tools/lldb-dap/databreakpoint/TestDAP_setDataBreakpoints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class TestDAP_setDataBreakpoints(lldbdap_testcase.DAPTestCaseBase):
1111
def setUp(self):
12-
lldbdap_testcase.DAPTestCaseBase.setUp(self)
12+
super().setUp()
1313
self.accessTypes = ["read", "write", "readWrite"]
1414

1515
@skipIfWindows

lldb/test/API/tools/lldb-dap/disassemble/TestDAP_disassemble.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
"""
44

55

6-
import dap_server
76
from lldbsuite.test.decorators import *
87
from lldbsuite.test.lldbtest import *
9-
from lldbsuite.test import lldbutil
108
import lldbdap_testcase
119
import os
1210

0 commit comments

Comments
 (0)