(t *testing.T, userns bool)
| 25 | } |
| 26 | |
| 27 | func 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") |
no test coverage detected
searching dependent graphs…