]> xenbits.xensource.com Git - libvirt.git/commitdiff
testutilsqemu: Mock virTPMSwtpmSetupCapsGet()
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 20 Jul 2022 07:11:38 +0000 (09:11 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 2 Aug 2022 07:03:24 +0000 (09:03 +0200)
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>
tests/testutilsqemu.c

index 6dabbaf36ab5b148863a602c58eca709de492122..00dd9871d1fd7f0c29013944ab490d690dd903c7 100644 (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)
 {