Files
runc/tests/integration/root.bats
Kir Kolyshkin 99d5c0231f tests/int/{root,list}.bats: ALT_ROOT fixups in teardown
1. Add "unset ALT_ROOT" since it should not be used after teardown is
   called.

2. Remove "rm -rf $ALT_ROOT". It is not needed, because ALT_ROOT is a
   subdirectory of ROOT, which is removed in teardown_bundle.

3. Checking for ALT_ROOT being non-empty is a leftover from the era when
   teardown() was called as the first step from setup(). Since commit
   41670e21f0 this is no longer the case, so the condition
   is no longer needed (plus, the `set -u` which is about to be added
   should catch any possible use of unset ALT_ROOT).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2022-02-28 18:39:08 -08:00

52 lines
1.1 KiB
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 runc run -d --console-socket "$CONSOLE_SOCKET" test_dotbox
[ "$status" -eq 0 ]
# run busybox detached in default root
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]
runc state test_busybox
[ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]]
ROOT=$ALT_ROOT runc state test_dotbox
[ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]]
ROOT=$ALT_ROOT runc state test_busybox
[ "$status" -ne 0 ]
runc state test_dotbox
[ "$status" -ne 0 ]
runc kill test_busybox KILL
[ "$status" -eq 0 ]
wait_for_container 10 1 test_busybox stopped
runc delete test_busybox
[ "$status" -eq 0 ]
ROOT=$ALT_ROOT runc kill test_dotbox KILL
[ "$status" -eq 0 ]
ROOT=$ALT_ROOT wait_for_container 10 1 test_dotbox stopped
ROOT=$ALT_ROOT runc delete test_dotbox
[ "$status" -eq 0 ]
}