From b7f39dd1e28b629fcdd96a40371236288b80438a Mon Sep 17 00:00:00 2001 From: Takahiro Itazuri Date: Fri, 8 Mar 2024 19:13:17 +0000 Subject: [PATCH] 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 --- .../functional/test_cpu_template_helper.py | 38 +++++-------------- 1 file changed, 10 insertions(+), 28 deletions(-) diff --git a/tests/integration_tests/functional/test_cpu_template_helper.py b/tests/integration_tests/functional/test_cpu_template_helper.py index eba16c775b63..e41be89c6c05 100644 --- a/tests/integration_tests/functional/test_cpu_template_helper.py +++ b/tests/integration_tests/functional/test_cpu_template_helper.py @@ -370,33 +370,15 @@ def test_json_static_templates(cpu_template_helper, tmp_path, custom_cpu_templat cpu_template_helper.template_verify(custom_cpu_template_path) -def test_consecutive_cpu_config_consistency(cpu_template_helper, tmp_path): +def test_consecutive_fingerprint_consistency(cpu_template_helper, tmp_path): """ - Verify that two dumped guest CPU configs obtained consecutively are - consistent. The dumped guest CPU config should not change without - any environmental changes (firecracker, kernel, microcode updates). + Verify that two fingerprints obtained consecutively are consisttent. """ - # Dump CPU config with the helper tool. - cpu_config_1 = tmp_path / "cpu_config_1.json" - cpu_template_helper.template_dump(cpu_config_1) - cpu_config_2 = tmp_path / "cpu_config_2.json" - cpu_template_helper.template_dump(cpu_config_2) - - # Strip common entries. - cpu_template_helper.template_strip([cpu_config_1, cpu_config_2]) - - # Check the stripped result is empty. - if PLATFORM == "x86_64": - empty_cpu_config = { - "cpuid_modifiers": [], - "kvm_capabilities": [], - "msr_modifiers": [], - } - elif PLATFORM == "aarch64": - empty_cpu_config = { - "kvm_capabilities": [], - "reg_modifiers": [], - "vcpu_features": [], - } - assert json.loads(cpu_config_1.read_text(encoding="utf-8")) == empty_cpu_config - assert json.loads(cpu_config_2.read_text(encoding="utf-8")) == empty_cpu_config + # Dump fingerprints with the helper tool. + fingerprint_1 = tmp_path / "fingerprint_1.json" + cpu_template_helper.fingerprint_dump(fingerprint_1) + fingerprint_2 = tmp_path / "fingerprint_2.json" + cpu_template_helper.fingerprint_dump(fingerprint_2) + + # Compare them. + cpu_template_helper.fingerprint_compare(fingerprint_1, fingerprint_2)