This is an archive of the discontinued LLVM Phabricator instance.

[lldb][tests] Test queue-specific breakpoints
ClosedPublic

Authored by cassanova on Aug 10 2022, 11:17 AM.

Details

Summary

This commit adds tests to ensure that queue-specific breakpoints work as expected, as this feature wasn't being tested before.

Diff Detail

Event Timeline

cassanova created this revision.Aug 10 2022, 11:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 11:17 AM
cassanova requested review of this revision.Aug 10 2022, 11:17 AM
jasonmolenda accepted this revision.Aug 10 2022, 1:31 PM
jasonmolenda added a subscriber: jasonmolenda.

This looks good to me.

This revision is now accepted and ready to land.Aug 10 2022, 1:31 PM

Please include more context (https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface) in future patches.

Thanks for the tests regardless!

mib added inline comments.Aug 11 2022, 2:47 PM
lldb/test/API/macosx/queues/TestQueues.py
133

Could you replace that with the enum variable ?

388

Do you really need a main_thread variable since lldbutil.run_to_name_breakpoint would return a tuple with (target, process, thread, bkpt) ? Is the thread returned here different from the main_thread you created above ?

cassanova added inline comments.Aug 12 2022, 11:54 AM
lldb/test/API/macosx/queues/TestQueues.py
133

Yes the enum variable would be better here

388

The thread is the same actually, so it would probably be beneficial to just get the thread from run_to_name_breakpoint instead.

Use the enum name for the stop reason when asserting that the queues hit their breakpoints instead of just the raw number.

Also, get the main thread from run_to_name_breakpoint instead of getting it from get_threads_stopped_at_breakpoint

mib added inline comments.Aug 12 2022, 12:10 PM
lldb/test/API/macosx/queues/TestQueues.py
204–206

Why not do it this way ? Takes less space and it's easier to read (for people who don't know what process_info[2] and process_info[3] refers to)

316

Do you still need this ?

387–389

ditto

All variables needed from run_to_name_breakpoint are obtained in one line rather than getting them by index.

cassanova added inline comments.Aug 12 2022, 1:49 PM
lldb/test/API/macosx/queues/TestQueues.py
204–206

This is a much cleaner way to write it :)

cassanova marked 4 inline comments as done.Aug 12 2022, 1:49 PM
teemperor added inline comments.
lldb/test/API/macosx/queues/TestQueues.py
131

missed assertEqual here?

mib accepted this revision.Aug 12 2022, 2:01 PM

LGTM with @teemperor feedback !

lldb/test/API/macosx/queues/TestQueues.py
131

+1!

cassanova added inline comments.Aug 12 2022, 2:09 PM
lldb/test/API/macosx/queues/TestQueues.py
131

Yes, adding this in

cassanova updated this revision to Diff 452302.Aug 12 2022, 2:12 PM

Changed an assertTrue to assertEqual.

JDevlieghere requested changes to this revision.Aug 15 2022, 10:18 AM
JDevlieghere added inline comments.
lldb/test/API/macosx/queues/TestQueues.py
133

This should use self.assertStopReason for a better error message.

201–206

This seems like it should be its own test. Right now this is reassigning the target and process, which seems suspicious, and also changes the meaning of everything that comes after it.

This revision now requires changes to proceed.Aug 15 2022, 10:18 AM
cassanova added inline comments.Aug 15 2022, 4:27 PM
lldb/test/API/macosx/queues/TestQueues.py
201–206

Good point, I'm placing the queue specific tests into their own test.

cassanova updated this revision to Diff 452853.Aug 15 2022, 5:28 PM

Added the queue-specific breakpoints to their own test.

JDevlieghere added inline comments.Aug 16 2022, 3:51 PM
lldb/test/API/macosx/queues/TestQueues.py
125

Any reason this should be a separate function? Can this be inlined in queue_specific_breakpoints?

cassanova added inline comments.Aug 16 2022, 4:11 PM
lldb/test/API/macosx/queues/TestQueues.py
125

It can be inlined, the reason I had it in a separate function is that it matched the rest of the test in having the assertions be in their own functions.

JDevlieghere accepted this revision.Aug 17 2022, 9:01 AM

LGTM

lldb/test/API/macosx/queues/TestQueues.py
125

Fair enough, this test has a different structure than most. Let's keep it this way then for consistency.

This revision is now accepted and ready to land.Aug 17 2022, 9:01 AM
cassanova marked 7 inline comments as done.Aug 17 2022, 9:44 AM
This revision was automatically updated to reflect the committed changes.