...
1#!/usr/bin/env bats
2
3load helpers
4
5function setup() {
6 setup_busybox
7 ALT_ROOT="$ROOT/alt"
8 mkdir -p "$ALT_ROOT/state"
9}
10
11function teardown() {
12 if [ -n "$ALT_ROOT" ]; then
13 ROOT=$ALT_ROOT __runc delete -f test_dotbox
14 rm -rf "$ALT_ROOT"
15 fi
16 teardown_bundle
17}
18
19@test "global --root" {
20 # run busybox detached using $ALT_ROOT for state
21 ROOT=$ALT_ROOT runc run -d --console-socket "$CONSOLE_SOCKET" test_dotbox
22 [ "$status" -eq 0 ]
23
24 # run busybox detached in default root
25 runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
26 [ "$status" -eq 0 ]
27
28 runc state test_busybox
29 [ "$status" -eq 0 ]
30 [[ "${output}" == *"running"* ]]
31
32 ROOT=$ALT_ROOT runc state test_dotbox
33 [ "$status" -eq 0 ]
34 [[ "${output}" == *"running"* ]]
35
36 ROOT=$ALT_ROOT runc state test_busybox
37 [ "$status" -ne 0 ]
38
39 runc state test_dotbox
40 [ "$status" -ne 0 ]
41
42 runc kill test_busybox KILL
43 [ "$status" -eq 0 ]
44 wait_for_container 10 1 test_busybox stopped
45 runc delete test_busybox
46 [ "$status" -eq 0 ]
47
48 ROOT=$ALT_ROOT runc kill test_dotbox KILL
49 [ "$status" -eq 0 ]
50 ROOT=$ALT_ROOT wait_for_container 10 1 test_dotbox stopped
51 ROOT=$ALT_ROOT runc delete test_dotbox
52 [ "$status" -eq 0 ]
53}
View as plain text