Hi Julia, On Wed, 2 Aug 2023 at 02:35, Julia Daxenberger <julia.daxenber...@infineon.com> wrote: > > Patch 1/2 of this series provides basic testing of the get_test_result > functionality. This Patch adds further testing of possible error > scenarios, but relies on rebooting sandbox at the beginning of the test. > > Signed-off-by: Julia Daxenberger <julia.daxenber...@infineon.com> > --- > Changes in v2: > - Add error test cases reliant on restart_uboot() in response to Simon > Glass <s...@chromium.org> > > test/py/tests/test_tpm2.py | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py > index 96bed36c5f..8416ff5d0b 100644 > --- a/test/py/tests/test_tpm2.py > +++ b/test/py/tests/test_tpm2.py > @@ -322,12 +322,40 @@ def test_tpm2_get_test_result(u_boot_console): > Ask the TPM to get the test result of the self test. > Display the Test Result and Test Result Data. > > + Expected default return value of tpm2_get_test_result, if the TPM has > not been initialized: > + - TPM2_RC_INITIALIZE = TPM2_RC_VER1 + 0x0000 = 0x00000100. > + > Expected default value for test_result: > + - TPM_RC_NEEDS_TEST = 0x00000153, if tpm2 self_test has not been > executed. > - TPM_RC_SUCCESS = 0x00000000, if testing is complete without functional > failures. > > There is no expected default value for the test result data because it > would depend on the chip > used. The test result data is therefore not tested. > """ > + if is_sandbox(u_boot_console): > + u_boot_console.restart_uboot()
Actually sandbox should not need a restart. What is missing about the current state init in dm_test_pre_run()? > + > + skip_test = u_boot_console.config.env.get('env__tpm_device_test_skip', > False) > + if skip_test: > + pytest.skip('skip TPM device test') > + > + read_res = u_boot_console.run_command('tpm2 get_test_result') > + output = u_boot_console.run_command('echo $?') > + assert 'Error: 256' in read_res > + > + u_boot_console.run_command('tpm2 init') > + read_res = u_boot_console.run_command('tpm2 get_test_result') > + output = u_boot_console.run_command('echo $?') > + assert 'Error: 256' in read_res > + > + u_boot_console.run_command('tpm2 startup TPM2_SU_CLEAR') > + read_res = u_boot_console.run_command('tpm2 get_test_result') > + output = u_boot_console.run_command('echo $?') > + """assert output.endswith('0')""" > + assert 'Test Result:\r\r\n0x00000153 TPM2_RC_NEEDS_TEST' in read_res > + """ Assert console output. Test Result Data can not be tested, as it is > vendor specific""" > + assert 'Test Result Data of Self Test:\r\r\n0x' in read_res > + > u_boot_console.run_command('tpm2 self_test full') > read_res = u_boot_console.run_command('tpm2 get_test_result') > output = u_boot_console.run_command('echo $?') > -- > 2.34.1 > Regards, Simon