[PATCH 3/3] testutilsqemu: Fake TPM versions

Andrea Bolognani abologna at redhat.com
Mon Aug 1 16:10:31 UTC 2022


On Fri, Jul 29, 2022 at 09:42:13AM +0200, Michal Privoznik wrote:
> +++ b/tests/testutilsqemu.c
> @@ -150,12 +150,13 @@ bool
>  virTPMSwtpmSetupCapsGet(virTPMSwtpmSetupFeature cap)
>  {
>      switch (cap) {
> +    case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_1_2:
> +    case VIR_TPM_SWTPM_SETUP_FEATURE_TPM_2_0:
> +        return true;
>      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;
>      }

So our test suite will work against a mocked TPM that supports a very
small set of hardcoded capabilities. Would it make sense to extend
this so that it's possible to control things as the test case level,
so that we can have coverage for things like e.g. trying to use TPM
1.2 when the swtpm binary only supports TPM 2.0?

That'd all be follow-up work, of course. Your change is good to have
as is :)

Reviewed-by: Andrea Bolognani <abologna at redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization



More information about the libvir-list mailing list