Skip to content

Commit 93de09b

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 3dd692b commit 93de09b

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

tests/integration_tests/functional/test_cpu_template_helper.py

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -370,37 +370,14 @@ def test_json_static_templates(cpu_template_helper, tmp_path, custom_cpu_templat
370370
cpu_template_helper.template_verify(custom_cpu_template_path)
371371

372372

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

0 commit comments

Comments
 (0)