From 26ac320a03b6b435a5584808b51d007bf06a899e Mon Sep 17 00:00:00 2001 From: Efim Verzakov Date: Fri, 20 Feb 2026 12:27:48 +0000 Subject: [PATCH] integration: add userns and checkpoint integration test Signed-off-by: Efim Verzakov --- tests/integration/helpers.bash | 19 +++++++++++++++++++ tests/integration/userns.bats | 24 ++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 24035eb6486..58a1674c72b 100755 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -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() { @@ -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 diff --git a/tests/integration/userns.bats b/tests/integration/userns.bats index 1f2e83400e8..5fe6529e059 100644 --- a/tests/integration/userns.bats +++ b/tests/integration/userns.bats @@ -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 +}