Skip to content

Fix test assertions in TestDAP_stepInTargets.py #96687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2024

Conversation

kendalharland
Copy link
Contributor

@kendalharland kendalharland commented Jun 25, 2024

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.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the lldb label Jun 25, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 25, 2024

@llvm/pr-subscribers-lldb

Author: Kendal Harland (kendalharland)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/96687.diff

1 Files Affected:

  • (modified) lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py (+4-4)
diff --git a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
index 6296f6554d07e..cc53954885cdf 100644
--- a/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
+++ b/lldb/test/API/tools/lldb-dap/stepInTargets/TestDAP_stepInTargets.py
@@ -55,14 +55,14 @@ def test_basic(self):
         self.assertEqual(len(step_in_targets), 3, "expect 3 step in targets")
 
         # Verify the target names are correct.
-        self.assertEqual(step_in_targets[0]["label"], "bar()", "expect bar()")
-        self.assertEqual(step_in_targets[1]["label"], "bar2()", "expect bar2()")
+        self.assertEqual(step_in_targets[0]["label"], "int bar2(void)", "expect bar2()")
+        self.assertEqual(step_in_targets[1]["label"], "int bar(void)", "expect bar()")
         self.assertEqual(
-            step_in_targets[2]["label"], "foo(int, int)", "expect foo(int, int)"
+            step_in_targets[2]["label"], "int foo(int, int)", "expect foo(int, int)"
         )
 
         # Choose to step into second target and verify that we are in bar2()
         self.stepIn(threadId=tid, targetId=step_in_targets[1]["id"], waitForStop=True)
         leaf_frame = self.dap_server.get_stackFrame()
         self.assertIsNotNone(leaf_frame, "expect a leaf frame")
-        self.assertEqual(leaf_frame["name"], "bar2()")
+        self.assertEqual(leaf_frame["name"], "int bar2(void)")

@kendalharland
Copy link
Contributor Author

This PR was really just the result of me looking at the test output on my own machine and copy-pasting the values that were generated by the test's data. I am not familiar with this test's implementation and would appreciate any guidance on whether there really is a bug here, and how I can test this on different platforms/architectures the same way that the llvm-project CI does it.

Copy link
Contributor

@jeffreytan81 jeffreytan81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried to run this test on Linux? It is passing on my machine. I am pretty sure this might be Windows platform (like compiler and disassembler) specific behavior which you shouldn't change the default value for the test. You either have to disable this test for Windows (which I never tested) or write different expected value for different platform

@bulbazord
Copy link
Member

One option might be to change the test to match against some list of expected strings. I'm not super familiar with this test but as Jeffrey said this could be OS/Platform dependent.

@labath
Copy link
Collaborator

labath commented Jun 26, 2024

I'm not sure if these names come from the demangler or debug info, but windows has different implementations for both, so it not surprising they're different. Assuming we don't care about the precise formatting of the names, we could just check whether the name of the function is in the string (and change the name to something more unique): assertIn("my_first_step_target", step_in_targets[0]["label"])

@kendalharland
Copy link
Contributor Author

kendalharland commented Jun 27, 2024

I'm not sure if these names come from the demangler or debug info, but windows has different implementations for both, so it not surprising they're different. Assuming we don't care about the precise formatting of the names, we could just check whether the name of the function is in the string (and change the name to something more unique): assertIn("my_first_step_target", step_in_targets[0]["label"])

Sorry for the late follow up, I got pulled into fixing something else. I think this is a simple enough solution. I'll reupload and re-ping for review.

@kendalharland kendalharland force-pushed the kendal/fix-test-dap-step-in-targets branch from 2e3ac00 to 58adc30 Compare July 1, 2024 20:43
@kendalharland
Copy link
Contributor Author

I'm not sure if these names come from the demangler or debug info, but windows has different implementations for both, so it not surprising they're different. Assuming we don't care about the precise formatting of the names, we could just check whether the name of the function is in the string (and change the name to something more unique): assertIn("my_first_step_target", step_in_targets[0]["label"])

Sorry for the late follow up, I got pulled into fixing something else. I think this is a simple enough solution. I'll reupload and re-ping for review.

Updated in the latest commit.

@labath
Copy link
Collaborator

labath commented Jul 2, 2024

This looks fine to me. @jeffreytan81 ?

Copy link
Contributor

@jeffreytan81 jeffreytan81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, was in the middle of review then got interrupted/distracted by other stuff yesterday.

Looks good.

@kendalharland
Copy link
Contributor Author

Sorry, was in the middle of review then got interrupted/distracted by other stuff yesterday.

Looks good.

No problem at all. Thanks for the reviews! I'll look into the build failures.

@labath
Copy link
Collaborator

labath commented Jul 3, 2024

�AssertionError: 'funcB' not found in 'funcA()' : expect funcB

The step targets are coming in different order. It's probably an ABI thing, as the compiler produces the calls in different order as well: https://godbolt.org/z/cPqhsWba6

I guess we need to adjust the test to accept both orders.

@kendalharland kendalharland force-pushed the kendal/fix-test-dap-step-in-targets branch 2 times, most recently from b579f4c to 2584ce9 Compare July 3, 2024 19:12
@kendalharland
Copy link
Contributor Author

Nice find! I didn't now about godbolt.org. Updated the test to be order-independent w.r.t. funcA and funcB.

@kendalharland kendalharland force-pushed the kendal/fix-test-dap-step-in-targets branch from 2584ce9 to 02f06f9 Compare July 9, 2024 23:29
@kendalharland kendalharland requested a review from labath July 9, 2024 23:29
@kendalharland kendalharland force-pushed the kendal/fix-test-dap-step-in-targets branch from f993be5 to 4934a0c Compare July 12, 2024 17:42
) # InstructionControlFlowKind for ARM is not supported yet.
@skipIf
# InstructionControlFlowKind for ARM is not supported yet.
# On x86_64 lldb-dap seems to ignore targetId when stepping into functions.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging by everything said on this thread, I believe this is only true on x86_64 windows, so we should limit the exclusion to windows. Then you may actually be able to keep the xfail decorator, since the test is really expected to fail in this configuration (until the issue is fixed). (i.e., I think this should use @expectedFailureAll(oslist=["windows"]) instead of the @skipIf).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks for catching that. I added back the original @skipIf since the comment indicates that running the test on ARM is a waste, given that InstructionControlFlowKind is unsupported, and combined that with the @expectedFailureAll you gave above to expect failure on Windows configurations.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, that's exactly what I had in mind. Thanks.

@kendalharland kendalharland force-pushed the kendal/fix-test-dap-step-in-targets branch from 4934a0c to 8735430 Compare July 15, 2024 17:34
@kendalharland
Copy link
Contributor Author

I'll need help merging from someone with write access

@labath labath merged commit 2ea4a03 into llvm:main Jul 16, 2024
6 checks passed
Copy link

@kendalharland Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@kendalharland kendalharland deleted the kendal/fix-test-dap-step-in-targets branch July 24, 2024 19:32
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants