diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index 06d9d31903d..1e8e185f394 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -493,20 +493,33 @@ func TestAdditionalGroups(t *testing.T) { } func TestFreeze(t *testing.T) { - testFreeze(t, false) -} - -func TestSystemdFreeze(t *testing.T) { - if !systemd.IsRunningSystemd() { - t.Skip("Test requires systemd.") + for _, systemd := range []bool{true, false} { + for _, set := range []bool{true, false} { + name := "" + if systemd { + name += "Systemd" + } else { + name += "FS" + } + if set { + name += "ViaSet" + } else { + name += "ViaPauseResume" + } + t.Run(name, func(t *testing.T) { + testFreeze(t, systemd, set) + }) + } } - testFreeze(t, true) } -func testFreeze(t *testing.T, systemd bool) { +func testFreeze(t *testing.T, withSystemd bool, useSet bool) { if testing.Short() { return } + if withSystemd && !systemd.IsRunningSystemd() { + t.Skip("Test requires systemd.") + } rootfs, err := newRootfs() ok(t, err) @@ -514,7 +527,7 @@ func testFreeze(t *testing.T, systemd bool) { config := newTemplateConfig(t, &tParam{ rootfs: rootfs, - systemd: systemd, + systemd: withSystemd, }) container, err := newContainer(t, config) ok(t, err) @@ -535,16 +548,28 @@ func testFreeze(t *testing.T, systemd bool) { defer stdinW.Close() //nolint: errcheck ok(t, err) - err = container.Pause() + if !useSet { + err = container.Pause() + } else { + config.Cgroups.Resources.Freezer = configs.Frozen + err = container.Set(*config) + } ok(t, err) + state, err := container.Status() ok(t, err) - err = container.Resume() - ok(t, err) if state != libcontainer.Paused { t.Fatal("Unexpected state: ", state) } + if !useSet { + err = container.Resume() + } else { + config.Cgroups.Resources.Freezer = configs.Thawed + err = container.Set(*config) + } + ok(t, err) + _ = stdinW.Close() waitProcess(pconfig, t) }