2016-05-27 05:44:59 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
teardown_busybox
|
|
|
|
setup_busybox
|
|
|
|
}
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
teardown_busybox
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "runc create" {
|
2016-09-06 20:40:01 +08:00
|
|
|
runc create --console-socket $CONSOLE_SOCKET test_busybox
|
2016-05-27 05:44:59 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox created
|
|
|
|
|
|
|
|
# start the command
|
2016-05-28 04:13:11 +08:00
|
|
|
runc start test_busybox
|
2016-05-27 05:44:59 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox running
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "runc create exec" {
|
2016-09-06 20:40:01 +08:00
|
|
|
runc create --console-socket $CONSOLE_SOCKET test_busybox
|
2016-05-27 05:44:59 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox created
|
|
|
|
|
2016-05-28 04:13:11 +08:00
|
|
|
runc exec test_busybox true
|
2016-05-27 05:44:59 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2016-09-06 20:40:01 +08:00
|
|
|
testcontainer test_busybox created
|
|
|
|
|
2016-05-27 05:44:59 +08:00
|
|
|
# start the command
|
2016-05-28 04:13:11 +08:00
|
|
|
runc start test_busybox
|
2016-05-27 05:44:59 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox running
|
|
|
|
}
|
2016-10-20 12:05:05 +08:00
|
|
|
|
|
|
|
@test "runc create --pid-file" {
|
2016-09-06 20:40:01 +08:00
|
|
|
runc create --pid-file pid.txt --console-socket $CONSOLE_SOCKET test_busybox
|
2016-10-20 12:05:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox created
|
|
|
|
|
|
|
|
# check pid.txt was generated
|
|
|
|
[ -e pid.txt ]
|
|
|
|
|
|
|
|
run cat pid.txt
|
|
|
|
[ "$status" -eq 0 ]
|
2016-10-25 15:00:51 +08:00
|
|
|
[[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]]
|
2016-10-20 12:05:05 +08:00
|
|
|
|
|
|
|
# start the command
|
|
|
|
runc start test_busybox
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox running
|
|
|
|
}
|
2016-11-01 19:13:49 +08:00
|
|
|
|
|
|
|
@test "runc create --pid-file with new CWD" {
|
|
|
|
# create pid_file directory as the CWD
|
|
|
|
run mkdir pid_file
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
run cd pid_file
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
2016-09-06 20:40:01 +08:00
|
|
|
runc create --pid-file pid.txt -b $BUSYBOX_BUNDLE --console-socket $CONSOLE_SOCKET test_busybox
|
2016-11-01 19:13:49 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox created
|
|
|
|
|
|
|
|
# check pid.txt was generated
|
|
|
|
[ -e pid.txt ]
|
|
|
|
|
|
|
|
run cat pid.txt
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ ${lines[0]} == $(__runc state test_busybox | jq '.pid') ]]
|
|
|
|
|
|
|
|
# start the command
|
|
|
|
runc start test_busybox
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
testcontainer test_busybox running
|
|
|
|
}
|