On 8/1/22 18:10, Andrea Bolognani wrote:
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?
Good point. We could have an environment variable that, if set, would
make this function return just a subset of TPM versions. And then, when
we want to test scenario you suggest we could do the following:
setenv("VIR_TEST_MOCK_FAKE_TPM_VERSION", "1.2");
DO_TEST_FAILURE("guest-tpm-2.0");
unsetenv("VIR_TEST_MOCK_FAKE_TPM_VERSION");
Alternatively, we can modify the DO_TEST_* macro so that it accepts TPM
version and sets the ENV var accordingly, but I'd rather not do that,
because it's not very extensible.
That'd all be follow-up work, of course. Your change is good to have
as is :)
In fact, I can just not merge this patch and send v2 of this patch that
implements the idea from above. I'll push the other two though, because
they fix the issue.
Reviewed-by: Andrea Bolognani <abologna(a)redhat.com>
Thanks!
Michal