Skip to content

Commit 41333a9

Browse files
kendalharlandkendal
authored andcommitted
Fix test assertions in TestDAP_stepInTargets.py (#96687)
The strings this test is using seem to consistently fail to match against the expected values when built & run targeting Windows amd64. This PR updates them to the expected values. To fix the test and avoid over-specifying for a specific platform, use `assertIn(<target-substring>,...)` to see if we've got the correct target label instead of comparing the demangler output for an exact string match. --------- Co-authored-by: kendal <[email protected]>
1 parent 632b6e8 commit 41333a9

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py

+22-10
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010

1111

1212
class TestDAP_stepInTargets(lldbdap_testcase.DAPTestCaseBase):
13-
@skipIf(
14-
archs=no_match(["x86_64"])
15-
) # InstructionControlFlowKind for ARM is not supported yet.
13+
@expectedFailureAll(oslist=["windows"])
14+
@skipIf(archs=no_match(["x86_64"]))
15+
# InstructionControlFlowKind for ARM is not supported yet.
16+
# On Windows, lldb-dap seems to ignore targetId when stepping into functions.
17+
# For more context, see https://github.com/llvm/llvm-project/issues/98509.
1618
def test_basic(self):
1719
"""
1820
Tests the basic stepping in targets with directly calls.
@@ -55,14 +57,24 @@ def test_basic(self):
5557
self.assertEqual(len(step_in_targets), 3, "expect 3 step in targets")
5658

5759
# Verify the target names are correct.
58-
self.assertEqual(step_in_targets[0]["label"], "bar()", "expect bar()")
59-
self.assertEqual(step_in_targets[1]["label"], "bar2()", "expect bar2()")
60-
self.assertEqual(
61-
step_in_targets[2]["label"], "foo(int, int)", "expect foo(int, int)"
62-
)
60+
# The order of funcA and funcB may change depending on the compiler ABI.
61+
funcA_target = None
62+
funcB_target = None
63+
for target in step_in_targets[0:2]:
64+
if "funcB" in target["label"]:
65+
funcB_target = target
66+
elif "funcA" in target["label"]:
67+
funcA_target = target
68+
else:
69+
self.fail(f"Unexpected step in target: {target}")
70+
71+
self.assertIsNotNone(funcA_target, "expect funcA")
72+
self.assertIsNotNone(funcB_target, "expect funcB")
73+
self.assertIn("foo", step_in_targets[2]["label"], "expect foo")
6374

64-
# Choose to step into second target and verify that we are in bar2()
75+
# Choose to step into second target and verify that we are in the second target,
76+
# be it funcA or funcB.
6577
self.stepIn(threadId=tid, targetId=step_in_targets[1]["id"], waitForStop=True)
6678
leaf_frame = self.dap_server.get_stackFrame()
6779
self.assertIsNotNone(leaf_frame, "expect a leaf frame")
68-
self.assertEqual(leaf_frame["name"], "bar2()")
80+
self.assertEqual(step_in_targets[1]["label"], leaf_frame["name"])
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11

22
int foo(int val, int extra) { return val + extra; }
33

4-
int bar() { return 22; }
4+
int funcA() { return 22; }
55

6-
int bar2() { return 54; }
6+
int funcB() { return 54; }
77

88
int main(int argc, char const *argv[]) {
9-
foo(bar(), bar2()); // set breakpoint here
9+
foo(funcA(), funcB()); // set breakpoint here
1010
return 0;
1111
}

0 commit comments

Comments
 (0)