Skip to content

Commit

Permalink
Add new test case for SVE support
Browse files Browse the repository at this point in the history
This commit adds a new test case
to check the SVE support on the
host.

Signed-off-by: Aakanksha Tripathi <[email protected]>
  • Loading branch information
Aakanksha0311 authored and root committed Nov 22, 2023
1 parent de5a309 commit c3321b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
6 changes: 5 additions & 1 deletion libvirt/tests/cfg/cpu/aarch64_cpu_sve.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@
vector_lenth_list = '[{"sve":"disable"}, {"sve128":"require"}]'
define_error = "yes"
expect_msg = "SVE disabled, but SVE vector lengths provided"
- no_host_sve_support:
only negative_test
host_without_sve = "yes"
status_error = "yes"
variants:
- positive_test:
status_error = "no"
- negative_test:
only invalid_length, conflict_length
only invalid_length, conflict_length, no_host_sve_support
status_error = "yes"
21 changes: 15 additions & 6 deletions libvirt/tests/src/cpu/aarch64_cpu_sve.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def run(test, params, env):

status_error = "yes" == params.get("status_error", "no")
define_error = "yes" == params.get("define_error", "no")
host_without_sve = "yes" == params.get("host_without_sve", "no")
expect_sve = "yes" == params.get("expect_sve", "yes")
expect_msg = params.get("expect_msg", "")
vector_length = params.get("vector_length", "sve")
Expand All @@ -57,10 +58,17 @@ def _prepare_env(vm):
if (not utils_package.package_install("util-linux")
or not utils_package.package_install("util-linux", session)):
test.error("Failed to install util-linux")
# Cancel test if host doesn't support SVE
if process.run(check_sve,
ignore_status=True, shell=True).exit_status:
test.cancel("Host doesn't support SVE")

# Cancel test if the Host doesn't support or supports SVE based on configuration
if process.run(check_sve, ignore_status=True, shell=True).exit_status:
if not host_without_sve:
test.cancel("Host doesn't support SVE")
else:
return
else:
if host_without_sve:
test.cancel("Host supports SVE")

# To enable SVE: Hardware support && enable kconfig
# CONFIG_ARM64_SVE
if session.cmd_status(check_sve_config % current_boot):
Expand All @@ -86,7 +94,7 @@ def _get_maxium_sve_length(vm):
session = vm.wait_for_login(timeout=120)
ret = session.cmd(get_maxium_sve_length).strip()
# dmesg record maximum sve length in bytes
sve_length_byte = re.search("length (\d+) bytes", ret).groups()[0]
sve_length_byte = re.search(r"length (\d+) bytes", ret).groups()[0]
# Change max_length into sve + length(bit) E.g. sve512
sve_length_bit = "sve" + str(int(sve_length_byte) * 8)
logging.debug("guest sve_length_bit is %s" % sve_length_bit)
Expand Down Expand Up @@ -155,7 +163,8 @@ def _guest_has_sve(vm):
except LibvirtXMLError as e:
if define_error:
if not re.search(expect_msg, str(e)):
test.fail("Expect definition failure: %s but got %s" % (expect_msg, str(e)))
test.fail("Expect definition failure: %s but got %s" %
(expect_msg, str(e)))
return True
else:
test.error("Failed to define guest: %s" % str(e))
Expand Down

0 comments on commit c3321b3

Please sign in to comment.