Skip to content
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

Add a test for permission denied test case #448

Merged
merged 1 commit into from
Dec 18, 2023
Merged

Add a test for permission denied test case #448

merged 1 commit into from
Dec 18, 2023

Conversation

danielocfb
Copy link
Collaborator

This change adds a test checking expected behavior when access to a symbolization source file is denied.

This change adds a test checking expected behavior when access to a
symbolization source file is denied.

Signed-off-by: Daniel Müller <[email protected]>
@danielocfb danielocfb requested a review from anakryiko December 15, 2023 21:55
Copy link

codecov bot commented Dec 15, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (cdde707) 92.30% compared to head (3ca1660) 92.26%.

❗ Current head 3ca1660 differs from pull request most recent head 9163a49. Consider uploading reports for the commit 9163a49 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #448      +/-   ##
==========================================
- Coverage   92.30%   92.26%   -0.05%     
==========================================
  Files          41       41              
  Lines        6397     6347      -50     
==========================================
- Hits         5905     5856      -49     
+ Misses        492      491       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@anakryiko anakryiko left a comment

Choose a reason for hiding this comment

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

It feels like too much effort just to test this condition, especially taking into account all the "Ugh" remarks ;)

If you absolutely want to have a test for this specific conditions, can you use some root-only file as a source. E.g., /proc/kcore (assuming it's Linux and kcore is present, of course), or /etc/sudoers (seems to not allow reading for non-root).

@d-e-s-o
Copy link
Collaborator

d-e-s-o commented Dec 16, 2023

It feels like too much effort just to test this condition, especially taking into account all the "Ugh" remarks ;)

It does, but the effort has been invested by now. The test is entirely optional and won't run by default (though it will run in CI, but that's a pretty stable environment overall and we can always disable it if it turns out to be flaky).

If you absolutely want to have a test for this specific conditions, can you use some root-only file as a source. E.g., /proc/kcore (assuming it's Linux and kcore is present, of course), or /etc/sudoers (seems to not allow reading for non-root).

The problem is more that all tests are running as root so we will always have access to these files. That's why the fork dance is necessary, so that we can run as different user. The main reason for checking this condition was that I wanted to test the behavior that Salvatore described. There is admittedly no coverage increase, but I'd say it's still valuable to have and risk and maintenance burden seem low to me. Let me know what you think.

Copy link
Member

@anakryiko anakryiko left a comment

Choose a reason for hiding this comment

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

Sure, why not. We can always delete it if it causes problems in the future, of course.

@d-e-s-o
Copy link
Collaborator

d-e-s-o commented Dec 18, 2023

A bunch of the nastiness evaporates once we move this test into a separate binary.

@d-e-s-o d-e-s-o merged commit 8d2332d into libbpf:main Dec 18, 2023
25 checks passed
@d-e-s-o d-e-s-o deleted the topic/permission-denied branch December 18, 2023 16:27
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.

3 participants