Skip to content

Commit

Permalink
libct/int: checkpoint test: skip pre-dump if not avail
Browse files Browse the repository at this point in the history
Since we're now testing on ARM, the test case fails when trying to do
pre-dump since MemTrack is not available.

Skip the pre-dump part if so.

This also reverts part of commit 3f4a73d as it is no longer needed
(now, instead of skipping the whole test, we're just skipping the
pre-dump).

[Review with --ignore-all-space]

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed May 10, 2024
1 parent e42d981 commit 36be6d0
Showing 1 changed file with 28 additions and 23 deletions.
51 changes: 28 additions & 23 deletions libcontainer/integration/checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package integration

import (
"bytes"
"errors"
"os"
"os/exec"
"path/filepath"
Expand All @@ -14,11 +13,11 @@ import (
"golang.org/x/sys/unix"
)

func criuFeature(feature string) bool {
return exec.Command("criu", "check", "--feature", feature).Run() == nil
}

func TestUsernsCheckpoint(t *testing.T) {
cmd := exec.Command("criu", "check", "--feature", "userns")
if err := cmd.Run(); err != nil {
t.Skip("Test requires userns")
}
testCheckpoint(t, true)
}

Expand All @@ -41,6 +40,10 @@ func testCheckpoint(t *testing.T, userns bool) {
t.Skip("Test requires criu >= 3.17-4 on CentOS Stream 9.")
}

if userns && !criuFeature("userns") {
t.Skip("Test requires userns")
}

config := newTemplateConfig(t, &tParam{userns: userns})
stateDir := t.TempDir()

Expand Down Expand Up @@ -74,41 +77,43 @@ func testCheckpoint(t *testing.T, userns bool) {
ok(t, err)

tmp := t.TempDir()
var parentImage string

// Test pre-dump if mem_dirty_track is available.
if criuFeature("mem_dirty_track") {
parentImage = "../criu-parent"
parentDir := filepath.Join(tmp, "criu-parent")
preDumpOpts := &libcontainer.CriuOpts{
ImagesDirectory: parentDir,
WorkDirectory: parentDir,
PreDump: true,
}

parentDir := filepath.Join(tmp, "criu-parent")
preDumpOpts := &libcontainer.CriuOpts{
ImagesDirectory: parentDir,
WorkDirectory: parentDir,
PreDump: true,
}

if err := container.Checkpoint(preDumpOpts); err != nil {
if errors.Is(err, libcontainer.ErrCriuMissingFeatures) {
t.Skip(err)
if err := container.Checkpoint(preDumpOpts); err != nil {
t.Fatal(err)
}
t.Fatal(err)
}

state, err := container.Status()
ok(t, err)
state, err := container.Status()
ok(t, err)

if state != libcontainer.Running {
t.Fatal("Unexpected preDump state: ", state)
if state != libcontainer.Running {
t.Fatal("Unexpected preDump state: ", state)
}
}

imagesDir := filepath.Join(tmp, "criu")

checkpointOpts := &libcontainer.CriuOpts{
ImagesDirectory: imagesDir,
WorkDirectory: imagesDir,
ParentImage: "../criu-parent",
ParentImage: parentImage,
}

if err := container.Checkpoint(checkpointOpts); err != nil {
t.Fatal(err)
}

state, err = container.Status()
state, err := container.Status()
ok(t, err)

if state != libcontainer.Stopped {
Expand Down

0 comments on commit 36be6d0

Please sign in to comment.