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.
83 lines
2.6 KiB
Python
83 lines
2.6 KiB
Python
"""
|
|
Test lldb's ability to read and write the AArch64 FPMR register.
|
|
"""
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
|
|
|
|
class AArch64LinuxFPMR(TestBase):
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
# The value set by the inferior.
|
|
EXPECTED_FPMR = (0b101010 << 32) | 0b101
|
|
EXPECTED_FPMR_FIELDS = ["LSCALE2 = 42", "F8S1 = FP8_E4M3 | 0x4"]
|
|
|
|
@skipUnlessArch("aarch64")
|
|
@requireLinux
|
|
def test_fpmr_register_live(self):
|
|
if not self.isAArch64FPMR():
|
|
self.skipTest("FPMR must be present.")
|
|
|
|
self.build()
|
|
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
|
|
|
|
lldbutil.run_break_set_by_file_and_line(
|
|
self,
|
|
"main.c",
|
|
line_number("main.c", "// Set break point at this line."),
|
|
num_expected_locations=1,
|
|
)
|
|
|
|
self.runCmd("run", RUN_SUCCEEDED)
|
|
|
|
if self.process().GetState() == lldb.eStateExited:
|
|
self.fail("Test program failed to run.")
|
|
|
|
self.expect(
|
|
"thread list",
|
|
STOPPED_DUE_TO_BREAKPOINT,
|
|
substrs=["stopped", "stop reason = breakpoint"],
|
|
)
|
|
|
|
# This has been set by the program.
|
|
self.expect(
|
|
"register read --all",
|
|
substrs=[
|
|
"Floating Point Mode Register",
|
|
f"fpmr = {self.EXPECTED_FPMR:#018x}",
|
|
],
|
|
)
|
|
|
|
if self.hasXMLSupport():
|
|
self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)
|
|
|
|
# Write a value for the program to find. Same fields but with bit values
|
|
# inverted.
|
|
new_fpmr = (0b010101 << 32) | 0b010
|
|
self.runCmd(f"register write fpmr {new_fpmr:#x}")
|
|
|
|
# This value should be saved and restored after expressions.
|
|
self.runCmd("p expr_func()")
|
|
self.expect("register read fpmr", substrs=[f"fpmr = {new_fpmr:#018x}"])
|
|
|
|
# 0 means the program found the new value in the sysreg as expected.
|
|
self.expect("continue", substrs=["exited with status = 0"])
|
|
|
|
@skipIfLLVMTargetMissing("AArch64")
|
|
def test_fpmr_register_core(self):
|
|
if not self.isAArch64FPMR():
|
|
self.skipTest("FPMR must be present.")
|
|
|
|
self.runCmd("target create --core corefile")
|
|
|
|
self.expect(
|
|
"register read --all",
|
|
substrs=[
|
|
"Floating Point Mode Register",
|
|
f"fpmr = {self.EXPECTED_FPMR:#018x}",
|
|
],
|
|
)
|
|
self.expect("register read fpmr", substrs=self.EXPECTED_FPMR_FIELDS)
|