Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,19 @@ function have_criu() {
run ! grep -q '^criu-3\.17-[123]\.el9' <<<"$ver"
}

function have_criu_version() {
local major_required minor_required
major_required=$(echo "$1" | cut -d. -f1)
minor_required=$(echo "$1" | cut -d. -f2)

local current_ver major_current minor_current
current_ver=$(criu --version | grep Version | awk '{print $2}')
major_current=$(echo "$current_ver" | cut -d. -f1)
minor_current=$(echo "$current_ver" | cut -d. -f2)

[[ $major_current -gt $major_required || ($major_current -eq $major_required && $minor_current -ge $minor_required) ]]
}

# Allows a test to specify what things it requires. If the environment can't
# support it, the test is skipped with a message.
function requires() {
Expand All @@ -508,6 +521,12 @@ function requires() {
skip "requires CRIU feature ${var}"
fi
;;
criu_version_*)
var=${var#criu_version_}
if ! have_criu_version "$var"; then
skip "requires CRIU version ${var}"
fi
;;
root)
if [ $EUID -ne 0 ] || in_userns; then
skip_me=1
Expand Down
24 changes: 24 additions & 0 deletions tests/integration/userns.bats
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,27 @@ function teardown() {
# is deleted during the namespace cleanup.
run ! ip link del dummy0
}

@test "checkpoint userns container" {
requires criu root criu_version_4.3

runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]

testcontainer test_busybox running

for _ in $(seq 2); do
runc checkpoint --work-path ./work-dir test_busybox
[ "$status" -eq 0 ]

testcontainer test_busybox checkpointed

# we need to chown images because child process can try to read them.
chown -R 100000:200000 ./checkpoint

runc restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]

testcontainer test_busybox running
done
}