Skip to content

Commit 46dc4b8

Browse files
GeorgeHuyuboGeorge Hu
andauthored
[lldb] Fix TestLocationsAfterRebuild test (llvm#167402)
After commit fce5889 enabled the locate_module callback for main executables, the TestLocationsAfterRebuild.py test started failing on remote platforms. The test was hardcoded to expect breakpoint location "1.3" to exist after three rebuilds, but the new module loading behavior changed how breakpoint locations are managed. This patch fixes the test by: - Removing the @skipIfRemote decorator to re-enable testing on remote platforms - Dynamically querying the actual number of breakpoint locations instead of assuming a specific count - Using loc.GetID() to get actual location IDs rather than assuming sequential IDs (1, 2, 3) - Iterating through all valid locations and verifying each can be disabled/enabled The fix maintains the original test intent (validating that breakpoint location IDs remain valid after rebuilds) while adapting to the new module loading behavior where the number and IDs of locations may vary across platforms. Co-authored-by: George Hu <[email protected]>
1 parent e5e74e9 commit 46dc4b8

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

lldb/test/API/functionalities/breakpoint/breakpoint_locations/after_rebuild/TestLocationsAfterRebuild.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import lldb
88
import lldbsuite.test.lldbutil as lldbutil
99
from lldbsuite.test.lldbtest import *
10-
from lldbsuite.test.decorators import skipIfWindows, skipIfRemote
10+
from lldbsuite.test.decorators import skipIfWindows
1111
import os
1212

1313

@@ -19,7 +19,6 @@ class TestLocationsAfterRebuild(TestBase):
1919

2020
# On Windows we cannot remove a file that lldb is debugging.
2121
@skipIfWindows
22-
@skipIfRemote
2322
def test_remaining_location_spec(self):
2423
"""If we rebuild a couple of times some of the old locations
2524
get removed. Make sure the command-line breakpoint id
@@ -55,6 +54,24 @@ def test_remaining_location_spec(self):
5554
self, target, bkpt
5655
)
5756

57+
# After enabling locate_module callback for main executables,
58+
# the number of locations may vary depending on the platform.
59+
num_locs = bkpt.GetNumLocations()
5860
bkpt_id = bkpt.GetID()
59-
loc_string = f"{bkpt_id}.3"
60-
self.runCmd(f"break disable {loc_string}")
61+
62+
self.assertGreater(
63+
num_locs,
64+
0,
65+
f"Expected at least one breakpoint location, but found {num_locs}",
66+
)
67+
68+
# Iterate through all valid locations and verify we can disable each one.
69+
# This tests that breakpoint location IDs remain valid after rebuilds.
70+
for loc_idx in range(num_locs):
71+
loc = bkpt.GetLocationAtIndex(loc_idx)
72+
self.assertTrue(loc.IsValid(), f"Location at index {loc_idx} is not valid")
73+
74+
# Get the actual location ID from the location object
75+
loc_id = loc.GetID()
76+
loc_string = f"{bkpt_id}.{loc_id}"
77+
self.runCmd(f"break disable {loc_string}")

0 commit comments

Comments
 (0)