Skip to content

Commit d56f643

Browse files
committed
test: Check consecutive fingerprints consistency
Previously, only consecutive guest CPU configs were verified. A fingerprint contains not only guest CPU config but also host configuration. Signed-off-by: Takahiro Itazuri <[email protected]>
1 parent b482181 commit d56f643

File tree

1 file changed

+10
-32
lines changed

1 file changed

+10
-32
lines changed

tests/integration_tests/functional/test_cpu_template_helper.py

+10-32
Original file line numberDiff line numberDiff line change
@@ -374,37 +374,15 @@ def test_json_static_templates(cpu_template_helper, tmp_path, custom_cpu_templat
374374
cpu_template_helper.template_verify(custom_cpu_template_path)
375375

376376

377-
def test_consecutive_cpu_config_consistency(cpu_template_helper, tmp_path):
377+
def test_consecutive_fingerprint_consistency(cpu_template_helper, tmp_path):
378378
"""
379-
Verify that two dumped guest CPU configs obtained consecutively are
380-
consistent. The dumped guest CPU config should not change without
381-
any environmental changes (firecracker, kernel, microcode updates).
379+
Verify that two fingerprints obtained consecutively are consistent.
382380
"""
383-
# Dump CPU config with the helper tool.
384-
cpu_config_1 = tmp_path / "cpu_config_1.json"
385-
cpu_template_helper.template_dump(cpu_config_1)
386-
cpu_config_2 = tmp_path / "cpu_config_2.json"
387-
cpu_template_helper.template_dump(cpu_config_2)
388-
389-
# Strip common entries.
390-
cpu_template_helper.template_strip([cpu_config_1, cpu_config_2])
391-
392-
config_1 = json.loads(cpu_config_1.read_text(encoding="utf-8"))
393-
config_2 = json.loads(cpu_config_2.read_text(encoding="utf-8"))
394-
395-
# Check the stripped result is empty.
396-
if PLATFORM == "x86_64":
397-
empty_cpu_config = {
398-
"cpuid_modifiers": [],
399-
"kvm_capabilities": [],
400-
"msr_modifiers": [],
401-
}
402-
elif PLATFORM == "aarch64":
403-
empty_cpu_config = {
404-
"kvm_capabilities": [],
405-
"reg_modifiers": [],
406-
"vcpu_features": [],
407-
}
408-
409-
assert config_1 == empty_cpu_config
410-
assert config_2 == empty_cpu_config
381+
# Dump a fingerprint with the helper tool.
382+
fp1 = tmp_path / "fp1.json"
383+
cpu_template_helper.fingerprint_dump(fp1)
384+
fp2 = tmp_path / "fp2.json"
385+
cpu_template_helper.fingerprint_dump(fp2)
386+
387+
# Compare them.
388+
cpu_template_helper.fingerprint_compare(fp1, fp2, None)

0 commit comments

Comments
 (0)