[lldb/test] Re-enable TestEvents.py on Darwin and fix crashes

This patch re-enables TestEvents.py on Darwin and fixes some crashes
that were happening due to an undefined method.

I ran it 100 times locally with the following command and it passed
every the time:

```
for i in {1..100}; do print $i/100; ./bin/lldb-dotest -p TestEvents.py 2>&1 | rg PASSED; if [ "$?" -eq "1" ]; then break; fi; done
```

Let's see if it still fails non-deterministically on the bots and
eventually also re-enable it on linux.

rdar://37037235

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

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
This commit is contained in:
Med Ismail Bennani
2022-02-25 20:50:05 -08:00
parent 22b6e8173c
commit 2a29c3f72e

View File

@@ -13,7 +13,6 @@ from lldbsuite.test import lldbutil
@skipIfLinux # llvm.org/pr25924, sometimes generating SIGSEGV
@skipIfDarwin
class EventAPITestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@@ -171,9 +170,9 @@ class EventAPITestCase(TestBase):
# Let's only try at most 3 times to retrieve any kind of event.
while not count > 3:
if listener.WaitForEvent(5, event):
self.trace("Got a valid event:", event)
self.trace("Event data flavor:", event.GetDataFlavor())
self.trace("Event type:", lldbutil.state_type_to_str(event.GetType()))
self.context.trace("Got a valid event:", event)
self.context.trace("Event data flavor:", event.GetDataFlavor())
self.context.trace("Event type:", lldbutil.state_type_to_str(event.GetType()))
listener.Clear()
return
count = count + 1
@@ -187,6 +186,7 @@ class EventAPITestCase(TestBase):
# Let's start the listening thread to retrieve the event.
my_thread = MyListeningThread()
my_thread.context = self
my_thread.start()
# Wait until the 'MyListeningThread' terminates.
@@ -256,7 +256,7 @@ class EventAPITestCase(TestBase):
class MyListeningThread(threading.Thread):
def run(self):
self.trace("Running MyListeningThread:", self)
self.context.trace("Running MyListeningThread:", self)
# Regular expression pattern for the event description.
pattern = re.compile("data = {.*, state = (.*)}$")
@@ -266,7 +266,7 @@ class EventAPITestCase(TestBase):
while True:
if listener.WaitForEvent(5, event):
desc = lldbutil.get_description(event)
self.trace("Event description:", desc)
self.context.trace("Event description:", desc)
match = pattern.search(desc)
if not match:
break