From 6fc6f48acdf9b016582e0921756487b84008f914 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 | 42 +++++-------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/tests/integration_tests/functional/test_cpu_template_helper.py b/tests/integration_tests/functional/test_cpu_template_helper.py index ae2e6c5e942..334b04060c4 100644 --- a/tests/integration_tests/functional/test_cpu_template_helper.py +++ b/tests/integration_tests/functional/test_cpu_template_helper.py @@ -372,37 +372,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 consistent. """ - # 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]) - - config_1 = json.loads(cpu_config_1.read_text(encoding="utf-8")) - config_2 = json.loads(cpu_config_2.read_text(encoding="utf-8")) - - # 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 config_1 == empty_cpu_config - assert config_2 == empty_cpu_config + # Dump a fingerprint with the helper tool. + fp1 = tmp_path / "fp1.json" + cpu_template_helper.fingerprint_dump(fp1) + fp2 = tmp_path / "fp2.json" + cpu_template_helper.fingerprint_dump(fp2) + + # Compare them. + cpu_template_helper.fingerprint_compare(fp1, fp2, None)