Skip to content

Commit abe2901

Browse files
authored
hypervisor_cpu_models: add test for new command (#6324)
* hypervisor_cpu_models: add test for new command New command added in libvirt 11.2.0. Signed-off-by: Sebastian Mitterle <[email protected]> * hypervisor_cpu_model: enable on x86_64 Add config for x86_64. Signed-off-by: Sebastian Mitterle <[email protected]> * hypervisor_cpu_model: enable aarch64 Add config to enable aarch64 coverage. Signed-off-by: Sebastian Mitterle <[email protected]> * fix libvirt_version check Config was available but forgot to check version in code with that config. Signed-off-by: Sebastian Mitterle <[email protected]> * cfg: remove unused parameters Initially this configuration was reused from a similar test case. However, these parameters are not necessary anymore. Signed-off-by: Sebastian Mitterle <[email protected]> --------- Signed-off-by: Sebastian Mitterle <[email protected]>
1 parent de38b62 commit abe2901

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
- virsh.hypervisor_cpu_models:
2+
type = virsh_hypervisor_cpu_models
3+
func_supported_since_libvirt_ver = (11, 2, 0)
4+
options = ""
5+
start_vm = no
6+
variants:
7+
- positive_test:
8+
status_error = "no"
9+
variants:
10+
- default:
11+
- all:
12+
options = "--all"
13+
- valid_parameter_values:
14+
s390-virtio:
15+
options = "--all --arch s390x --machine s390-ccw-virtio --emulator /usr/libexec/qemu-kvm --virttype kvm"
16+
x86_64:
17+
options = "--all --arch x86_64 --machine q35 --emulator /usr/libexec/qemu-kvm --virttype kvm"
18+
aarch64:
19+
options = "--all --arch aarch64 --machine virt --emulator /usr/libexec/qemu-kvm --virttype kvm"
20+
- negative_test:
21+
status_error = "yes"
22+
variants:
23+
- invalid_arch:
24+
options = "--arch invalid"
25+
- invalid_virttype:
26+
options = "--virttype invalid"
27+
- invalid_machine:
28+
options = "--machine invalid"
29+
- invalid_emulator:
30+
options = "--virttype invalid"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import logging as log
2+
3+
from virttest import libvirt_version
4+
from virttest import virsh
5+
from virttest.utils_test import libvirt as utlv
6+
from virttest.libvirt_xml.domcapability_xml import DomCapabilityXML
7+
8+
9+
logging = log.getLogger("avocado." + __name__)
10+
11+
12+
def compare_cpu_model_with_domcapabilities(test, params, result):
13+
"""
14+
Compare the available CPUs with those returned by domcapabilities.
15+
16+
:param test: the test instance
17+
:param params: the test parameters
18+
:param result: the output from hypervisor-cpu-models
19+
"""
20+
xml = DomCapabilityXML()
21+
hc_models = [x for x in result.stdout_text.split("\n") if x != ""]
22+
if "--all" in params.get("options"):
23+
xpath = "/cpu/mode/model"
24+
else:
25+
xpath = "/cpu/mode/model[@usable='yes']"
26+
dc_models = [str(x.text) for x in xml.xmltreefile.findall(xpath)]
27+
difference = set(dc_models) ^ set(hc_models)
28+
if difference and difference != set(""):
29+
test.fail(f"Model list should be identical. Difference: {difference}")
30+
test.log.debug("All models were found in hypervisor-cpu-models")
31+
32+
33+
def run(test, params, env):
34+
"""
35+
Test command virsh hypervisor-cpu-models
36+
"""
37+
options = params.get("options", "")
38+
status_error = "yes" == params.get("status_error", "no")
39+
40+
libvirt_version.is_libvirt_feature_supported(params)
41+
42+
result = virsh.hypervisor_cpu_models(options, ignore_status=True, debug=True)
43+
utlv.check_exit_status(result, expect_error=status_error)
44+
if not status_error:
45+
compare_cpu_model_with_domcapabilities(test, params, result)

0 commit comments

Comments
 (0)