6 Commits

Author SHA1 Message Date
Kir Kolyshkin ac2a53be8e tests: rename AUX_{DIR,UID} to ROOTLESS_AUX_*
Also, fix the typo (AUX_DIX) in cleanup.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2026-04-07 10:53:37 -07:00
Kir Kolyshkin c8c3e8526d tests: fix checks for non-existent variables
Audit all checks for non-empty variables (i.e. ' -z ', ' -n ',
' != ""' and '= ""'), and fix those cases where a variable might be
unset. Those variables (that might not be set) are

 - RUNC_USE_SYSTEMD
 - BATS_RUN_TMPDIR
 - AUX_UID
 - AUX_DIR
 - SD_PARENT_NAME
 - REL_PARENT_PATH
 - ROOT
 - HAVE_CRIU
 - ROOTLESS_FEATURES
 - and a few test-specific or file-specific variables

This should allow us to enable set -u.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-02-28 18:41:35 -08:00
Peter Hunt 6ce2d63a5d libct/init_linux: retry chdir to fix EPERM
Alas, the EPERM on chdir saga continues...

Unfortunately, the there were two releases between when https://github.com/opencontainers/runc/commit/5e0e67d76cc99d76c8228d48f38f37034503f315  was released
and when the workaround https://github.com/opencontainers/runc/pull/2712 was added.

Between this, folks started relying on the ability to have a workdir that the container user doesn't have access to.

Since this case was previously valid, we should continue support for it.

Now, we retry the chdir:
Once at the top of the function (to catch cases where the runc user has access, but container user does not)
and once after we setup user (to catch cases where the container user has access, and the runc user does not)

Add a test case for this as well.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2021-04-06 14:51:43 -04:00
Kir Kolyshkin 41670e21f0 tests/int: rework/simplify setup and teardown
1. Get rid of fixed ROOT, *_BUNDLE, and CONSOLE_SOCKET dirs.
   Now they are temporary directories created in setup_bundle.

2. Automate containers cleanup: instead of having to specify all
   containers to be removed, list and destroy everything (which is
   now possible since every test case has its own unique root).

3. Randomize cgroup paths so two tests running in parallel won't
   use the same cgroup.

Now it's theoretically possible to execute tests in parallel.
Practically it's not possible yet because bats uses GNU parallel,
which do not provide a terminal for whatever it executes, and
many runc tests (all those that run containers with terminal:
true) needs a tty. This may possibly be addressed later.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2021-02-09 20:05:54 -08:00
Kir Kolyshkin 27268b1a7e tests/int/cwd: add test case for cwd not owned by runc
The test setup is complicated, as we want to run it as non-root,
but we need to create a directory owned by a particular user,
and root is needed for chown. To do that, we hijack enable_idmap.

Now, there is no ideal place to clean up AUX_DIR. A function
cleanup is called after the test to do so. Note that it won't
be called if the test fails.

This was verified to fail before and pass after the
previous commit.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 13:23:27 -08:00
Kir Kolyshkin 8bd3b8786b test: add case for GH #2086
Commit 5e0e67d7 ("fix permission denied") modified some code but
did not provide a test case.

This is a test case that was tested to fail before and succeed after
the above commit.

For more details, see https://github.com/opencontainers/runc/pull/2086

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2020-12-18 12:56:48 -08:00