You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use a single TPM context and avoid race conditions during tests
This implements a singleton to use a single instance of the
tss_espi::Context.
This also avoids race conditions by using a thread-safe mutex to access
the context.
The tests were modified to cleanup generated key handles between test
cases, preventing leftover handles to fill the TPM memory.
Introduce a mutex to allow only a single test that create keys in the
TPM to run at once. It is required that tests that create keys in the
TPM to run the tpm::testing::lock_tests() to obtain the mutex and be
able to continue executing without the risk of other tests filling the
TPM memory.
The QuoteData::fixture implementation (used only during tests) was
modified to flush the created key contexts when dropped. It also was
modified to lock the global mutex by calling the
tpm::testing::lock_tests() and provide the respective guard, preventing
other tests that use the fixture (which necessarily create TPM keys) to
run in parallel.
Note that it is necessary to drop the QuoteData explicitly to guarantee
that the keys are flushed before releasing the global mutex.
Finally, the following changes were made to the tests/run.sh:
* Do not use tpm2-abrmd anymore, and use only the swtpm socket instead
* Stop the started processes at exit
With all these changes, the tests/run.sh can now be executed locally
without any special setting.
Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
0 commit comments