aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/python_api
diff options
context:
space:
mode:
authorJacob Lalonde <jalalonde@fb.com>2025-03-03 14:01:29 -0800
committerGitHub <noreply@github.com>2025-03-03 14:01:29 -0800
commit3ff6fb68d7aadf570a15a8a068ce7b24851e136d (patch)
treed9bec3b4899ef43492a5e25df8a229c602fa69db /lldb/test/API/python_api
parent8179bcfe56ef3361827a644a1ab4f515ad2583aa (diff)
downloadllvm-3ff6fb68d7aadf570a15a8a068ce7b24851e136d.zip
llvm-3ff6fb68d7aadf570a15a8a068ce7b24851e136d.tar.gz
llvm-3ff6fb68d7aadf570a15a8a068ce7b24851e136d.tar.bz2
[LLDB][SBProgress] Add a finalize method (#128966)
This patch adds a finalize method which destroys the underlying RAII SBProgress. My primary motivation for this is so I can write better tests that are non-flaky, but after discussing with @clayborg in my DAP message improvement patch (#124648) this is probably an essential API despite that I originally argued it wasn't.
Diffstat (limited to 'lldb/test/API/python_api')
-rw-r--r--lldb/test/API/python_api/sbprogress/TestSBProgress.py59
1 files changed, 30 insertions, 29 deletions
diff --git a/lldb/test/API/python_api/sbprogress/TestSBProgress.py b/lldb/test/API/python_api/sbprogress/TestSBProgress.py
index 1b8f01d..2a0689a 100644
--- a/lldb/test/API/python_api/sbprogress/TestSBProgress.py
+++ b/lldb/test/API/python_api/sbprogress/TestSBProgress.py
@@ -6,35 +6,6 @@ from lldbsuite.test.lldbtest import *
class SBProgressTestCase(TestBase):
def test_with_external_bit_set(self):
- """Test SBProgress events are listened to when the external bit is set."""
-
- progress = lldb.SBProgress("Test SBProgress", "Test progress", self.dbg)
- listener = lldb.SBListener("Test listener")
- broadcaster = self.dbg.GetBroadcaster()
- broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgress)
- event = lldb.SBEvent()
-
- expected_string = "Test progress first increment"
- progress.Increment(1, expected_string)
- self.assertTrue(listener.PeekAtNextEvent(event))
- stream = lldb.SBStream()
- event.GetDescription(stream)
- self.assertIn(expected_string, stream.GetData())
-
- def test_without_external_bit_set(self):
- """Test SBProgress events are not listened to on the internal progress bit."""
-
- progress = lldb.SBProgress("Test SBProgress", "Test progress", self.dbg)
- listener = lldb.SBListener("Test listener")
- broadcaster = self.dbg.GetBroadcaster()
- broadcaster.AddListener(listener, lldb.eBroadcastBitProgress)
- event = lldb.SBEvent()
-
- expected_string = "Test progress first increment"
- progress.Increment(1, expected_string)
- self.assertFalse(listener.PeekAtNextEvent(event))
-
- def test_with_external_bit_set(self):
"""Test SBProgress can handle null events."""
progress = lldb.SBProgress("Test SBProgress", "Test progress", 3, self.dbg)
@@ -65,3 +36,33 @@ class SBProgressTestCase(TestBase):
stream = lldb.SBStream()
event.GetDescription(stream)
self.assertIn("Step 3", stream.GetData())
+
+ def test_progress_finalize_non_deterministic_progress(self):
+ """Test SBProgress finalize sends the progressEnd event"""
+
+ progress = lldb.SBProgress("Test SBProgress", "Test finalize", self.dbg)
+ listener = lldb.SBListener("Test listener")
+ broadcaster = self.dbg.GetBroadcaster()
+ broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgressCategory)
+ event = lldb.SBEvent()
+ progress.Finalize()
+ self.assertTrue(listener.WaitForEvent(5, event))
+ stream = lldb.SBStream()
+ event.GetDescription(stream)
+ self.assertIn("type = end", stream.GetData())
+
+ def test_progress_finalize_deterministic_progress(self):
+ """Test SBProgress finalize sends the progressEnd event"""
+
+ progress = lldb.SBProgress("Test SBProgress", "Test finalize", 13, self.dbg)
+ listener = lldb.SBListener("Test listener")
+ broadcaster = self.dbg.GetBroadcaster()
+ broadcaster.AddListener(listener, lldb.eBroadcastBitExternalProgressCategory)
+ event = lldb.SBEvent()
+ progress.Finalize()
+ self.assertTrue(listener.WaitForEvent(5, event))
+ stream = lldb.SBStream()
+ event.GetDescription(stream)
+ # Note even for progresses with a total, the total isn't
+ # sent in the end message.
+ self.assertIn("type = end", stream.GetData())