Skip to content

Commit 21472d0

Browse files
zulinx86roypat
authored andcommitted
test: Check all vCPUs have the same features inside guest
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]>
1 parent da1c3b3 commit 21472d0

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/integration_tests/functional/test_cpu_multiple.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,21 @@ def test_all_vcpus_online(uvm_any):
1616
uvm_any.ssh.check_output("cat /sys/devices/system/cpu/online").stdout.strip()
1717
== f"0-{uvm_any.vcpus_count - 1}"
1818
)
19+
20+
21+
def test_all_vcpus_have_same_features(uvm_any):
22+
"""
23+
Check all vCPUs have the same features inside guest.
24+
25+
This test ensures Firecracker or CPU templates don't configure CPU features
26+
differently between vCPUs.
27+
28+
Note that whether the shown CPU features are expected or not should be
29+
tested in (arch-specific) test_cpu_features_*.py only for vCPU 0. Thus, we
30+
only test the equivalence of all CPUs in the same guest.
31+
"""
32+
# Get a feature set for each CPU and deduplicate them.
33+
unique_feature_lists = uvm_any.ssh.check_output(
34+
'grep -E "^(flags|Features)" /proc/cpuinfo | uniq'
35+
).stdout.splitlines()
36+
assert len(unique_feature_lists) == 1

0 commit comments

Comments
 (0)