Skip to content

Commit 10d9770

Browse files
committed
Adding a skipIfBuildType helper to skip tests that may fail or be unstable in certain build configuraitons.
This revealed a number of tests that were unstable, so I also included fixes for those tests as well.
1 parent ad51c73 commit 10d9770

File tree

18 files changed

+85
-56
lines changed

18 files changed

+85
-56
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@
137137
# A plugin whose tests will be enabled, like intel-pt.
138138
enabled_plugins = []
139139

140+
# the build type of lldb
141+
# Typical values include Debug, Release, RelWithDebInfo and MinSizeRel
142+
cmake_build_type = None
140143

141144
def shouldSkipBecauseOfCategories(test_categories):
142145
if use_categories:

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

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,26 +1105,13 @@ def is_feature_enabled():
11051105
return skipTestIfFn(is_feature_enabled)
11061106

11071107

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}"
1108+
def skipIfBuildType(types: list[str]):
1109+
"""Skip tests if built in a specific CMAKE_BUILD_TYPE.
11291110
1130-
return skipTestIfFn(check_binary_size)
1111+
Supported types include 'Release', 'RelWithDebInfo', 'Debug', 'MinSizeRel'.
1112+
"""
1113+
types = [name.lower() for name in types]
1114+
return unittest.skipIf(
1115+
configuration.cmake_build_type.lower() in types,
1116+
"skip on {} build type(s)".format(", ".join(types)),
1117+
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def parseOptionsAndInitTestdirs():
297297
configuration.libcxx_include_dir = args.libcxx_include_dir
298298
configuration.libcxx_include_target_dir = args.libcxx_include_target_dir
299299
configuration.libcxx_library_dir = args.libcxx_library_dir
300+
configuration.cmake_build_type = args.cmake_build_type.lower()
300301

301302
if args.channels:
302303
lldbtest_config.channels = args.channels

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,12 @@ def create_parser():
300300
metavar="platform-available-ports",
301301
help="Ports available for connection to a lldb server on the remote platform",
302302
)
303+
group.add_argument(
304+
"--cmake-build-type",
305+
dest="cmake_build_type",
306+
metavar="cmake-build-type",
307+
help="Specifies the build type on single-configuration",
308+
)
303309

304310
# Test-suite behaviour
305311
group = parser.add_argument_group("Runtime behaviour options")

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def __init__(
164164
self.output: dict[str, list[str]] = {}
165165
self.configuration_done_sent = False
166166
self.initialized = False
167+
self.terminated = False
167168
self.frame_scopes = {}
168169
self.init_commands = init_commands
169170

@@ -271,6 +272,10 @@ def _handle_recv_packet(self, packet: Optional[ProtocolMessage]) -> bool:
271272
# When a new process is attached or launched, remember the
272273
# details that are available in the body of the event
273274
self.process_event_body = body
275+
elif event == "terminated":
276+
# If we get the 'terminated' event then lldb-dap has exited
277+
# itself.
278+
self.terminated = True
274279
elif event == "exited":
275280
# Process exited, mark the status to indicate the process is not
276281
# alive.
@@ -388,7 +393,7 @@ def send_recv(self, command):
388393
if response_or_request["command"] == "runInTerminal":
389394
subprocess.Popen(
390395
response_or_request["arguments"]["args"],
391-
env=response_or_request["arguments"]["env"],
396+
env=response_or_request["arguments"].get("env", {}),
392397
)
393398
self.send_packet(
394399
{
@@ -749,13 +754,11 @@ def request_restart(self, restartArguments=None):
749754
# Caller must still call wait_for_stopped.
750755
return response
751756

752-
def request_disconnect(self, terminateDebuggee=None):
753-
args_dict = {}
754-
if terminateDebuggee is not None:
755-
if terminateDebuggee:
756-
args_dict["terminateDebuggee"] = True
757-
else:
758-
args_dict["terminateDebuggee"] = False
757+
def request_disconnect(self, terminateDebuggee=False, suspendDebuggee=False):
758+
args_dict = {
759+
"terminateDebuggee": terminateDebuggee,
760+
"suspendDebuggee": suspendDebuggee,
761+
}
759762
command_dict = {
760763
"command": "disconnect",
761764
"type": "request",

lldb/test/API/lit.cfg.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,9 @@ def delete_module_cache(path):
271271
if is_configured("lldb_framework_dir"):
272272
dotest_cmd += ["--framework", config.lldb_framework_dir]
273273

274+
if is_configured("cmake_build_type"):
275+
dotest_cmd += ["--cmake-build-type", config.cmake_build_type]
276+
274277
if "lldb-simulator-ios" in config.available_features:
275278
dotest_cmd += ["--apple-sdk", "iphonesimulator", "--platform-name", "ios-simulator"]
276279
elif "lldb-simulator-watchos" in config.available_features:

lldb/test/API/lit.site.cfg.py.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ config.has_libcxx = @LLDB_HAS_LIBCXX@
4040
config.libcxx_libs_dir = "@LIBCXX_LIBRARY_DIR@"
4141
config.libcxx_include_dir = "@LIBCXX_GENERATED_INCLUDE_DIR@"
4242
config.libcxx_include_target_dir = "@LIBCXX_GENERATED_INCLUDE_TARGET_DIR@"
43+
config.cmake_build_type = "@CMAKE_BUILD_TYPE@"
4344
# The API tests use their own module caches.
4445
config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api")
4546
config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api")

lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_runInTerminal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
Test lldb-dap restart request.
33
"""
44

5-
import os
65
from lldbsuite.test.decorators import *
76
from lldbsuite.test.lldbtest import line_number
87
import lldbdap_testcase
98

109

11-
@skipIfBinaryToLarge(os.getenv("LLDBDAP_EXEC"), 1_000_000)
10+
@skipIfBuildType(["debug"])
1211
class TestDAP_restart_runInTerminal(lldbdap_testcase.DAPTestCaseBase):
1312
@skipIfWindows
1413
@skipIf(oslist=["linux"], archs=["arm"]) # Always times out on buildbot
@@ -56,6 +55,7 @@ def test_stopOnEntry(self):
5655
program = self.getBuildArtifact("a.out")
5756
self.build_and_launch(program, runInTerminal=True, stopOnEntry=True)
5857
[bp_main] = self.set_function_breakpoints(["main"])
58+
self.dap_server.request_configurationDone()
5959

6060
# When using stopOnEntry, configurationDone doesn't result in a running
6161
# process, we should immediately get a stopped event instead.

lldb/test/API/tools/lldb-dap/runInTerminal/TestDAP_runInTerminal.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import json
1111

1212

13-
@skipIfBinaryToLarge(os.getenv("LLDBDAP_EXEC"), 1_000_000)
13+
@skipIfBuildType(["debug"])
1414
class TestDAP_runInTerminal(lldbdap_testcase.DAPTestCaseBase):
1515
def readPidMessage(self, fifo_file):
1616
with open(fifo_file, "r") as file:
@@ -90,6 +90,12 @@ def test_runInTerminalWithObjectEnv(self):
9090
self.assertIn("FOO", request_envs)
9191
self.assertEqual("BAR", request_envs["FOO"])
9292

93+
# Ensure we can continue to a breakpoint.
94+
source = "main.c"
95+
breakpoint_line = line_number(source, "// breakpoint")
96+
self.set_source_breakpoints(source, [breakpoint_line])
97+
self.continue_to_next_stop()
98+
9399
@skipIfWindows
94100
@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
95101
def test_runInTerminalInvalidTarget(self):
@@ -103,8 +109,8 @@ def test_runInTerminalInvalidTarget(self):
103109
)
104110
self.assertFalse(response["success"])
105111
self.assertIn(
106-
"Could not create a target for a program 'INVALIDPROGRAM': 'INVALIDPROGRAM' does not exist",
107-
response["message"],
112+
"'INVALIDPROGRAM' does not exist",
113+
response["body"]["error"]["format"],
108114
)
109115

110116
@skipIfWindows

lldb/test/API/tools/lldb-dap/server/TestDAP_server.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,12 @@ def test_server_interrupt(self):
9898
self.set_source_breakpoints(source, [breakpoint_line])
9999
self.continue_to_next_stop()
100100

101-
# Interrupt the server which should disconnect all clients.
102-
process.send_signal(signal.SIGINT)
103-
104-
self.dap_server.wait_for_terminated()
105101
self.assertIsNone(
106102
self.dap_server.exit_status,
107103
"Process exited before interrupting lldb-dap server",
108104
)
105+
106+
# Interrupt the server which should disconnect all clients.
107+
process.send_signal(signal.SIGINT)
108+
109+
self.dap_server.wait_for_terminated()

0 commit comments

Comments
 (0)