swtpm/tests
Stefan Berger 1f9bb04869 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:56:31 -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 19:21:50 -04:00
_test_encrypted_state tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
_test_getcap tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_hashing tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_hashing2 tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_init tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_locality tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_migration_key tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
_test_migration_key_2 tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
_test_print_capabilities tests: Extend regex to allow for optional RSA-4096 keys 2025-05-13 08:56:31 -04:00
_test_print_states tests: Add test cases for using swtpm --print-states while swtpm is running 2024-06-11 08:43:01 -04:00
_test_resume_volatile tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_save_load_encrypted_state tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_save_load_state tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_setbuffersize tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_swtpm_bios tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_avoid_da_lockout tests: Retry NVWrite command after 0x922 return code and inc lockout counter 2025-05-13 08:56:31 -04:00
_test_tpm2_derived_keys tests: Remove unnecessary '\' before '/' 2024-01-08 15:04:38 -05:00
_test_tpm2_encrypted_state tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
_test_tpm2_file_permissions tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
_test_tpm2_getcap tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_hashing tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_tpm2_hashing2 tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_tpm2_hashing3 tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_init tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_locality tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_migration_key tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
_test_tpm2_print_capabilities tests: Extend regex to allow for optional RSA-4096 keys 2025-05-13 08:56:31 -04:00
_test_tpm2_print_states tests: Use regex to compare --print-states sizes output 2024-06-17 12:49:14 -04:00
_test_tpm2_probe tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_resume_volatile tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_tpm2_save_load_encrypted_state tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_save_load_state tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_save_load_state_da_timeout tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
_test_tpm2_save_load_state_locking tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_tpm2_savestate tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_setbuffersize tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_tpm2_swtpm_bios tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
_test_tpm2_volatilestate tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm2_wrongorder tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_tpm_probe tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_volatilestate tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
_test_wrongorder tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
common tests: Remove stray \ in front of - after already escaped '\-' 2023-06-26 20:50:01 -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: Fix shellcheck issue SC2148 by adding a shell directive 2023-01-30 18:25:45 -05:00
Makefile.am build-sys: Add support for --disable-tests to disable tests 2024-03-22 11:18:05 -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: Add softhsm_setup to shellcheck'ed files and fix issues 2023-11-22 07:16:44 -05: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: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_common tests: Fix shellcheck issue SC2148 by adding a shell directive 2023-01-30 18:25:45 -05:00
test_config.in build: remove hardcoded tss user and group 2015-11-02 20:47:37 -05:00
test_ctrlchannel tests: Fix 2 cases of shellcheck SC2001 using bash search-replace 2023-01-30 18:25:45 -05:00
test_ctrlchannel2 tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_ctrlchannel3 tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_ctrlchannel4 tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_cuse tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
test_encrypted_state tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_getcap tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_hashing tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_hashing2 tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_init tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_locality tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_migration_key tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_parameters tests: Fix shellcheck issue SC2115 by using "${var:?}" 2023-01-29 15:04:00 -05:00
test_print_capabilities tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_print_states tests: Add test cases for using swtpm --print-states while swtpm is running 2024-06-11 08:43:01 -04:00
test_resume_volatile tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_samples_create_tpmca tests: Fix shellcheck issue SC2115 by using "${var:?}" 2023-01-29 15:04:00 -05:00
test_save_load_encrypted_state tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_save_load_state tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_setbuffersize tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05: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: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_swtpm_cert tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_swtpm_setup_create_cert tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_swtpm_setup_file_backend tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_swtpm_setup_misc tests: Rearrange order of test cases to run some also as 'root' 2024-03-19 14:28:01 -04:00
test_swtpm_setup_overwrite tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm2_avoid_da_lockout tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_chroot_chardev tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_tpm2_chroot_cuse tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_tpm2_chroot_socket tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_tpm2_ctrlchannel2 tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm2_ctrlchannel3 tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_tpm2_derived_keys tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_encrypted_state tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_file_permissions tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_getcap tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_hashing tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_hashing2 tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_hashing3 tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_ibmtss2 tests: Set OPENSSL_ENABLE_SHA1_SIGNATURES=1 on swtpm in IBMTSS2 test 2025-05-06 19:21:50 -04:00
test_tpm2_init tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_locality tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_migration_key tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_parameters tests: Fix shellcheck issue SC2115 by using "${var:?}" 2023-01-29 15:04:00 -05:00
test_tpm2_partial_reads tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm2_print_capabilities tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_print_states tests: Add test cases for using swtpm --print-states while swtpm is running 2024-06-11 08:43:01 -04:00
test_tpm2_probe tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_resume_volatile tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_samples_create_tpmca.test tests: Fix shellcheck issue SC2115 by using "${var:?}" 2023-01-29 15:04:00 -05:00
test_tpm2_save_load_encrypted_state tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_save_load_state tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_save_load_state_2 tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm2_save_load_state_2_block tests: Fix 3 occurrences of stray '\' before '-' 2024-06-10 19:40:31 -04:00
test_tpm2_save_load_state_2_linear tests: Fix code to pass shellcheck with some errors disabled 2023-01-13 13:59:02 -05:00
test_tpm2_save_load_state_3 tests: Fix spelling mistakes 2023-07-17 20:46:43 -04:00
test_tpm2_save_load_state_da_timeout tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_save_load_state_locking tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_savestate tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_setbuffersize tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_swtpm_bios tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_swtpm_cert tests: Add test cases for swtpm_cert with max serial number 2023-08-26 17:19:29 -04:00
test_tpm2_swtpm_cert_ecc tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm2_swtpm_localca tests: Fix 3 occurrences of stray '\' before '-' 2024-06-10 19:40:31 -04:00
test_tpm2_swtpm_localca_pkcs11.test tests: Fix 3 occurrences of stray '\' before '-' 2024-06-10 19:40:31 -04:00
test_tpm2_swtpm_setup_create_cert tests: Add missing 'exit 1' on unexpected file size on --reconfigure 2023-08-26 17:19:29 -04:00
test_tpm2_swtpm_setup_overwrite tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm2_volatilestate tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm2_vtpm_proxy tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
test_tpm2_wrongorder tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_tpm12 tests: Fix shellcheck issue SC2181 by if cmd; ... 2023-01-27 11:58:54 -05:00
test_tpm_probe tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_volatilestate tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05:00
test_vtpm_proxy tests: Fix newly detected shellcheck issues SC2086 by quoting 2023-06-26 20:50:01 -04:00
test_wrongorder tests: Fix issues related to SC2164 2023-01-13 21:02:51 -05: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"