...
1#!/usr/bin/env bats
2
3load helpers
4
5function setup() {
6 setup_busybox
7 update_config '.process.args = ["/bin/echo", "Hello World"]'
8}
9
10function teardown() {
11 teardown_bundle
12}
13
14function check_debug() {
15 [[ "$*" == *"nsexec container setup"* ]]
16 [[ "$*" == *"child process in init()"* ]]
17 [[ "$*" == *"init: closing the pipe to signal completion"* ]]
18}
19
20@test "global --debug" {
21 # run hello-world
22 runc --debug run test_hello
23 [ "$status" -eq 0 ]
24
25 # check expected debug output was sent to stderr
26 [[ "${output}" == *"level=debug"* ]]
27 check_debug "$output"
28}
29
30@test "global --debug to --log" {
31 # run hello-world
32 runc --log log.out --debug run test_hello
33 [ "$status" -eq 0 ]
34
35 # check output does not include debug info
36 [[ "${output}" != *"level=debug"* ]]
37
38 cat log.out >&2
39 # check expected debug output was sent to log.out
40 output=$(cat log.out)
41 [[ "${output}" == *"level=debug"* ]]
42 check_debug "$output"
43}
44
45@test "global --debug to --log --log-format 'text'" {
46 # run hello-world
47 runc --log log.out --log-format "text" --debug run test_hello
48 [ "$status" -eq 0 ]
49
50 # check output does not include debug info
51 [[ "${output}" != *"level=debug"* ]]
52
53 cat log.out >&2
54 # check expected debug output was sent to log.out
55 output=$(cat log.out)
56 [[ "${output}" == *"level=debug"* ]]
57 check_debug "$output"
58}
59
60@test "global --debug to --log --log-format 'json'" {
61 # run hello-world
62 runc --log log.out --log-format "json" --debug run test_hello
63 [ "$status" -eq 0 ]
64
65 # check output does not include debug info
66 [[ "${output}" != *"level=debug"* ]]
67
68 cat log.out >&2
69 # check expected debug output was sent to log.out
70 output=$(cat log.out)
71 [[ "${output}" == *'"level":"debug"'* ]]
72 check_debug "$output"
73}
View as plain text