This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix TestTargetAPI.py on Apple simulators
ClosedPublic

Authored by teemperor on Oct 19 2020, 6:51 AM.

Details

Summary

This test checks that the output of SBTarget.GetDescription() contains the substrings 'a.out', 'Target', 'Module', 'Breakpoint'
in that order. This test is currently failing on Apple simulators as apparently 'Module' can't be found in the output after 'Target".

The reason for that is that the actual output of SBTarget.GetDescription() looks like this:

Target
  Module /build/path/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_description_dwarf/a.out
0x7ff2b6d3f990:     ObjectFileMachO64, file = /build/path/lldb-test-build.noindex/python_api/target/TestTargetAPI.test_get_description
[...]
0x7ff307150000:   BreakpointList with 0 Breakpoints:
<LLDB module output repeats for each loaded module>

Clearly the string order should be 'Target', 'Module', 'a.out', 'Breakpoint'. However, LLDB is also a bunch of system shared libraries
(libxpc.dylib, libobjc.A.dylib, etc.) when *not* running against a simulator, we end up unintentionally finding the
'Target', 'Module', 'Breakpoint' substrings in the trailing descriptions of the system modules. When running against a simulator
we however don't load shared system libraries.

This patch just moves the substrings in the correct order to make this test pass without having any shared library modules
in the description output.

Diff Detail

Event Timeline

teemperor requested review of this revision.Oct 19 2020, 6:51 AM
teemperor created this revision.
mib added a comment.Oct 19 2020, 7:09 AM

What if we tested each substring individually with self.assertIn to avoid checking the order of the substrings as it seems to change depending on the target ?

JDevlieghere accepted this revision.Oct 19 2020, 9:02 AM
In D89698#2338771, @mib wrote:

What if we tested each substring individually with self.assertIn to avoid checking the order of the substrings as it seems to change depending on the target ?

There's an optional argument to not enforce ordering (which used to be the default). But as illustrated here, that might result in (unintentionally) matching something else, so it should be used with caution.

This revision is now accepted and ready to land.Oct 19 2020, 9:02 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 22 2020, 7:42 AM