2016-03-15 03:55:05 +08:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load helpers
|
|
|
|
|
|
|
|
function setup() {
|
|
|
|
teardown_busybox
|
|
|
|
setup_busybox
|
|
|
|
}
|
|
|
|
|
|
|
|
function teardown() {
|
|
|
|
teardown_busybox
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "runc exec" {
|
2016-05-20 08:28:58 +08:00
|
|
|
# run busybox detached
|
|
|
|
runc run -d --console /dev/pts/ptmx test_busybox
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
wait_for_container 15 1 test_busybox
|
|
|
|
|
2016-05-09 21:06:42 +08:00
|
|
|
runc exec test_busybox echo Hello from exec
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-05-16 16:21:52 +08:00
|
|
|
echo text echoed = "'""${output}""'"
|
2016-03-15 03:55:05 +08:00
|
|
|
[[ "${output}" == *"Hello from exec"* ]]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "runc exec --pid-file" {
|
2016-05-20 08:28:58 +08:00
|
|
|
# run busybox detached
|
|
|
|
runc run -d --console /dev/pts/ptmx test_busybox
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
|
|
|
|
wait_for_container 15 1 test_busybox
|
|
|
|
|
2016-05-09 21:06:42 +08:00
|
|
|
runc exec --pid-file pid.txt test_busybox echo Hello from exec
|
2016-03-15 03:55:05 +08:00
|
|
|
[ "$status" -eq 0 ]
|
2016-05-16 16:21:52 +08:00
|
|
|
echo text echoed = "'""${output}""'"
|
2016-03-15 03:55:05 +08:00
|
|
|
[[ "${output}" == *"Hello from exec"* ]]
|
|
|
|
|
2016-05-16 16:21:52 +08:00
|
|
|
# check pid.txt was generated
|
2016-03-15 03:55:05 +08:00
|
|
|
[ -e pid.txt ]
|
|
|
|
|
|
|
|
run cat pid.txt
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[[ ${lines[0]} =~ [0-9]+ ]]
|
|
|
|
}
|