mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 14:13:58 +08:00
7da77d802e
Some tests (those in help.bats and version.bats) do not use setup_bundle (as they do not need to start any containers), and thus they do not set $ROOT. As a consequence, these tests now call "runc --root /state" which is not nice. Make adding --root conditional (only if $ROOT is set). Amazingly, this change breaks help.bats tests under rootless, because "sudo rootless" does not change the value of XDG_RUNTIME_DIR which still points to root-owned directory, and as a result we have this: > runc foo -h (status=1): > the path in $XDG_RUNTIME_DIR must be writable by the user > time="2022-02-08T07:04:57Z" level=error msg="mkdir /run/user/0/runc: permission denied" This could be fixed by adding proper $ROOT, but it's easier just to skip those tests under non-root. NOTE that version.bats is not broken because -v is handled by urfave/cli very early, so app.Before function is not run. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
95 lines
1.9 KiB
Bash
95 lines
1.9 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
function setup() {
|
|
# It does not make sense to repeat these trivial tests for non-root.
|
|
# Also, they fail due to $ROOT not being set and XDG_RUNTIME_DIR
|
|
# pointing to another user's directory after sudo rootless.
|
|
requires root
|
|
}
|
|
|
|
@test "runc -h" {
|
|
runc -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} =~ NAME:+ ]]
|
|
[[ ${lines[1]} =~ runc\ '-'\ Open\ Container\ Initiative\ runtime+ ]]
|
|
|
|
runc --help
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} =~ NAME:+ ]]
|
|
[[ ${lines[1]} =~ runc\ '-'\ Open\ Container\ Initiative\ runtime+ ]]
|
|
}
|
|
|
|
@test "runc command -h" {
|
|
runc checkpoint -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ checkpoint+ ]]
|
|
|
|
runc delete -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ delete+ ]]
|
|
|
|
runc events -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ events+ ]]
|
|
|
|
runc exec -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ exec+ ]]
|
|
|
|
runc kill -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ kill+ ]]
|
|
|
|
runc list -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} =~ NAME:+ ]]
|
|
[[ ${lines[1]} =~ runc\ list+ ]]
|
|
|
|
runc list --help
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[0]} =~ NAME:+ ]]
|
|
[[ ${lines[1]} =~ runc\ list+ ]]
|
|
|
|
runc pause -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ pause+ ]]
|
|
|
|
runc restore -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ restore+ ]]
|
|
|
|
runc resume -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ resume+ ]]
|
|
|
|
# We don't use runc_spec here, because we're just testing the help page.
|
|
runc spec -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ spec+ ]]
|
|
|
|
runc start -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ start+ ]]
|
|
|
|
runc run -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ run+ ]]
|
|
|
|
runc state -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ state+ ]]
|
|
|
|
runc update -h
|
|
[ "$status" -eq 0 ]
|
|
[[ ${lines[1]} =~ runc\ update+ ]]
|
|
|
|
}
|
|
|
|
@test "runc foo -h" {
|
|
runc foo -h
|
|
[ "$status" -ne 0 ]
|
|
[[ "${output}" == *"No help topic for 'foo'"* ]]
|
|
}
|