mirror of
https://github.com/opencontainers/runc.git
synced 2025-09-27 03:46:19 +08:00
[1.3] tests: add sane_run helper
"runc" was a special wrapper around bats's "run" which output some very useful diagnostic information to the bats log, but this was not usable for other commands. So let's make it a more generic helper that we can use for other commands. Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (Cherry-pick of commit ea385de40c9a006737399bc72918a19e5d038736.) Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
@@ -36,18 +36,27 @@ ARCH=$(uname -m)
|
||||
# Seccomp agent socket.
|
||||
SECCCOMP_AGENT_SOCKET="$BATS_TMPDIR/seccomp-agent.sock"
|
||||
|
||||
# Wrapper for runc.
|
||||
function runc() {
|
||||
run __runc "$@"
|
||||
# Wrapper around "run" that logs output to make tests easier to debug.
|
||||
function sane_run() {
|
||||
local cmd="$1"
|
||||
local cmdname="${CMDNAME:-$(basename "$cmd")}"
|
||||
shift
|
||||
|
||||
run "$cmd" "$@"
|
||||
|
||||
# Some debug information to make life easier. bats will only print it if the
|
||||
# test failed, in which case the output is useful.
|
||||
# shellcheck disable=SC2154
|
||||
echo "$(basename "$RUNC") $* (status=$status):" >&2
|
||||
echo "$cmdname $* (status=$status)" >&2
|
||||
# shellcheck disable=SC2154
|
||||
echo "$output" >&2
|
||||
}
|
||||
|
||||
# Wrapper for runc.
|
||||
function runc() {
|
||||
CMDNAME="$(basename "$RUNC")" sane_run __runc "$@"
|
||||
}
|
||||
|
||||
# Raw wrapper for runc.
|
||||
function __runc() {
|
||||
"$RUNC" ${RUNC_USE_SYSTEMD+--systemd-cgroup} \
|
||||
|
Reference in New Issue
Block a user