mirror-llvm-project/lldb/test/API/macosx/macCatalyst/TestMacCatalyst.py
Charles Zablit 67a20745d6
[lldb] Introduce the require decorator (#212753)
Currently, it is unclear if a test that is skipped is either:
- Unsupported because it will never run (macosx tests should not run on
Windows).
- Skipped because it's supposed to work but does not yet.
`@expectedFailure` is not always an option because a test might be
timing out and waiting 600s for it to fail is not acceptable.

This patch introduces 2 new decorators to differentiate those tests:
- `@requireX` meaning the tests require X to run (e.g `@requireDarwin`).
- `@requireNotX` meaning the tests requires anything but `X` to run (e.g
`@requireNotDarwin`).

In the tests results summary, this introduces a new category: `skipped`
tests:
- `@requireX` -> `UNSUPPORTED`
- `@skipIfX` -> `SKIPPED`

Here is how they can and cannot be stacked:

This will never run:
```py3
@requireDarwin
@requireWindows
def test():
    ...
```

This will not run on Linux, because `@requireWindows` is not satisfied.
```py3
@requireNotDarwin
@requireWindows
def test():
    ...
```

For "require Darwin or Windows", you need:
```py3
@requirePlatform(["darwin", "windows"])
def test():
    ...
```

For "require Darwin on ARM64 or Windows on ARM64", you need:
```py3
@requireARM64
@requirePlatform(["darwin", "windows"])
def test():
    ...
```

This patch also converts the tests in
`lldb/tests/API/{macosx,linux,windows}` to use these decorators. Patches
to convert the rest of the tests will follow.
2026-08-01 18:03:29 +02:00

45 lines
1.7 KiB
Python

import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test import configuration
import os
class TestMacCatalyst(TestBase):
SHARED_BUILD_TESTCASE = False
@skipIf(macos_version=["<", "10.15"])
@requireDarwin
@skipIfDarwinEmbedded
def test_macabi(self):
"""Test the x86_64-apple-ios-macabi target linked against a macos dylib"""
self.build(
dictionary={
"TRIPLE": self.getArchitecture() + "-apple-ios13.1-macabi",
}
)
log = self.getBuildArtifact("packets.log")
self.expect("log enable gdb-remote packets -f " + log)
lldbutil.run_to_source_breakpoint(self, "break here", lldb.SBFileSpec("main.c"))
self.expect(
"image list -t -b",
patterns=[self.getArchitecture() + r".*-apple-ios.*-macabi a\.out"],
)
self.expect("fr v s", substrs=["Hello macCatalyst"])
self.expect("expression s", substrs=["Hello macCatalyst"])
self.check_debugserver(log)
def check_debugserver(self, log):
"""scan the debugserver packet log"""
process_info = lldbutil.packetlog_get_process_info(log)
self.assertIn("ostype", process_info)
self.assertEqual(process_info["ostype"], "maccatalyst")
aout_info = None
dylib_info = lldbutil.packetlog_get_dylib_info(log)
for image in dylib_info["images"]:
if image["pathname"].endswith("a.out"):
aout_info = image
self.assertTrue(aout_info)
self.assertEqual(aout_info["min_version_os_name"], "maccatalyst")