Files
clang-p2996/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py
Michael Buch aad7874000 [lldb][test][NFC] TestBreakpointSetRestart.py: split up assertion to determine which check specifically fails in CI
This test consistently fails on the public macOS ASAN CI (and isn't
reproducible locally):
```
FAIL: test_breakpoint_set_restart_dwarf
(TestBreakpointSetRestart.BreakpointSetRestart)
----------------------------------------------------------------------
Traceback (most recent call last):
  File
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
line 1756, in test_method
    return attrvalue(self)
  File
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
line 150, in wrapper
    return func(*args, **kwargs)
  File
"/Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake-sanitized/llvm-project/lldb/test/API/functionalities/breakpoint/breakpoint_set_restart/TestBreakpointSetRestart.py",
line 36, in test_breakpoint_set_restart
    self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1,
VALID_BREAKPOINT)
AssertionError: False is not true : Got a valid breakpoint
```

From this error we're not quite sure what about the breakpoint here is
the problem.

This patch splits up the assertion to narrow down the issue.
2024-06-03 17:04:16 +01:00

52 lines
1.8 KiB
Python

"""
Test inferior restart when breakpoint is set on running target.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
class BreakpointSetRestart(TestBase):
BREAKPOINT_TEXT = "Set a breakpoint here"
@skipIfNetBSD
@skipIf(oslist=["freebsd"], bugnumber="github.com/llvm/llvm-project/issues/56082")
def test_breakpoint_set_restart(self):
self.build()
exe = self.getBuildArtifact("a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_TARGET)
self.dbg.SetAsync(True)
process = target.LaunchSimple(None, None, self.get_process_working_directory())
self.assertTrue(process, PROCESS_IS_VALID)
event = lldb.SBEvent()
# Wait for inferior to transition to running state
while self.dbg.GetListener().WaitForEvent(2, event):
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
break
bp = target.BreakpointCreateBySourceRegex(
self.BREAKPOINT_TEXT, lldb.SBFileSpec("main.cpp")
)
self.assertTrue(bp.IsValid(), VALID_BREAKPOINT)
self.assertEqual(bp.GetNumLocations(), 1, VALID_BREAKPOINT)
while self.dbg.GetListener().WaitForEvent(2, event):
if lldb.SBProcess.GetStateFromEvent(
event
) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
continue
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
continue
self.fail(
"Setting a breakpoint generated an unexpected event: %s"
% lldb.SBDebugger.StateAsCString(
lldb.SBProcess.GetStateFromEvent(event)
)
)