Skip to content

Conversation

@ansasaki
Copy link
Contributor

@ansasaki ansasaki commented Jun 16, 2025

Some tests could fail due to race conditions:

  • In keylime-agent/src/payloads.rs, the test_run_encrypted_payload() and test_payload_worker() could affect each other because both set the environment variable KEYLIME_TEST_DIR
    • This was fixed by adding a mutex to make the tests to not run concurrently
  • In keylime/src/cert.rs, the test_cert_no_server_cert() and test_server_from_server_key() could delete each other's files because they used the same path
    • This was fixed by using a temporary directory for each test, which also avoids the need for cleanup before and after the test

ansasaki added 2 commits June 16, 2025 19:10
The payload tests that set the environment variable `KEYLIME_TEST_DIR`
could affect each other.  This adds a mutex to make these tests to not
run concurrently.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
The tests could enter in a race condition where one test removes the
file while the other is using it. This was caused by the files using the
same path.

This uses a temporary directory for each test.  This makes it
unnecessary to manually remove the files and also avoids the risk of
race conditions since each temporary directory has a unique name.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Copy link
Contributor

@sarroutbi sarroutbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch @ansasaki . LGTM

@ansasaki ansasaki merged commit 2a4daf7 into keylime:master Jun 18, 2025
12 of 13 checks passed
@ansasaki ansasaki deleted the fix_payloads_tests branch June 18, 2025 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants