MCPcopy
hub / github.com/opencontainers/runc / testCheckpoint

Function testCheckpoint

libcontainer/integration/checkpoint_test.go:27–170  ·  view source on GitHub ↗
(t *testing.T, userns bool)

Source from the content-addressed store, hash-verified

25}
26
27func testCheckpoint(t *testing.T, userns bool) {
28 if testing.Short() {
29 return
30 }
31
32 if _, err := exec.LookPath("criu"); err != nil {
33 t.Skipf("criu binary not found: %v", err)
34 }
35
36 // Workaround for https://github.com/opencontainers/runc/issues/3532.
37 out, err := exec.Command("rpm", "-q", "criu").CombinedOutput()
38 if err == nil && regexp.MustCompile(`^criu-3\.17-[123]\.el9`).Match(out) {
39 t.Skip("Test requires criu >= 3.17-4 on CentOS Stream 9.")
40 }
41
42 if userns && !criuFeature("userns") {
43 t.Skip("Test requires userns")
44 }
45
46 config := newTemplateConfig(t, &tParam{userns: userns})
47 stateDir := t.TempDir()
48
49 container, err := libcontainer.Create(stateDir, "test", config)
50 ok(t, err)
51 defer destroyContainer(container)
52
53 stdinR, stdinW, err := os.Pipe()
54 ok(t, err)
55
56 var stdout strings.Builder
57
58 pconfig := libcontainer.Process{
59 Cwd: "/",
60 Args: []string{"cat"},
61 Env: standardEnvironment,
62 Stdin: stdinR,
63 Stdout: &stdout,
64 Init: true,
65 }
66
67 err = container.Run(&pconfig)
68 _ = stdinR.Close()
69 defer stdinW.Close()
70 ok(t, err)
71
72 pid, err := pconfig.Pid()
73 ok(t, err)
74
75 process, err := os.FindProcess(pid)
76 ok(t, err)
77
78 tmp := t.TempDir()
79 var parentImage string
80
81 // Test pre-dump if mem_dirty_track is available.
82 if criuFeature("mem_dirty_track") {
83 parentImage = "../criu-parent"
84 parentDir := filepath.Join(tmp, "criu-parent")

Callers 2

TestUsernsCheckpointFunction · 0.85
TestCheckpointFunction · 0.85

Calls 15

PidMethod · 0.95
CreateFunction · 0.92
LoadFunction · 0.92
criuFeatureFunction · 0.85
newTemplateConfigFunction · 0.85
okFunction · 0.85
destroyContainerFunction · 0.85
waitProcessFunction · 0.85
StatusMethod · 0.80
WaitMethod · 0.80
ContainsMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…