[Lldb-commits] [PATCH] D120284: [lldb/test] Fix TestProgressReporting.py race issue with the event listener
Med Ismail Bennani via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Feb 21 14:33:04 PST 2022
mib created this revision.
mib added a reviewer: labath.
mib added a project: LLDB.
Herald added a subscriber: JDevlieghere.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.
This patch is a follow-up of D120100 <https://reviews.llvm.org/D120100> to address some feedbacks from
@labath.
This should mainly fix the race issue with the even listener by moving
the listener setup to the main thread.
This also updates the test to check it the inout arguments are returned
in a tuple and re-enables the test on linux.
Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D120284
Files:
lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
Index: lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
===================================================================
--- lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
+++ lldb/test/API/functionalities/progress_reporting/TestProgressReporting.py
@@ -17,41 +17,43 @@
TestBase.setUp(self)
self.progress_events = []
- def fetch_events(self, test_broadcaster):
- listener = lldb.SBListener("lldb.progress.listener")
- listener.StartListeningForEvents(test_broadcaster,
- self.eBroadcastBitStopProgressThread)
-
- progress_broadcaster = self.dbg.GetBroadcaster()
- progress_broadcaster.AddListener(listener, lldb.SBDebugger.eBroadcastBitProgress)
-
+ def fetch_events(self):
event = lldb.SBEvent()
done = False
while not done:
- if listener.WaitForEvent(1, event):
+ if self.listener.WaitForEvent(1, event):
event_mask = event.GetType();
- if event.BroadcasterMatchesRef(test_broadcaster):
+ if event.BroadcasterMatchesRef(self.test_broadcaster):
if event_mask & self.eBroadcastBitStopProgressThread:
done = True;
- elif event.BroadcasterMatchesRef(progress_broadcaster):
- message = lldb.SBDebugger().GetProgressFromEvent(event, 0, 0, 0, False);
+ elif event.BroadcasterMatchesRef(self.progress_broadcaster):
+ ret_args = lldb.SBDebugger().GetProgressFromEvent(event, 0, 0, 0, False);
+ self.assertGreater(len(ret_args), 1)
+
+ message = ret_args[0]
if message:
self.progress_events.append((message, event))
- @skipUnlessDarwin
+ @skipIf(oslist=no_match(['darwin','macos','linux']))
def test_dwarf_symbol_loading_progress_report(self):
"""Test that we are able to fetch dwarf symbol loading progress events"""
self.build()
- test_broadcaster = lldb.SBBroadcaster('lldb.broadcaster.test')
- listener_thread = threading.Thread(target=self.fetch_events,
- args=[test_broadcaster])
+ self.listener = lldb.SBListener("lldb.progress.listener")
+ self.test_broadcaster = lldb.SBBroadcaster('lldb.broadcaster.test')
+ self.listener.StartListeningForEvents(self.test_broadcaster,
+ self.eBroadcastBitStopProgressThread)
+
+ self.progress_broadcaster = self.dbg.GetBroadcaster()
+ self.progress_broadcaster.AddListener(self.listener, lldb.SBDebugger.eBroadcastBitProgress)
+
+ listener_thread = threading.Thread(target=self.fetch_events)
listener_thread.start()
lldbutil.run_to_source_breakpoint(self, 'break here', lldb.SBFileSpec('main.c'))
- test_broadcaster.BroadcastEventByType(self.eBroadcastBitStopProgressThread)
+ self.test_broadcaster.BroadcastEventByType(self.eBroadcastBitStopProgressThread)
listener_thread.join()
self.assertTrue(len(self.progress_events) > 0)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120284.410390.patch
Type: text/x-patch
Size: 3236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220221/ab1bc600/attachment.bin>
More information about the lldb-commits
mailing list