================
@@ -0,0 +1,253 @@
+import json
+import threading
+from typing import List, Union
+
+from lldbsuite.test.tools.lldb_dap.dap_types import (
+    CapabilitiesEvent,
+    DAPError,
+    Event,
+    ExitedEvent,
+    InitializedEvent,
+    ModuleEvent,
+    OutputEvent,
+    ProcessEvent,
+    ProgressEndEvent,
+    TerminatedEvent,
+)
+from lldbsuite.test.tools.lldb_dap.lldb_dap_testcase import DAPTestCaseBase
+from lldbsuite.test.tools.lldb_dap.utils import EventHistory
+
+
+class TestDAPUtils_EventHistory(DAPTestCaseBase):
+    """
+    This test suite verifies the behavior of EventHistory, including event 
ordering validation,
+    querying specific events, handling closed histories, applying custom 
filtering conditions,
+    and managing timeouts during asynchronous event additions.
+    """
+
+    def test_history_order(self):
+        """Test that events added to EventHistory are in sequential order"""
+
+        history = EventHistory(timeout=10)
+        event_1 = Event.from_json(
+            {
+                "body": {
+                    "category": "console",
+                    "output": "Running preInitCommands:\n",
+                },
+                "event": "output",
+                "seq": 2,
+                "type": "event",
+            }
+        )
+        event_2 = Event.from_json(
+            {
+                "body": {
+                    "category": "console",
+                    "output": "(lldb) log enable lldb process",
+                },
+                "event": "output",
+                "seq": 1,
+                "type": "event",
+            }
+        )
+
+        history.record(event_1)
+        with self.assertRaises(DAPError) as ctx:
+            history.record(event_2)
+
+        self.assertIn("older than last event", str(ctx.exception))
+
+    def test_wait_for_X_event_on_history_closed(self):
+        """Tests `wait_for_first_event`, `wait_for_event` and 
`wait_for_any_event` when the history is closed.
----------------
da-viper wrote:

Function was renamed.

https://github.com/llvm/llvm-project/pull/207037
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to