summaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-05-24 07:06:35 -0600
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2025-06-10 19:35:26 +0300
commitedc4bfd2e32a58b09e88f8a12e5e97d72232c6ff (patch)
tree873af99dc92dd4509f16de4bc003dcf9753ecb04 /test/py
parent1f144b61740d4e0acf15cc82911bc6129f2f814e (diff)
tpm: Convert sandbox-focussed tests to C
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 fully initializes the TPM and performs the self tests. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Diffstat (limited to 'test/py')
-rw-r--r--test/py/tests/test_tpm2.py38
1 files changed, 1 insertions, 37 deletions
diff --git a/test/py/tests/test_tpm2.py b/test/py/tests/test_tpm2.py
index 064651c3e23..e55adfe784c 100644
--- a/test/py/tests/test_tpm2.py
+++ b/test/py/tests/test_tpm2.py
@@ -56,7 +56,7 @@ def is_sandbox(ubman):
return sys_arch == 'sandbox'
@pytest.mark.buildconfigspec('cmd_tpm_v2')
-def test_tpm2_init(ubman):
+def test_tpm2_autostart(ubman):
"""Init the software stack to use TPMv2 commands."""
skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
if skip_test:
@@ -65,19 +65,6 @@ def test_tpm2_init(ubman):
output = ubman.run_command('echo $?')
assert output.endswith('0')
-@pytest.mark.buildconfigspec('cmd_tpm_v2')
-def test_tpm2_startup(ubman):
- """Execute a TPM2_Startup command.
-
- Initiate the TPM internal state machine.
- """
- skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
- if skip_test:
- pytest.skip('skip TPM device test')
- ubman.run_command('tpm2 startup TPM2_SU_CLEAR')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
def tpm2_sandbox_init(ubman):
"""Put sandbox back into a known state so we can run a test
@@ -93,29 +80,6 @@ def tpm2_sandbox_init(ubman):
pytest.skip('skip TPM device test')
@pytest.mark.buildconfigspec('cmd_tpm_v2')
-def test_tpm2_sandbox_self_test_full(ubman):
- """Execute a TPM2_SelfTest (full) command.
-
- Ask the TPM to perform all self tests to also enable full capabilities.
- """
- if is_sandbox(ubman):
- ubman.restart_uboot()
- ubman.run_command('tpm2 autostart')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
- ubman.run_command('tpm2 startup TPM2_SU_CLEAR')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
- skip_test = ubman.config.env.get('env__tpm_device_test_skip', False)
- if skip_test:
- pytest.skip('skip TPM device test')
- ubman.run_command('tpm2 self_test full')
- output = ubman.run_command('echo $?')
- assert output.endswith('0')
-
-@pytest.mark.buildconfigspec('cmd_tpm_v2')
def test_tpm2_continue_self_test(ubman):
"""Execute a TPM2_SelfTest (continued) command.