Skip to content

Commit 36be6d0

Browse files
committed
libct/int: checkpoint test: skip pre-dump if not avail
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 <[email protected]>
1 parent e42d981 commit 36be6d0

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

libcontainer/integration/checkpoint_test.go

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package integration
22

33
import (
44
"bytes"
5-
"errors"
65
"os"
76
"os/exec"
87
"path/filepath"
@@ -14,11 +13,11 @@ import (
1413
"golang.org/x/sys/unix"
1514
)
1615

16+
func criuFeature(feature string) bool {
17+
return exec.Command("criu", "check", "--feature", feature).Run() == nil
18+
}
19+
1720
func TestUsernsCheckpoint(t *testing.T) {
18-
cmd := exec.Command("criu", "check", "--feature", "userns")
19-
if err := cmd.Run(); err != nil {
20-
t.Skip("Test requires userns")
21-
}
2221
testCheckpoint(t, true)
2322
}
2423

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

43+
if userns && !criuFeature("userns") {
44+
t.Skip("Test requires userns")
45+
}
46+
4447
config := newTemplateConfig(t, &tParam{userns: userns})
4548
stateDir := t.TempDir()
4649

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

7679
tmp := t.TempDir()
80+
var parentImage string
81+
82+
// Test pre-dump if mem_dirty_track is available.
83+
if criuFeature("mem_dirty_track") {
84+
parentImage = "../criu-parent"
85+
parentDir := filepath.Join(tmp, "criu-parent")
86+
preDumpOpts := &libcontainer.CriuOpts{
87+
ImagesDirectory: parentDir,
88+
WorkDirectory: parentDir,
89+
PreDump: true,
90+
}
7791

78-
parentDir := filepath.Join(tmp, "criu-parent")
79-
preDumpOpts := &libcontainer.CriuOpts{
80-
ImagesDirectory: parentDir,
81-
WorkDirectory: parentDir,
82-
PreDump: true,
83-
}
84-
85-
if err := container.Checkpoint(preDumpOpts); err != nil {
86-
if errors.Is(err, libcontainer.ErrCriuMissingFeatures) {
87-
t.Skip(err)
92+
if err := container.Checkpoint(preDumpOpts); err != nil {
93+
t.Fatal(err)
8894
}
89-
t.Fatal(err)
90-
}
9195

92-
state, err := container.Status()
93-
ok(t, err)
96+
state, err := container.Status()
97+
ok(t, err)
9498

95-
if state != libcontainer.Running {
96-
t.Fatal("Unexpected preDump state: ", state)
99+
if state != libcontainer.Running {
100+
t.Fatal("Unexpected preDump state: ", state)
101+
}
97102
}
98103

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

101106
checkpointOpts := &libcontainer.CriuOpts{
102107
ImagesDirectory: imagesDir,
103108
WorkDirectory: imagesDir,
104-
ParentImage: "../criu-parent",
109+
ParentImage: parentImage,
105110
}
106111

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

111-
state, err = container.Status()
116+
state, err := container.Status()
112117
ok(t, err)
113118

114119
if state != libcontainer.Stopped {

0 commit comments

Comments
 (0)