Skip to content

context_info_handler: Do not assume /var/lib/keylime exists #1044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2025

Conversation

ansasaki
Copy link
Contributor

@ansasaki ansasaki commented Jul 10, 2025

This changes the tests in the context_info_handler.rs to not assume the /var/lib/keylime exists.

In tests, whenever a configuration is necessary, the config::get_testing_config() should be called, passing the path to a temporary directory as argument so that it overrides the keylime_dir option to not use the default /var/lib/keylime.

Note that this is only available when the testing feature is enabled.

This is necessary to avoid the tests to fail when the /var/lib/keylime directory is not present, for example in build systems or when the tests are executed before Keylime is installed.

This changes the tests in the context_info_handler.rs to not assume the
/var/lib/keylime exists.

In tests, whenever a configuration is necessary, the
`config::get_testing_config()` should be called, passing the path to a
temporary directory as argument so that it overrides the `keylime_dir`
option to not use the default `/var/lib/keylime`.

Note that this is only available when the `testing` feature is enabled.

This is necessary to avoid the tests to fail when the `/var/lib/keylime`
directory is not present, for example in build systems or when the tests
are executed before Keylime is installed.

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

codecov bot commented Jul 10, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.54%. Comparing base (5893499) to head (bff526e).
Report is 1 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
e2e-testsuite 58.54% <ø> (-0.04%) ⬇️
upstream-unit-tests 58.54% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ylime-push-model-agent/src/context_info_handler.rs 49.12% <ø> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@@ -101,16 +102,15 @@ mod tests {
}

#[tokio::test]
#[cfg(feature = "testing")]
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you remove this "testing" feature label? If I am not wrong, all the TPM related tests are executed with it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it is redundant, the whole tests module is annotated (see the line 78 above), which means it is only compiled when the testing feature is enabled.

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.

LGTM

@ansasaki ansasaki merged commit f42ccea into keylime:master Jul 10, 2025
13 of 15 checks passed
@ansasaki ansasaki deleted the fix_context_info_test branch July 10, 2025 14:58
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