tests/checkpoint.bats: simplify status checks

Introduce a special case for `testcontainer` to test
for container that is not present (checkpointed), use it.

Fix one place where testcontainer was not used.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin 2020-04-19 21:28:15 -07:00
parent 69d599ddbd
commit e216457eea
2 changed files with 9 additions and 11 deletions

View File

@ -33,8 +33,7 @@ function teardown() {
[ "$status" -eq 0 ]
# after checkpoint busybox is no longer running
runc state test_busybox
[ "$status" -ne 0 ]
testcontainer test_busybox checkpointed
# restore from checkpoint
runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox
@ -87,9 +86,7 @@ function teardown() {
[ "$status" -eq 0 ]
# busybox should still be running
runc state test_busybox
[ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]]
testcontainer test_busybox running
# checkpoint the running container
mkdir image-dir
@ -99,8 +96,7 @@ function teardown() {
[ "$status" -eq 0 ]
# after checkpoint busybox is no longer running
runc state test_busybox
[ "$status" -ne 0 ]
testcontainer test_busybox checkpointed
# restore from checkpoint
__runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_busybox <&60 >&51 2>&51
@ -271,8 +267,7 @@ function teardown() {
[ "$status" -eq 0 ]
# after checkpoint busybox is no longer running
runc state test_busybox
[ "$status" -ne 0 ]
testcontainer test_busybox checkpointed
# restore from checkpoint; this should restore the container into the existing network namespace
runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox
@ -327,8 +322,7 @@ function teardown() {
test -f ./work-dir/$tmplog2
# after checkpoint busybox is no longer running
runc state test_busybox
[ "$status" -ne 0 ]
testcontainer test_busybox checkpointed
test -f ./work-dir/$tmplog2 && unlink ./work-dir/$tmplog2
# restore from checkpoint

View File

@ -310,6 +310,10 @@ function wait_for_container_inroot() {
function testcontainer() {
# test state of container
runc state $1
if [ $2 == "checkpointed" ]; then
[ "$status" -eq 1 ]
return
fi
[ "$status" -eq 0 ]
[[ "${output}" == *"$2"* ]]
}