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

interfaces/builtin, testutil: skip unit test when apparmor_parser is not in PATH #14951

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bboozzoo
Copy link
Contributor

On some distros which support AppArmor, the apparmor_parser binary is located under /usr/sbin, which also happens to not be included in a regular user's $PATH. The sandbox/apparmor package code is able to locate it directly by checking a number of default paths, however the test code simply assumes that it is available in $PATH. Instead of complicating things further, let's skip the offending unit test.

Thanks for helping us make a better snapd!
Have you signed the license agreement and read the contribution guide?

@bboozzoo bboozzoo added the Simple 😃 A small PR which can be reviewed quickly label Jan 20, 2025
…not in PATH

On some distros which support AppArmor, the apparmor_parser binary is
located under /usr/sbin, which also happens to not be included in a
regular user's $PATH. The sandbox/apparmor package code is able to
locate it directly by checking a number of default paths, however the
test code simply assumes that it is available in $PATH. Instead of
complicating things further, let's skip the offending unit test.

Signed-off-by: Maciej Borzecki <[email protected]>
Copy link
Contributor

@zyga zyga left a comment

Choose a reason for hiding this comment

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

LGTM but see my suggestion inline.

@@ -868,6 +871,9 @@ ptrace (read, trace) peer=unconfined,

// Profile existing profile
expectedHash, err := testutil.AppArmorParseAndHashHelper("#include <tunables/global> \nprofile docker_support {" + privilegedProfile + "}")
if err != nil && errors.Is(err, exec.ErrNotFound) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The left hand side is redundant

@bboozzoo bboozzoo force-pushed the bboozzoo/apparmor_parser-in-path branch from e36856a to 6baee6c Compare January 20, 2025 12:28
@bboozzoo bboozzoo changed the title interfaces/builtin, testutil: do not apparmor_parser is in PATH interfaces/builtin, testutil: skip unit test when apparmor_parser is not in PATH Jan 20, 2025
Copy link

github-actions bot commented Jan 20, 2025

Tue Jan 21 14:11:44 UTC 2025
The following results are from: https://github.com/canonical/snapd/actions/runs/12868023702

Failures:

Preparing:

  • openstack:debian-sid-64:tests/main/
  • openstack:opensuse-tumbleweed-64:tests/main/refresh:classic_fake
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-devmode:fake
  • openstack:opensuse-tumbleweed-64:tests/main/refresh:parallel_strict_fake
  • openstack:opensuse-tumbleweed-64:tests/main/revert-devmode:fake
  • openstack:opensuse-tumbleweed-64:tests/main/refresh:strict_fake
  • openstack:opensuse-tumbleweed-64:tests/main/revert:fake
  • openstack:opensuse-tumbleweed-64:tests/main/set-proxy-store

Executing:

  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:hosts
  • openstack:opensuse-tumbleweed-64:tests/main/sudo-env
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:funcarg
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:func
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:plain
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:funky
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:hosts_n_dirs
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:funky
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:plain_plusdirs
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:files
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-many-transactional-undo
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:funcarg
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:hosts_n_dirs
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:files
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:plain
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:funkyfunc
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:func
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:funkyfunc
  • openstack:opensuse-tumbleweed-64:tests/completion/indirect:plain_plusdirs
  • openstack:opensuse-tumbleweed-64:tests/completion/snippets:hosts
  • openstack:opensuse-tumbleweed-64:tests/main/snap-quota-memory
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-gating-from-snap
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-backoff
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:close_mid_restart
  • openstack:opensuse-tumbleweed-64:tests/main/drop-privs
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-many-transactional
  • openstack:opensuse-tumbleweed-64:tests/main/snapd-homedirs
  • openstack:opensuse-tumbleweed-64:tests/main/snap-run
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:ignore
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:restart
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh:regular
  • openstack:opensuse-tumbleweed-64:tests/main/store-state
  • openstack:opensuse-tumbleweed-64:tests/main/snap-refresh-hold
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-all
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-all-undo
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-gating
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-retry
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh:parallel
  • openstack:opensuse-tumbleweed-64:tests/main/auto-refresh-pre-download:close
  • openstack:opensuse-tumbleweed-64:tests/main/refresh-app-awareness-notify
  • google:ubuntu-18.04-64:tests/main/snapd-snap:lxd

Restoring:

  • openstack:opensuse-tumbleweed-64:tests/main/refresh-app-awareness-notify
  • google:ubuntu-18.04-64:tests/main/snapd-snap:lxd
  • google:ubuntu-18.04-64:tests/main/
  • google:ubuntu-18.04-64

Copy link

codecov bot commented Jan 20, 2025

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Please upload report for BASE (master@79632c6). Learn more about missing BASE report.
Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
testutil/apparmor.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master   #14951   +/-   ##
=========================================
  Coverage          ?   78.26%           
=========================================
  Files             ?     1157           
  Lines             ?   153473           
  Branches          ?        0           
=========================================
  Hits              ?   120119           
  Misses            ?    25947           
  Partials          ?     7407           
Flag Coverage Δ
unittests 78.26% <0.00%> (?)

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

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

Copy link
Contributor

@maykathm maykathm left a comment

Choose a reason for hiding this comment

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

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Simple 😃 A small PR which can be reviewed quickly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants