...
1#!/usr/bin/env bats
2
3load helpers
4
5function setup() {
6 setup_busybox
7}
8
9function teardown() {
10 teardown_bundle
11}
12
13@test "runc create" {
14 runc create --console-socket "$CONSOLE_SOCKET" test_busybox
15 [ "$status" -eq 0 ]
16
17 testcontainer test_busybox created
18
19 # start the command
20 runc start test_busybox
21 [ "$status" -eq 0 ]
22
23 testcontainer test_busybox running
24}
25
26@test "runc create exec" {
27 runc create --console-socket "$CONSOLE_SOCKET" test_busybox
28 [ "$status" -eq 0 ]
29
30 testcontainer test_busybox created
31
32 runc exec test_busybox true
33 [ "$status" -eq 0 ]
34
35 testcontainer test_busybox created
36
37 # start the command
38 runc start test_busybox
39 [ "$status" -eq 0 ]
40
41 testcontainer test_busybox running
42}
43
44@test "runc create --pid-file" {
45 runc create --pid-file pid.txt --console-socket "$CONSOLE_SOCKET" test_busybox
46 [ "$status" -eq 0 ]
47
48 testcontainer test_busybox created
49
50 # check pid.txt was generated
51 [ -e pid.txt ]
52
53 [[ $(cat pid.txt) == $(__runc state test_busybox | jq '.pid') ]]
54
55 # start the command
56 runc start test_busybox
57 [ "$status" -eq 0 ]
58
59 testcontainer test_busybox running
60}
61
62@test "runc create --pid-file with new CWD" {
63 bundle="$(pwd)"
64 # create pid_file directory as the CWD
65 mkdir pid_file
66 cd pid_file
67
68 runc create --pid-file pid.txt -b "$bundle" --console-socket "$CONSOLE_SOCKET" test_busybox
69 [ "$status" -eq 0 ]
70
71 testcontainer test_busybox created
72
73 # check pid.txt was generated
74 [ -e pid.txt ]
75
76 [[ $(cat pid.txt) == $(__runc state test_busybox | jq '.pid') ]]
77
78 # start the command
79 runc start test_busybox
80 [ "$status" -eq 0 ]
81
82 testcontainer test_busybox running
83}
View as plain text