Skip to content

Commit

Permalink
test: Check all vCPUs have the same features inside guest
Browse files Browse the repository at this point in the history
The test ensures Firecracker or CPU templates don't configure CPU
features differently between vCPUs.

Note that whether the printed CPU features are expected or not should be
tested in (arch-specific) test_cpu_features_*.py only for vCPU 0. Thus,
we only test the equivalence of all CPUs in the same guest.

Signed-off-by: Takahiro Itazuri <[email protected]>
  • Loading branch information
zulinx86 committed Dec 9, 2024
1 parent db7720b commit 2a86306
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/integration_tests/functional/test_cpu_multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
are operating identically, except for the expected differences.
"""

from framework.properties import global_props


def test_all_vcpus_online(uvm_any):
"""Check all vCPUs are online inside guest"""
Expand All @@ -17,3 +19,23 @@ def test_all_vcpus_online(uvm_any):
uvm_any.ssh.check_output(f"cat /sys/devices/system/cpu/online").stdout.strip()
== f"0-{uvm_any.vcpus_count - 1}"
)


def test_all_vcpus_have_same_features(uvm_any):
"""
Check all vCPUs have the same features inside guest.
This test ensures Firecracker or CPU templates don't configure CPU features
differently between vCPUs.
Note that whether the shown CPU features are expected or not should be
tested in (arch-specific) test_cpu_features_*.py only for vCPU 0. Thus, we
only test the equivalence of all CPUs in the same guest.
"""
# Get a feature list of all CPUs
field = "flags" if global_props.cpu_architecture == "x86_64" else "Features"
features = uvm_any.ssh.check_output(
f"cat /proc/cpuinfo | grep f{field}"
).stdout.splitlines()
for idx in range(1, uvm_any.vcpus_count):
assert features[0] == features[idx]

0 comments on commit 2a86306

Please sign in to comment.