summaryrefslogtreecommitdiff
path: root/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
diff options
context:
space:
mode:
authorPavel Labath <pavel@labath.sk>2022-02-07 20:04:42 +0100
committerPavel Labath <pavel@labath.sk>2022-02-09 11:05:02 +0100
commit5a4fe166d13bf89e6bc387bd96232e8c0f706d27 (patch)
treec7f91525736b4f09a93a33420f05dfee92f256b6 /lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
parentcdb7675c2649ee91c4e97d84daa76c98cb93b9c4 (diff)
[lldb/test] Remove sleeps from some lldb-server tests
Instead of using sleeps, have the inferior notify us (via a trap opcode) that the requested number of threads have been created. This allows us to get rid of some fairly dodgy test utility code -- wait_for_thread_count seemed like it was waiting for the threads to appear, but it never actually let the inferior run, so it only succeeded if the threads were already started when the function was called. Since the function was called after a fairly small delay (1s, usually), this is probably the reason why the tests were failing on some bots. Differential Revision: https://reviews.llvm.org/D119167
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py57
1 files changed, 13 insertions, 44 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 619d0f1c2172..cea963e45659 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -772,29 +772,20 @@ class GdbRemoteTestCaseBase(Base):
thread_ids.extend(new_thread_infos)
return thread_ids
- def wait_for_thread_count(self, thread_count):
- start_time = time.time()
- timeout_time = start_time + self.DEFAULT_TIMEOUT
-
- actual_thread_count = 0
- while actual_thread_count < thread_count:
- self.reset_test_sequence()
- self.add_threadinfo_collection_packets()
-
- context = self.expect_gdbremote_sequence()
- self.assertIsNotNone(context)
-
- threads = self.parse_threadinfo_packets(context)
- self.assertIsNotNone(threads)
-
- actual_thread_count = len(threads)
-
- if time.time() > timeout_time:
- raise Exception(
- 'timed out after {} seconds while waiting for threads: waiting for at least {} threads, found {}'.format(
- self.DEFAULT_TIMEOUT, thread_count, actual_thread_count))
+ def launch_with_threads(self, thread_count):
+ procs = self.prep_debug_monitor_and_inferior(
+ inferior_args=["thread:new"]*(thread_count-1) + ["trap"])
- return threads
+ self.test_sequence.add_log_lines([
+ "read packet: $c#00",
+ {"direction": "send",
+ "regex": r"^\$T([0-9a-fA-F]{2})([^#]*)#..$",
+ "capture": {1: "stop_signo", 2: "stop_reply_kv"}}], True)
+ self.add_threadinfo_collection_packets()
+ context = self.expect_gdbremote_sequence()
+ threads = self.parse_threadinfo_packets(context)
+ self.assertGreaterEqual(len(threads), thread_count)
+ return context, threads
def add_set_breakpoint_packets(
self,
@@ -896,28 +887,6 @@ class GdbRemoteTestCaseBase(Base):
return supported_dict
- def run_process_then_stop(self, run_seconds=1):
- # Tell the stub to continue.
- self.test_sequence.add_log_lines(
- ["read packet: $vCont;c#a8"],
- True)
- context = self.expect_gdbremote_sequence()
-
- # Wait for run_seconds.
- time.sleep(run_seconds)
-
- # Send an interrupt, capture a T response.
- self.reset_test_sequence()
- self.test_sequence.add_log_lines(
- ["read packet: {}".format(chr(3)),
- {"direction": "send", "regex": r"^\$T([0-9a-fA-F]+)([^#]+)#[0-9a-fA-F]{2}$", "capture": {1: "stop_result"}}],
- True)
- context = self.expect_gdbremote_sequence()
- self.assertIsNotNone(context)
- self.assertIsNotNone(context.get("stop_result"))
-
- return context
-
def continue_process_and_wait_for_stop(self):
self.test_sequence.add_log_lines(
[