2016-03-15 03:55:05 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
teardown_hello
|
|
|
|
setup_hello
|
|
|
|
}
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
teardown_hello
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "global --debug" {
|
2016-05-14 06:49:45 +08:00
|
|
|
# run hello-world
|
|
|
|
runc --debug run test_hello
|
2016-03-15 03:55:05 +08:00
|
|
|
echo "${output}"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "global --debug to --log" {
|
2016-05-14 06:49:45 +08:00
|
|
|
# run hello-world
|
|
|
|
runc --log log.out --debug run test_hello
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# check output does not include debug info
|
|
|
|
[[ "${output}" != *"level=debug"* ]]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
|
|
|
# check log.out was generated
|
2016-03-15 03:55:05 +08:00
|
|
|
[ -e log.out ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-03-15 03:55:05 +08:00
|
|
|
# check expected debug output was sent to log.out
|
|
|
|
run cat log.out
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${output}" == *"level=debug"* ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "global --debug to --log --log-format 'text'" {
|
2016-05-14 06:49:45 +08:00
|
|
|
# run hello-world
|
|
|
|
runc --log log.out --log-format "text" --debug run test_hello
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
# check output does not include debug info
|
|
|
|
[[ "${output}" != *"level=debug"* ]]
|
|
|
|
|
2016-05-16 16:21:52 +08:00
|
|
|
# check log.out was generated
|
2016-03-15 03:55:05 +08:00
|
|
|
[ -e log.out ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-03-15 03:55:05 +08:00
|
|
|
# check expected debug output was sent to log.out
|
|
|
|
run cat log.out
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${output}" == *"level=debug"* ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "global --debug to --log --log-format 'json'" {
|
2016-05-14 06:49:45 +08:00
|
|
|
# run hello-world
|
|
|
|
runc --log log.out --log-format "json" --debug run test_hello
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-03-15 03:55:05 +08:00
|
|
|
# check output does not include debug info
|
|
|
|
[[ "${output}" != *"level=debug"* ]]
|
|
|
|
|
2016-05-16 16:21:52 +08:00
|
|
|
# check log.out was generated
|
2016-03-15 03:55:05 +08:00
|
|
|
[ -e log.out ]
|
2016-05-16 16:21:52 +08:00
|
|
|
|
2016-03-15 03:55:05 +08:00
|
|
|
# check expected debug output was sent to log.out
|
|
|
|
run cat log.out
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ "${output}" == *'"level":"debug"'* ]]
|
|
|
|
}
|