diff --git a/tests/framework/utils_cpuid.py b/tests/framework/utils_cpuid.py index 65e953f43ac..4303e3ba967 100644 --- a/tests/framework/utils_cpuid.py +++ b/tests/framework/utils_cpuid.py @@ -10,6 +10,8 @@ from framework.utils import check_output from framework.utils_imdsv2 import imdsv2_get +CPU_FEATURES_CMD = r"lscpu |grep -oP '^Flags:\s+\K.+'" + class CpuVendor(Enum): """CPU vendors enum.""" diff --git a/tests/integration_tests/functional/test_cpu_features_aarch64.py b/tests/integration_tests/functional/test_cpu_features_aarch64.py index a1066da21a5..120b4af951a 100644 --- a/tests/integration_tests/functional/test_cpu_features_aarch64.py +++ b/tests/integration_tests/functional/test_cpu_features_aarch64.py @@ -8,7 +8,8 @@ import pytest import framework.utils_cpuid as cpuid_utils -from framework.utils_cpuid import CpuModel +from framework import utils +from framework.utils_cpuid import CpuModel, CPU_FEATURES_CMD PLATFORM = platform.machine() @@ -48,7 +49,7 @@ def _check_cpu_features_arm(test_microvm, guest_kv, template_name=None): case CpuModel.ARM_NEOVERSE_V1, _, None: expected_cpu_features = DEFAULT_G3_FEATURES_5_10 - _, stdout, _ = test_microvm.ssh.check_output(r"lscpu |grep -oP '^Flags:\s+\K.+'") + _, stdout, _ = test_microvm.ssh.check_output(CPU_FEATURES_CMD) flags = set(stdout.strip().split(" ")) assert flags == expected_cpu_features @@ -63,6 +64,30 @@ def get_cpu_template_dir(cpu_template): return cpu_template if cpu_template else "none" +@pytest.mark.skipif( + PLATFORM != "aarch64", + reason="This is aarch64 specific test.", +) +def test_host_vs_guest_cpu_features_aarch64(uvm_nano): + """Check CPU features host vs guest""" + + vm = uvm_nano + vm.add_net_iface() + vm.start() + host_feats = set(utils.check_output(CPU_FEATURES_CMD).stdout.strip().split(" ")) + guest_feats = set(vm.ssh.check_output(CPU_FEATURES_CMD).stdout.strip().split(" ")) + + match cpuid_utils.get_cpu_model_name(): + case CpuModel.ARM_NEOVERSE_N1: + assert host_feats - guest_feats == set() + assert guest_feats - host_feats == {"ssbs"} + case CpuModel.ARM_NEOVERSE_V1: + assert host_feats - guest_feats == {"pacg", "sve", "paca", "svebf16", "svei8mm"} + assert guest_feats - host_feats == {"ssbs"} + case _: + assert False, f"Please onboard new CpuModel {global_props.cpu_model}" + + @pytest.mark.skipif( PLATFORM != "aarch64", reason="This is aarch64 specific test.",