[1.2] tests: add RUNC_CMDLINE for tests incompatible with functions

Sometimes we need to run runc through some wrapper (like nohup), but
because "__runc" and "runc" are bash functions in our test suite this
doesn't work trivially -- and you cannot just pass "$RUNC" because you
you need to set --root for rootless tests.

So create a setup_runc_cmdline helper which sets $RUNC_CMDLINE to the
beginning cmdline used by __runc (and switch __runc to use that).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
(Cherry-pick of commit d1f6acfab06e6f5eb15b7edfaa704f50907907b1.)
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
Aleksa Sarai
2025-08-19 17:42:24 +10:00
parent 197c7fcd91
commit a06ff08ea2

View File

@@ -60,10 +60,17 @@ function runc() {
CMDNAME="$(basename "$RUNC")" sane_run __runc "$@"
}
function setup_runc_cmdline() {
RUNC_CMDLINE=("$RUNC")
[[ -v RUNC_USE_SYSTEMD ]] && RUNC_CMDLINE+=("--systemd-cgroup")
[[ -n "${ROOT:-}" ]] && RUNC_CMDLINE+=("--root" "$ROOT/state")
export RUNC_CMDLINE
}
# Raw wrapper for runc.
function __runc() {
"$RUNC" ${RUNC_USE_SYSTEMD+--systemd-cgroup} \
${ROOT:+--root "$ROOT/state"} "$@"
setup_runc_cmdline
"${RUNC_CMDLINE[@]}" "$@"
}
# Wrapper for runc spec.