mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 14:13:58 +08:00
2ceb97196e
Bats' run should only be used when we want to check both the command output and its non-zero exit status. Otherwise, we can rely on implicit exit code check (as the tests are run with set -e), or use if, etc. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
84 lines
1.6 KiB
Bash
84 lines
1.6 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load helpers
|
|
|
|
function setup() {
|
|
teardown_busybox
|
|
setup_busybox
|
|
}
|
|
|
|
function teardown() {
|
|
teardown_busybox
|
|
}
|
|
|
|
@test "runc create" {
|
|
runc create --console-socket "$CONSOLE_SOCKET" test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox created
|
|
|
|
# start the command
|
|
runc start test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox running
|
|
}
|
|
|
|
@test "runc create exec" {
|
|
runc create --console-socket "$CONSOLE_SOCKET" test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox created
|
|
|
|
runc exec test_busybox true
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox created
|
|
|
|
# start the command
|
|
runc start test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox running
|
|
}
|
|
|
|
@test "runc create --pid-file" {
|
|
runc create --pid-file pid.txt --console-socket "$CONSOLE_SOCKET" test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox created
|
|
|
|
# check pid.txt was generated
|
|
[ -e pid.txt ]
|
|
|
|
[[ $(cat pid.txt) == $(__runc state test_busybox | jq '.pid') ]]
|
|
|
|
# start the command
|
|
runc start test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox running
|
|
}
|
|
|
|
@test "runc create --pid-file with new CWD" {
|
|
# create pid_file directory as the CWD
|
|
mkdir pid_file
|
|
cd pid_file
|
|
|
|
runc create --pid-file pid.txt -b "$BUSYBOX_BUNDLE" --console-socket "$CONSOLE_SOCKET" test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox created
|
|
|
|
# check pid.txt was generated
|
|
[ -e pid.txt ]
|
|
|
|
[[ $(cat pid.txt) == $(__runc state test_busybox | jq '.pid') ]]
|
|
|
|
# start the command
|
|
runc start test_busybox
|
|
[ "$status" -eq 0 ]
|
|
|
|
testcontainer test_busybox running
|
|
}
|