Skip to content

tests/int: introduce the concept of unsafe tests#5212

Merged
cyphar merged 1 commit intoopencontainers:mainfrom
kolyshkin:unsafe_test
Apr 5, 2026
Merged

tests/int: introduce the concept of unsafe tests#5212
cyphar merged 1 commit intoopencontainers:mainfrom
kolyshkin:unsafe_test

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

Some of runc integration tests may do something that I would not like when running those on my development laptop. Examples include

Yet it is totally fine to do all that in a throwaway CI environment, or inside a Docker container.

Introduce a mechanism to skip specific "unsafe" tests unless an environment variable, RUNC_ALLOW_UNSAFE_TESTS, is set. Use it from a specific checkpoint/restore test which modifies /etc/criu/default.conf.

@kolyshkin
Copy link
Copy Markdown
Contributor Author

Note that the following is not considered "unsafe":

  • adding mounts on the host;
  • adding network interfaces, block loop devices, cgroups etc.;
  • sharing host mount namespace with a test container.

One other "unsafe" case not covered here is rootless idmap tests setup/cleanup in tests/rootless.sh, which renames /usr/bin/new{u,g}idmap binaries and modifies /etc/sub{u,g}id. Maybe we should skip it, too, unless RUNC_ALLOW_UNSAFE_TESTS is set.

@kolyshkin kolyshkin requested review from cyphar, lifubang and rata and removed request for cyphar April 1, 2026 21:23
Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

It seems bats has built-in support for tags/labels, but if you run bats ... <file> it won't work. You can force it to be opt-in. So this SGTM

@kolyshkin
Copy link
Copy Markdown
Contributor Author

It seems bats has built-in support for tags/labels, but if you run bats ... <file> it won't work. You can force it to be opt-in. So this SGTM

Right, I forgot about bats tags. The big issue is, you can't force it to be opt-in (you probably meant the same thing) if you're using bats directly (I often do that on my machine).

Another thing with bats tags is the test is silently excluded rather than skipped, while here the test is shown as skipped with a reason why ("requires unsafe"). To me being visible is slightly better.

Since implementation is rather trivial I'd rather stick to it.

Some of runc integration tests may do something that I would not like
when running those on my development laptop. Examples include

 - changing the root mount propagation [1];
 - replacing /root/runc [2];
 - changing the file in /etc (see checkpoint.bats).

Yet it is totally fine to do all that in a throwaway CI environment,
or inside a Docker container.

Introduce a mechanism to skip specific "unsafe" tests unless an
environment variable, RUNC_ALLOW_UNSAFE_TESTS, is set. Use it
from a specific checkpoint/restore test which modifies
/etc/criu/default.conf.

[1]: opencontainers#5200
[2]: opencontainers#5207

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Copy Markdown
Contributor Author

@opencontainers/runc-maintainers I need more eyes on this to help move #5200 and #5207 forward

Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

SGTM

haven't tested as I'm not on a Linux machine, so assuming this does the skips as expected 😅

@cyphar cyphar merged commit 4f2090f into opencontainers:main Apr 5, 2026
55 checks passed
LIBPATHRS_VERSION: "0.2.4"
RPMS: gcc git-core iptables jq glibc-static libseccomp-devel make criu fuse-sshfs container-selinux policycoreutils cargo lld wget
# Allow potentially unsafe tests.
RUNC_ALLOW_UNSAFE_TESTS: yes
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Does this variable RUNC_ALLOW_UNSAFE_TESTS reach the tests in Cirrus CI correctly?. It seams all integration tests are executed via ssh -tt localhost "make ...", which starts a new login shell.

I checked the cirrus ci logs of this PR and found ok 46 checkpoint and restore with container specific CRIU config # skip test requires unsafe. If the variable works, the comment # skip test requires unsafe won't appear here, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, good catch. Would you mind opening a PR to fix this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants