Skip to content

Commit 5340349

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 95057ce commit 5340349

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
@@ -656,23 +656,26 @@ def test_cpu_cpuid_restore(microvm_factory, guest_kernel, cpu_template_any):
656656
)
657657

658658

659-
@pytest.mark.parametrize("cpu_template", ["T2", "T2S", "C3"])
660-
def test_cpu_template(uvm_plain_any, cpu_template, microvm_factory):
659+
def test_cpu_template(uvm_plain_any, cpu_template_any, microvm_factory):
661660
"""
662661
Test masked and enabled cpu features against the expected template.
663662
664663
This test checks that all expected masked features are not present in the
665664
guest and that expected enabled features are present for each of the
666665
supported CPU templates.
667666
"""
667+
cpu_template = get_cpu_template_name_str(cpu_template_any)
668+
if cpu_template not in ["t2", "t2s", "c3"]:
669+
pytest.skip("CPU template not supported by this test")
670+
668671
test_microvm = uvm_plain_any
669672
test_microvm.spawn()
670673
# Set template as specified in the `cpu_template` parameter.
671674
test_microvm.basic_config(
672675
vcpu_count=1,
673676
mem_size_mib=256,
674-
cpu_template=cpu_template,
675677
)
678+
test_microvm.set_cpu_template(cpu_template_any)
676679
test_microvm.add_net_iface()
677680

678681
if cpuid_utils.get_cpu_vendor() != cpuid_utils.CpuVendor.INTEL:
@@ -700,7 +703,7 @@ def check_masked_features(test_microvm, cpu_template):
700703
"""Verify the masked features of the given template."""
701704
# fmt: off
702705
must_be_unset = []
703-
if cpu_template == "C3":
706+
if cpu_template == "c3":
704707
must_be_unset = [
705708
(0x1, 0x0, "ecx",
706709
(1 << 2) | # DTES64
@@ -785,7 +788,7 @@ def check_masked_features(test_microvm, cpu_template):
785788
(1 << 26) # PDPE1GB
786789
),
787790
]
788-
elif cpu_template in ("T2", "T2S"):
791+
elif cpu_template in ("t2", "t2s"):
789792
must_be_unset = [
790793
(0x1, 0x0, "ecx",
791794
(1 << 2) | # DTES64
@@ -959,7 +962,7 @@ def check_enabled_features(test_microvm, cpu_template):
959962
cpuid_utils.check_guest_cpuid_output(
960963
test_microvm, "cpuid -1", None, "=", enabled_list
961964
)
962-
if cpu_template == "T2":
965+
if cpu_template == "t2":
963966
t2_enabled_features = {
964967
"FMA instruction": "true",
965968
"BMI1 instructions": "true",

0 commit comments

Comments
 (0)