Skip to content

Commit a6c14bd

Browse files
committed
test: Cover all CPU templates in test_cpu_template
Preciously the test only supported static CPU templates. Now all the custom CPU templates are also tested. That helps test newer custom CPU templates (e.g. a CPU template for Intel Sapphire Rapids). Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent ad6ad45 commit a6c14bd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/integration_tests/functional/test_cpu_features_x86_64.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,23 +652,26 @@ def test_cpu_cpuid_restore(microvm_factory, guest_kernel, cpu_template_any):
652652
)
653653

654654

655-
@pytest.mark.parametrize("cpu_template", ["T2", "T2S", "C3"])
656-
def test_cpu_template(uvm_plain_any, cpu_template, microvm_factory):
655+
def test_cpu_template(uvm_plain_any, cpu_template_any, microvm_factory):
657656
"""
658657
Test masked and enabled cpu features against the expected template.
659658
660659
This test checks that all expected masked features are not present in the
661660
guest and that expected enabled features are present for each of the
662661
supported CPU templates.
663662
"""
663+
cpu_template = get_cpu_template_name_str(cpu_template_any)
664+
if cpu_template not in ["t2", "t2s", "c3"]:
665+
pytest.skip("CPU template not supported by this test")
666+
664667
test_microvm = uvm_plain_any
665668
test_microvm.spawn()
666669
# Set template as specified in the `cpu_template` parameter.
667670
test_microvm.basic_config(
668671
vcpu_count=1,
669672
mem_size_mib=256,
670-
cpu_template=cpu_template,
671673
)
674+
test_microvm.set_cpu_template(cpu_template_any)
672675
test_microvm.add_net_iface()
673676

674677
if cpuid_utils.get_cpu_vendor() != cpuid_utils.CpuVendor.INTEL:
@@ -696,7 +699,7 @@ def check_masked_features(test_microvm, cpu_template):
696699
"""Verify the masked features of the given template."""
697700
# fmt: off
698701
must_be_unset = []
699-
if cpu_template == "C3":
702+
if cpu_template == "c3":
700703
must_be_unset = [
701704
(0x1, 0x0, "ecx",
702705
(1 << 2) | # DTES64
@@ -781,7 +784,7 @@ def check_masked_features(test_microvm, cpu_template):
781784
(1 << 26) # PDPE1GB
782785
),
783786
]
784-
elif cpu_template in ("T2", "T2S"):
787+
elif cpu_template in ("t2", "t2s"):
785788
must_be_unset = [
786789
(0x1, 0x0, "ecx",
787790
(1 << 2) | # DTES64
@@ -955,7 +958,7 @@ def check_enabled_features(test_microvm, cpu_template):
955958
cpuid_utils.check_guest_cpuid_output(
956959
test_microvm, "cpuid -1", None, "=", enabled_list
957960
)
958-
if cpu_template == "T2":
961+
if cpu_template == "t2":
959962
t2_enabled_features = {
960963
"FMA instruction": "true",
961964
"BMI1 instructions": "true",

0 commit comments

Comments
 (0)