Skip to content

Commit e81248e

Browse files
committed
feat(aarch64): add host vs guest cpu feature test
Add test comparing host and guest default cpu features. Currently only available for aarch64. Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent ae30a82 commit e81248e

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

tests/framework/utils_cpuid.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
from framework.utils import check_output
1111
from framework.utils_imdsv2 import imdsv2_get
1212

13+
CPU_FEATURES_CMD = r"lscpu |grep -oP '^Flags:\s+\K.+'"
14+
1315

1416
class CpuVendor(Enum):
1517
"""CPU vendors enum."""

tests/integration_tests/functional/test_cpu_features_aarch64.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import pytest
99

1010
import framework.utils_cpuid as cpuid_utils
11-
from framework.utils_cpuid import CpuModel
11+
from framework import utils
12+
from framework.utils_cpuid import CPU_FEATURES_CMD, CpuModel
1213

1314
PLATFORM = platform.machine()
1415

@@ -48,7 +49,7 @@ def _check_cpu_features_arm(test_microvm, guest_kv, template_name=None):
4849
case CpuModel.ARM_NEOVERSE_V1, _, None:
4950
expected_cpu_features = DEFAULT_G3_FEATURES_5_10
5051

51-
_, stdout, _ = test_microvm.ssh.check_output(r"lscpu |grep -oP '^Flags:\s+\K.+'")
52+
_, stdout, _ = test_microvm.ssh.check_output(CPU_FEATURES_CMD)
5253
flags = set(stdout.strip().split(" "))
5354
assert flags == expected_cpu_features
5455

@@ -63,6 +64,37 @@ def get_cpu_template_dir(cpu_template):
6364
return cpu_template if cpu_template else "none"
6465

6566

67+
@pytest.mark.skipif(
68+
PLATFORM != "aarch64",
69+
reason="This is aarch64 specific test.",
70+
)
71+
def test_host_vs_guest_cpu_features_aarch64(uvm_nano):
72+
"""Check CPU features host vs guest"""
73+
74+
vm = uvm_nano
75+
vm.add_net_iface()
76+
vm.start()
77+
host_feats = set(utils.check_output(CPU_FEATURES_CMD).stdout.strip().split(" "))
78+
guest_feats = set(vm.ssh.check_output(CPU_FEATURES_CMD).stdout.strip().split(" "))
79+
80+
cpu_model = cpuid_utils.get_cpu_model_name()
81+
match cpu_model:
82+
case CpuModel.ARM_NEOVERSE_N1:
83+
assert host_feats - guest_feats == set()
84+
assert guest_feats - host_feats == {"ssbs"}
85+
case CpuModel.ARM_NEOVERSE_V1:
86+
assert host_feats - guest_feats == {
87+
"pacg",
88+
"sve",
89+
"paca",
90+
"svebf16",
91+
"svei8mm",
92+
}
93+
assert guest_feats - host_feats == {"ssbs"}
94+
case _:
95+
assert False, f"Cpu model {cpu_model} is not supported"
96+
97+
6698
@pytest.mark.skipif(
6799
PLATFORM != "aarch64",
68100
reason="This is aarch64 specific test.",

0 commit comments

Comments
 (0)