Skip to content

Commit 9b37bfa

Browse files
committed
[lldb][AArch64] Handle different default vector length in SVE testing
This test previously ran on QEMU or A64FX both of which can/do have 512 bit SVE by default. Graviton 3 has 256 bit SVE so the first part of the test failed. To fix this, probe the supported vector lengths before starting the test. The first check will use the default vector length and the rest use either 256 or 128 bit. Therefore this test will be skipped on a machine with only 128 bit SVE. Reviewed By: omjavaid Differential Revision: https://reviews.llvm.org/D154208
1 parent 8e76093 commit 9b37bfa

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

lldb/test/API/commands/register/register/aarch64_sve_registers/rw_access_dynamic_resize/TestSVEThreadedDynamic.py

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
"""
22
Test the AArch64 SVE registers dynamic resize with multiple threads.
3+
4+
This test assumes a minimum supported vector length (VL) of 256 bits
5+
and will test 512 bits if possible. We refer to "vg" which is the
6+
register shown in lldb. This is in units of 64 bits. 256 bit VL is
7+
the same as a vg of 4.
38
"""
49

510
import lldb
@@ -9,6 +14,39 @@
914

1015

1116
class RegisterCommandsTestCase(TestBase):
17+
def get_supported_vg(self):
18+
# Changing VL trashes the register state, so we need to run the program
19+
# just to test this. Then run it again for the test.
20+
exe = self.getBuildArtifact("a.out")
21+
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
22+
23+
main_thread_stop_line = line_number("main.c", "// Break in main thread")
24+
lldbutil.run_break_set_by_file_and_line(self, "main.c", main_thread_stop_line)
25+
26+
self.runCmd("run", RUN_SUCCEEDED)
27+
28+
self.expect(
29+
"thread info 1",
30+
STOPPED_DUE_TO_BREAKPOINT,
31+
substrs=["stop reason = breakpoint"],
32+
)
33+
34+
# Write back the current vg to confirm read/write works at all.
35+
current_vg = self.match("register read vg", ["(0x[0-9]+)"])
36+
self.assertTrue(current_vg is not None)
37+
self.expect("register write vg {}".format(current_vg.group()))
38+
39+
# Aka 128, 256 and 512 bit.
40+
supported_vg = []
41+
for vg in [2, 4, 8]:
42+
# This could mask other errors but writing vg is tested elsewhere
43+
# so we assume the hardware rejected the value.
44+
self.runCmd("register write vg {}".format(vg), check=False)
45+
if not self.res.GetError():
46+
supported_vg.append(vg)
47+
48+
return supported_vg
49+
1250
def check_sve_registers(self, vg_test_value):
1351
z_reg_size = vg_test_value * 8
1452
p_reg_size = int(z_reg_size / 8)
@@ -56,13 +94,18 @@ def check_sve_registers(self, vg_test_value):
5694
def test_sve_registers_dynamic_config(self):
5795
"""Test AArch64 SVE registers multi-threaded dynamic resize."""
5896

97+
if not self.isAArch64SVE():
98+
self.skipTest("SVE registers must be supported.")
99+
59100
self.build()
101+
supported_vg = self.get_supported_vg()
102+
103+
if not (2 in supported_vg and 4 in supported_vg):
104+
self.skipTest("Not all required SVE vector lengths are supported.")
105+
60106
exe = self.getBuildArtifact("a.out")
61107
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
62108

63-
if not self.isAArch64SVE():
64-
self.skipTest("SVE registers must be supported.")
65-
66109
main_thread_stop_line = line_number("main.c", "// Break in main thread")
67110
lldbutil.run_break_set_by_file_and_line(self, "main.c", main_thread_stop_line)
68111

@@ -90,7 +133,10 @@ def test_sve_registers_dynamic_config(self):
90133
substrs=["stop reason = breakpoint"],
91134
)
92135

93-
self.check_sve_registers(8)
136+
if 8 in supported_vg:
137+
self.check_sve_registers(8)
138+
else:
139+
self.check_sve_registers(4)
94140

95141
self.runCmd("process continue", RUN_SUCCEEDED)
96142

0 commit comments

Comments
 (0)