Skip to content

Commit

Permalink
test: Use fingerprint verify command
Browse files Browse the repository at this point in the history
Now that the fingerprint verify command is available, replaces dump +
compare commands with verify command. Also, removes
`detect_fingerprint_change()` since it is only used by
`test_guest_cpu_config_change()`.

Signed-off-by: Takahiro Itazuri <itazur@amazon.com>
  • Loading branch information
zulinx86 committed Mar 11, 2024
1 parent 8042375 commit 3dd692b
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions tests/integration_tests/functional/test_cpu_template_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def fingerprint_compare(
cmd += f" --filters {' '.join(filters)}"
utils.run_cmd(cmd)

def fingerprint_verify(self, baseline_path, output_path, filters):
"""Verify the given baseline fingerprint."""
cmd = (
f"{self.binary} fingerprint verify"
f" --baseline {baseline_path} --output {output_path}"
)
if filters:
cmd += f" --filters {' '.join(filters)}"
utils.run_cmd(cmd)


@pytest.fixture(scope="session", name="cpu_template_helper")
def cpu_template_helper_fixture():
Expand Down Expand Up @@ -320,12 +330,15 @@ def test_cpu_config_dump_vs_actual(
), f"Mismatched MSR for {key:#010x}: {actual=:#066b} vs. {dump=:#066b}"


def detect_fingerprint_change(
results_dir, cpu_template_helper, filters=None
):
@pytest.mark.no_block_pr
@pytest.mark.skipif(
global_props.host_linux_version not in SUPPORTED_HOST_KERNELS,
reason=f"Supported kernels are {SUPPORTED_HOST_KERNELS}",
)
def test_guest_cpu_config_change(results_dir, cpu_template_helper):
"""
Compare fingerprint files with filters between one taken at the moment and
a baseline file taken in a specific point in time.
Verify that the guest CPU config has not changed since the baseline
fingerprint was gathered.
"""
fname = f"fingerprint_{global_props.cpu_codename}_{global_props.host_linux_version}host.json"

Expand All @@ -336,27 +349,10 @@ def detect_fingerprint_change(
# Baseline fingerprint.
baseline_path = TEST_RESOURCES_DIR / fname

# Compare with baseline
cpu_template_helper.fingerprint_compare(
# Verify the baseline fingerprint.
cpu_template_helper.fingerprint_verify(
baseline_path,
fingerprint_path,
filters,
)


@pytest.mark.no_block_pr
@pytest.mark.skipif(
global_props.host_linux_version not in SUPPORTED_HOST_KERNELS,
reason=f"Supported kernels are {SUPPORTED_HOST_KERNELS}",
)
def test_guest_cpu_config_change(results_dir, cpu_template_helper):
"""
Verify that the guest CPU config has not changed since the baseline
fingerprint was gathered.
"""
detect_fingerprint_change(
results_dir,
cpu_template_helper,
["guest_cpu_config"],
)

Expand Down

0 comments on commit 3dd692b

Please sign in to comment.