mirror of
https://github.com/opencontainers/runc.git
synced 2026-11-06 05:17:05 +00:00
The point of the assert helpers is that a failed test says what it wanted and what it got, so leaving most comparisons as bare [[ ]] defeats it. Convert the rest of the checks on $output and $lines. Those using a glob to look for a substring become --partial, the rest become --regexp (the patterns are translated to extended regular expressions, and anchored where the glob was). The few remaining [[ ]] are not assertions: one is an if condition, and another one is the left hand side of ||, offering an alternative to the assert that follows it. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
58 lines
1.0 KiB
Bash
58 lines
1.0 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" {
|
|
run -0 runc -h
|
|
assert_line --index 0 --regexp 'NAME:+'
|
|
assert_line --index 1 --regexp 'runc - Open Container Initiative runtime+'
|
|
|
|
run -0 runc --help
|
|
assert_line --index 0 --regexp 'NAME:+'
|
|
assert_line --index 1 --regexp 'runc - Open Container Initiative runtime+'
|
|
}
|
|
|
|
@test "runc command -h" {
|
|
local bin
|
|
bin=$(basename "$RUNC")
|
|
local cmds=(
|
|
checkpoint
|
|
create
|
|
delete
|
|
events
|
|
exec
|
|
kill
|
|
list
|
|
pause
|
|
ps
|
|
restore
|
|
resume
|
|
run
|
|
spec
|
|
start
|
|
state
|
|
update
|
|
features
|
|
)
|
|
|
|
for cmd in "${cmds[@]}"; do
|
|
for arg in "-h" "--help"; do
|
|
run -0 runc "$cmd" "$arg"
|
|
assert_line --index 0 --regexp 'NAME:+'
|
|
assert_line --index 1 --regexp "$bin $cmd+"
|
|
done
|
|
done
|
|
}
|
|
|
|
@test "runc foo -h" {
|
|
run ! runc foo -h
|
|
assert_output --partial "No help topic for 'foo'"
|
|
}
|