diff --git a/libvirt/tests/cfg/cpu/aarch64_cpu_sve.cfg b/libvirt/tests/cfg/cpu/aarch64_cpu_sve.cfg index ff8de345e32..152c48c2ce6 100644 --- a/libvirt/tests/cfg/cpu/aarch64_cpu_sve.cfg +++ b/libvirt/tests/cfg/cpu/aarch64_cpu_sve.cfg @@ -41,9 +41,13 @@ vector_lenth_list = '[{"sve":"disable"}, {"sve128":"require"}]' define_error = "yes" expect_msg = "SVE disabled, but SVE vector lengths provided" + - host_sve_check: + only negative_test + check_host_sve = "yes" + status_error = "yes" variants: - positive_test: status_error = "no" - negative_test: - only invalid_length, conflict_length + only invalid_length, conflict_length, host_sve_check status_error = "yes" diff --git a/libvirt/tests/src/cpu/aarch64_cpu_sve.py b/libvirt/tests/src/cpu/aarch64_cpu_sve.py index f0bab842961..500ba952d10 100644 --- a/libvirt/tests/src/cpu/aarch64_cpu_sve.py +++ b/libvirt/tests/src/cpu/aarch64_cpu_sve.py @@ -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") + check_host_sve = "yes" == params.get("check_host_sve", "no") expect_sve = "yes" == params.get("expect_sve", "yes") expect_msg = params.get("expect_msg", "") vector_length = params.get("vector_length", "sve") @@ -57,10 +58,15 @@ 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") + if not check_host_sve: + test.cancel("Host supports SVE") + else: + return + # To enable SVE: Hardware support && enable kconfig # CONFIG_ARM64_SVE if session.cmd_status(check_sve_config % current_boot): @@ -86,7 +92,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) @@ -155,7 +161,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))