testutilsqemu: Mock virTPMSwtpmSetupCapsGet()

In a recent commit of v8.5.0-85-g430ab88ab1 I've made domaincaps
XML report supported TPM versions. This was done by calling
virTPMSwtpmSetupCapsGet(). But this function isn't mocked and
thus domaincapstest calls the real implementation, which tries to
execute swtpm_setup binary. This fails, because
virFindFileInPath() is mocked in such way that it returns NULL
for anything else than qemu-*.

Anyway, while the real binary is not executed after all, we
should mock the function which tries to execute it so that
predictable result is returned.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
Michal Privoznik 2022-07-20 09:11:38 +02:00
parent 18d70df6fc
commit 271d337a56

View File

@ -146,6 +146,24 @@ bool virTPMHasSwtpm(void)
}
bool
virTPMSwtpmSetupCapsGet(virTPMSwtpmSetupFeature cap)
{
switch (cap) {
case VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_PWDFILE_FD:
case VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_CREATE_CONFIG_FILES:
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM12_NOT_NEED_ROOT:
case VIR_TPM_SWTPM_SETUP_FEATURE_CMDARG_RECONFIGURE_PCR_BANKS:
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_1_2:
case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_2_0:
case VIR_TPM_SWTPM_SETUP_FEATURE_LAST:
break;
}
return false;
}
virCapsHostNUMA *
virCapabilitiesHostNUMANewHost(void)
{