swtpm/tests
Stefan Berger 0e0d346651 tests: Retry NVWrite command after 0x922 return code and inc lockout counter
When returncode 0x922 is received from NVWrite then retry the command so
that it gets the expected error code from failing to provide a password.
When checking the lockout counter, increase the numbers now.

Patched versions of libtpms may not return 0x922 anymore, so write the code
that it can test both cases.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2025-05-13 08:52:56 -04:00
..
data test: Recreate TPM 2 state files with header 2022-05-09 10:15:08 -04:00
patches tests: Remove unnecessary include of openssl/engine.h 2025-05-06 16:01:12 -04:00
_test_encrypted_state tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_getcap tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_hashing tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_hashing2 tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_init tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_locality tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_migration_key tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_migration_key_2 tests: Run tests also on socket interfaces 2017-07-11 14:04:40 -04:00
_test_print_capabilities tests: Extend regex to allow for optional RSA-4096 keys 2025-05-13 08:52:56 -04:00
_test_print_states tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_resume_volatile tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_save_load_encrypted_state tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_save_load_state tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_setbuffersize tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_swtpm_bios tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_tpm2_avoid_da_lockout tests: Retry NVWrite command after 0x922 return code and inc lockout counter 2025-05-13 08:52:56 -04:00
_test_tpm2_derived_keys tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_encrypted_state tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_file_permissions tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_getcap tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_tpm2_hashing tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_hashing2 tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_hashing3 tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_init tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_tpm2_locality tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_migration_key tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_print_capabilities tests: Extend regex to allow for optional RSA-4096 keys 2025-05-13 08:52:56 -04:00
_test_tpm2_print_states tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_tpm2_probe tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_resume_volatile tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_save_load_encrypted_state tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_save_load_state tests: Remove dump of logfile at end of test 2022-08-11 15:02:25 -04:00
_test_tpm2_save_load_state_da_timeout tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_save_load_state_locking tests: Add test case for state migration and storage locking 2022-09-06 14:08:45 -04:00
_test_tpm2_savestate tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_setbuffersize tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_swtpm_bios tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
_test_tpm2_volatilestate tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm2_wrongorder tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_tpm_probe tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_volatilestate tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
_test_wrongorder tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
common tests: Add test case for state migration and storage locking 2022-09-06 14:08:45 -04:00
create_certs.sh scripting: Use #!/usr/bin/env bash rather than /bin/bash 2018-09-10 16:49:12 +00:00
load_vtpm_proxy tests: Skip CUSE TPM related tests if cuse module is not available 2017-02-02 09:01:55 -05:00
Makefile.am build-sys: Add support for --disable-tests to disable tests 2024-03-22 16:52:59 -04:00
Readme.md tests: Add a Readme describing how to run the swtpm tests 2021-03-17 19:19:10 -04:00
softhsm_setup tests: Enable softhsm_setup to work with a temporary directory 2020-08-27 20:26:27 -04:00
swtpm_setup.conf treewide: remove executable bit from config files and c-code 2018-01-17 10:45:25 -05:00
test_clientfds.py swtpm: Implement CMD_LOCK_STORAGE to lock storage 2022-09-06 14:08:45 -04:00
test_commandline tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_common test: Add --log parameter to test logging 2017-02-03 15:15:31 -05:00
test_config.in build: remove hardcoded tss user and group 2015-11-02 20:47:37 -05:00
test_ctrlchannel swtpm: Implement CMD_LOCK_STORAGE to lock storage 2022-09-06 14:08:45 -04:00
test_ctrlchannel2 tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_ctrlchannel3 tests: Test automatic termination upon loss of ctrl channel connection 2022-09-22 13:27:38 -04:00
test_ctrlchannel4 swtpm: Implement CMD_LOCK_STORAGE to lock storage 2022-09-06 14:08:45 -04:00
test_cuse tests: Skip CUSE tests if not compiled with CUSE interface 2018-06-11 10:35:14 -04:00
test_encrypted_state tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_getcap tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_hashing tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_hashing2 tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_init tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_locality tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_migration_key tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_parameters tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_print_capabilities tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_print_states swtpm: Add --print-states for reporting TPM states status 2021-09-07 09:22:51 -04:00
test_resume_volatile tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_samples_create_tpmca tests: Move swtpm_open_cmddev into swtpm_cmd_tx 2022-08-09 17:10:37 -04:00
test_save_load_encrypted_state tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_save_load_state swtpm: Add tests for "linear file" backend 2021-10-05 09:01:30 -04:00
test_setbuffersize tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_setdatafd.py tests: Replicate test_ctrlchannel3 for TPM 2 to test_tpm2_ctrlchannel3 2022-09-22 13:27:38 -04:00
test_swtpm_bios tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_swtpm_cert tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_swtpm_setup_create_cert tests: Use ${WORKDIR} in config files to test env. var replacement 2022-02-23 09:17:11 -05:00
test_swtpm_setup_file_backend tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_swtpm_setup_misc tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_swtpm_setup_overwrite tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_avoid_da_lockout tests: Add test case to check that swtpm sends a TPM2_Shutdown 2022-08-18 09:50:16 -04:00
test_tpm2_chroot_chardev swtpm: Add a chroot option 2022-08-25 10:04:35 -04:00
test_tpm2_chroot_cuse tests: If filesystem is mounted with nodev opt skip CUSE chroot test 2022-08-25 13:13:20 -04:00
test_tpm2_chroot_socket swtpm: Add a chroot option 2022-08-25 10:04:35 -04:00
test_tpm2_ctrlchannel2 tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_ctrlchannel3 tests: Replicate test_ctrlchannel3 for TPM 2 to test_tpm2_ctrlchannel3 2022-09-22 13:27:38 -04:00
test_tpm2_derived_keys tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_encrypted_state tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_file_permissions tests: Add a test case for testing --runas and ability to access files 2021-09-28 09:23:28 -04:00
test_tpm2_getcap tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_hashing tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_hashing2 tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_hashing3 tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_ibmtss2 tests: Set OPENSSL_ENABLE_SHA1_SIGNATURES=1 on swtpm in IBMTSS2 test 2025-05-13 08:52:56 -04:00
test_tpm2_init tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_locality tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_migration_key tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_parameters tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_partial_reads swtpm: cuse: Restrict opening CUSE device to one openable file descriptor 2022-08-09 18:27:07 -04:00
test_tpm2_print_capabilities tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_print_states tests: Add test case for chardev for swtpm --print-states option 2021-10-27 18:58:25 -04:00
test_tpm2_probe tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_resume_volatile tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_samples_create_tpmca.test tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_save_load_encrypted_state tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_save_load_state tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_save_load_state_2 tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_save_load_state_2_block tests: Check for fallocate tool and its support for --posix 2022-08-26 14:41:06 -04:00
test_tpm2_save_load_state_2_linear tests: Use /usr/bin/env bash rather than /bin/bash (BSDs) 2021-10-05 13:50:45 -04:00
test_tpm2_save_load_state_3 tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_save_load_state_da_timeout tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_save_load_state_locking tests: Add test case for state migration and storage locking 2022-09-06 14:08:45 -04:00
test_tpm2_savestate tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_setbuffersize tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_swtpm_bios tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_swtpm_cert tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_swtpm_cert_ecc tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_swtpm_localca tests: Pass --verify-profile=medium to certtool if supported 2022-11-02 11:14:19 -04:00
test_tpm2_swtpm_localca_pkcs11.test tests: Pass --verify-profile=medium to certtool if supported 2022-11-02 11:14:19 -04:00
test_tpm2_swtpm_setup_create_cert tests: Do not activate SHA-1 PCR bank in test case 2022-06-13 21:46:56 -04:00
test_tpm2_swtpm_setup_overwrite tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_volatilestate tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm2_vtpm_proxy tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_tpm2_wrongorder tests: test for availability of TPM 2.0 support in swtpm 2021-08-10 07:13:24 -04:00
test_tpm12 tests: OSSL 3: Make TPM 1.2 test compile; skip IBM TSS 2 test 2021-11-05 12:59:42 -04:00
test_tpm_probe tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_volatilestate tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00
test_vtpm_proxy tests: exit with error code if mktemp fails 2021-11-02 08:35:49 -04:00
test_wrongorder tests: test for availability of TPM 1.2 support in swtpm 2021-08-10 07:13:24 -04:00

This directory contains the swtpm tests.

To run the tests you need to build swtpm first and then you can run the tests using the following command line:

SWTPM_TEST_EXPENSIVE=1 SWTPM_TEST_STORE_VOLATILE=1 SWTPM_TEST_IBMTSS2=1 make check

You may omit the environment variables if you don't want to run the more time-consuming tests.

SWTPM_TEST_EXPENSIVE=1 enables the following tests:

  • test_tpm12
  • test_tpm2_ibmtss2

SWTPM_TEST_STORE_VOLATILE=1 enables storing and restoring of the volatile state at every step of the test_tpm2_ibmtss2 test. This environment variable only has an effect if SWTPM_TEST_EXPENSIVE=1 is set.

SWTPM_TEST_IBMTSS2=1 enables the following tests

  • test_tpm2_save_load_state_2
  • test_tpm2_save_load_state_3

Some tests require root rights, especially those involving the CUSE TPM and the vTPM proxy device. To run these and all the other ones you can use the following command line:

sudo bash -c "SWTPM_TEST_EXPENSIVE=1 SWTPM_TEST_STORE_VOLATILE=1 SWTPM_TEST_IBMTSS2=1 make check"