1"""
2Test that we are able to broadcast and receive diagnostic events from lldb
3"""
4import lldb
5
6import lldbsuite.test.lldbutil as lldbutil
7
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test.eventlistener import EventListenerTestBase
10
11class TestDiagnosticReporting(EventListenerTestBase):
12
13    mydir = TestBase.compute_mydir(__file__)
14    event_mask = lldb.SBDebugger.eBroadcastBitWarning | lldb.SBDebugger.eBroadcastBitError
15    event_data_extractor = lldb.SBDebugger.GetDiagnosticFromEvent
16
17    def test_dwarf_symbol_loading_diagnostic_report(self):
18        """Test that we are able to fetch diagnostic events"""
19
20        self.yaml2obj("minidump.yaml", self.getBuildArtifact("minidump.core"))
21
22        self.dbg.CreateTarget(None)
23        self.target = self.dbg.GetSelectedTarget()
24        self.process = self.target.LoadCore(
25            self.getBuildArtifact("minidump.core"))
26
27        self.assertEquals(len(self.events), 1)
28
29        diagnostic_event = self.events[0]
30        self.assertEquals(
31            diagnostic_event.GetValueForKey("type").GetStringValue(100),
32            "warning")
33        self.assertEquals(
34            diagnostic_event.GetValueForKey("message").GetStringValue(100),
35            "unable to retrieve process ID from minidump file, setting process ID to 1"
36        )
37