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.
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
"""
|
|
Test that we can get the vm range of the shared cache.
|
|
"""
|
|
|
|
import lldb
|
|
import re
|
|
import json
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class SharedCacheVMRangeTestCase(TestBase):
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
@skipIfRemote
|
|
@requireDarwin
|
|
@skipIfOutOfTreeDebugserver # debugserver returns shared_cache_size
|
|
def test_shared_cache_vm_range(self):
|
|
"""Test that the shared cache VM range contains a known libc function"""
|
|
self.build()
|
|
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
|
|
self, "// break here", lldb.SBFileSpec("main.c")
|
|
)
|
|
|
|
res = lldb.SBCommandReturnObject()
|
|
ci = self.dbg.GetCommandInterpreter()
|
|
self.assertTrue(ci, VALID_COMMAND_INTERPRETER)
|
|
|
|
ci.HandleCommand("process plugin packet send jGetSharedCacheInfo:{}", res)
|
|
|
|
# packet: jGetSharedCacheInfo:{}
|
|
# response:
|
|
# {
|
|
# "shared_cache_base_address": 6572900352,
|
|
# "shared_cache_uuid": "674DB25A-34B2-3C56-8BD4-7D78005B2F2E",
|
|
# "no_shared_cache": false,
|
|
# "shared_cache_private_cache": false,
|
|
# "shared_cache_path": "/System/Volumes/Preboot/Cryptexes/OS/System/Library/dyld/dyld_shared_cache_arm64e",
|
|
# "shared_cache_size": 5820792832
|
|
# }
|
|
|
|
self.assertTrue("response: " in res.GetOutput())
|
|
response = re.search("response: (.+)", res.GetOutput()).group(1)
|
|
json_response = json.loads(response)
|
|
self.assertTrue("shared_cache_base_address" in json_response)
|
|
self.assertTrue("shared_cache_size" in json_response)
|
|
start = json_response["shared_cache_base_address"]
|
|
end = start + json_response["shared_cache_size"]
|
|
|
|
symctx_list = target.FindSymbols("printf", lldb.eSymbolTypeCode)
|
|
self.assertGreater(symctx_list.GetSize(), 0)
|
|
|
|
symctx = symctx_list.GetContextAtIndex(0)
|
|
sym = symctx.GetSymbol()
|
|
self.assertTrue(sym.IsValid())
|
|
addr = sym.GetStartAddress()
|
|
printf_load_addr = addr.GetLoadAddress(target)
|
|
|
|
self.assertGreater(printf_load_addr, start)
|
|
self.assertLess(printf_load_addr, end)
|