[PATCH 2/3] tpm: Convert sandbox-focussed tests to C

Ilias Apalodimas ilias.apalodimas at linaro.org
Mon Oct 30 12:40:05 CET 2023


Hi Tom

On Sun, 29 Oct 2023 at 16:33, Tom Rini <trini at konsulko.com> wrote:
>
> On Sun, Oct 29, 2023 at 05:28:13PM +1300, Simon Glass wrote:
>
> > Some of the Python tests are a pain because they don't reset the TPM
> > state before each test. Driver model tests do this, so convert the
> > tests to C.
> >
> > This means that these tests won't run on real hardware, but we have
> > tests which do TPM init, so there is still enough coverage.
> >
> > Rename and update the Python tpm_init test to use 'tpm autostart',
> > since this deals with starting up ready for the tests below.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
>
> I worry that we're removing maybe a few too many of the tests we can be
> used on real HW (and QEMU, another real use case) in favor of just
> testing them on sandbox. We can certainly have parallel sandbox-only
> test paths.

I think we are fine.  The auto start that is being called now
initializes the TPM and performs the sefltests.
So the removed tests are covered by just calling 'tpm autostart'.  The
only only opn that shouldn't be removed is
test_tpm2_continue_self_test

>
> [snip]
> > @@ -92,46 +79,6 @@ def tpm2_sandbox_init(u_boot_console):
> >      if skip_test:
> >          pytest.skip('skip TPM device test')
> >
> > - at pytest.mark.buildconfigspec('cmd_tpm_v2')
> > -def test_tpm2_sandbox_self_test_full(u_boot_console):
> > -    """Execute a TPM2_SelfTest (full) command.
> > -
> > -    Ask the TPM to perform all self tests to also enable full capabilities.
> > -    """
> > -    if is_sandbox(u_boot_console):
> > -        u_boot_console.restart_uboot()
> > -        u_boot_console.run_command('tpm2 init')
> > -        output = u_boot_console.run_command('echo $?')
> > -        assert output.endswith('0')
> > -
> > -        u_boot_console.run_command('tpm2 startup TPM2_SU_CLEAR')
> > -        output = u_boot_console.run_command('echo $?')
> > -        assert output.endswith('0')
> > -
> > -    skip_test = u_boot_console.config.env.get('env__tpm_device_test_skip', False)
> > -    if skip_test:
> > -        pytest.skip('skip TPM device test')
> > -    u_boot_console.run_command('tpm2 self_test full')
> > -    output = u_boot_console.run_command('echo $?')
> > -    assert output.endswith('0')
> > -
> > - at pytest.mark.buildconfigspec('cmd_tpm_v2')
> > -def test_tpm2_continue_self_test(u_boot_console):
> > -    """Execute a TPM2_SelfTest (continued) command.
> > -
> > -    Ask the TPM to finish its self tests (alternative to the full test) in order
> > -    to enter a fully operational state.
> > -    """
> > -
> > -    skip_test = u_boot_console.config.env.get('env__tpm_device_test_skip', False)
> > -    if skip_test:
> > -        pytest.skip('skip TPM device test')
> > -    if is_sandbox(u_boot_console):
> > -        tpm2_sandbox_init(u_boot_console)
> > -    u_boot_console.run_command('tpm2 self_test continue')
> > -    output = u_boot_console.run_command('echo $?')
> > -    assert output.endswith('0')
> > -
>
> I would think these are useful cases to check outside of sandbox. But
> I'll let Ilias chime in as I'm just assuming.

Yep that's the only one we should preserve

Thanks
/Ilias
>
> --
> Tom


More information about the U-Boot mailing list