Files
Kir Kolyshkin 07cd18c9c9 tests/int: use assert for substring and regexp comparisons
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>
2026-10-02 14:47:43 -07:00

42 lines
992 B
Bash

#!/usr/bin/env bats
load helpers
function setup() {
setup_busybox
ALT_ROOT="$ROOT/alt"
mkdir -p "$ALT_ROOT/state"
}
function teardown() {
ROOT=$ALT_ROOT runc delete -f test_dotbox
unset ALT_ROOT
teardown_bundle
}
@test "global --root" {
# run busybox detached using $ALT_ROOT for state
ROOT=$ALT_ROOT run -0 runc run -d --console-socket "$CONSOLE_SOCKET" test_dotbox
# run busybox detached in default root
run -0 runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
run -0 runc state test_busybox
assert_output --partial "running"
ROOT=$ALT_ROOT run -0 runc state test_dotbox
assert_output --partial "running"
ROOT=$ALT_ROOT run ! runc state test_busybox
run ! runc state test_dotbox
run -0 runc kill test_busybox KILL
wait_for_container 10 1 test_busybox stopped
run -0 runc delete test_busybox
ROOT=$ALT_ROOT run -0 runc kill test_dotbox KILL
ROOT=$ALT_ROOT wait_for_container 10 1 test_dotbox stopped
ROOT=$ALT_ROOT run -0 runc delete test_dotbox
}