Files
clang-p2996/lldb/test/API/functionalities/diagnostic_reporting/TestDiagnosticReporting.py
Med Ismail Bennani 9216baf87d [lldb/test] Add events listener helper function to lldbtest
This patch introduces 2 new lldb utility functions:
- lldbutil.start_listening_from: This can be called in the test setup to
  create a listener and set it up for a specific event mask and add it
  to the user-provided broadcaster's list.
- lldbutil.fetch_next_event: This will use fetch a single event from the
  provided istener and return it if it matches the provided broadcaster.

The motivation behind this is to easily test new kinds of events
(i.e. Swift type-system progress events). However, this patch also
updates `TestProgressReporting.py` and `TestDiagnosticReporting.py`
to make use of these new helper functions.

Differential Revision: https://reviews.llvm.org/D122193

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
2022-03-23 12:30:09 -07:00

41 lines
1.4 KiB
Python

"""
Test that we are able to broadcast and receive diagnostic events from lldb
"""
import lldb
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
class TestDiagnosticReporting(TestBase):
mydir = TestBase.compute_mydir(__file__)
def setUp(self):
TestBase.setUp(self)
self.broadcaster = self.dbg.GetBroadcaster()
self.listener = lldbutil.start_listening_from(self.broadcaster,
lldb.SBDebugger.eBroadcastBitWarning |
lldb.SBDebugger.eBroadcastBitError)
def test_dwarf_symbol_loading_diagnostic_report(self):
"""Test that we are able to fetch diagnostic events"""
self.yaml2obj("minidump.yaml", self.getBuildArtifact("minidump.core"))
self.dbg.CreateTarget(None)
self.target = self.dbg.GetSelectedTarget()
self.process = self.target.LoadCore(
self.getBuildArtifact("minidump.core"))
event = lldbutil.fetch_next_event(self, self.listener, self.broadcaster)
diagnostic_data = lldb.SBDebugger.GetDiagnosticFromEvent(event)
self.assertEquals(
diagnostic_data.GetValueForKey("type").GetStringValue(100),
"warning")
self.assertEquals(
diagnostic_data.GetValueForKey("message").GetStringValue(100),
"unable to retrieve process ID from minidump file, setting process ID to 1"
)