Merge pull request #11942 from thaJeztah/oci_test_WithParentCgroupDevices

pkg/oci: add basic test for WithParentCgroupDevices
This commit is contained in:
Maksym Pavlenko
2025-08-18 20:51:21 +00:00
committed by GitHub

View File

@@ -779,6 +779,32 @@ func TestWithoutMounts(t *testing.T) {
}
}
func TestWithParentCgroupDevices(t *testing.T) {
t.Parallel()
// TODO(thaJeztah): WithParentCgroupDevices should probably be a no-op if the Spec is non-Linux.
for name, spec := range emptySpecs {
t.Run(name, func(t *testing.T) {
err := WithParentCgroupDevices(context.Background(), nil, nil, &spec)
assert.NoError(t, err)
assert.Nil(t, spec.Linux.Resources.Devices)
})
}
t.Run("reset existing", func(t *testing.T) {
s := Spec{
Linux: &specs.Linux{
Resources: &specs.LinuxResources{
Devices: []specs.LinuxDeviceCgroup{{Allow: true, Access: rwm}},
},
},
}
err := WithParentCgroupDevices(context.Background(), nil, nil, &s)
assert.NoError(t, err)
assert.Nil(t, s.Linux.Resources.Devices)
})
}
func TestWithWindowsDevice(t *testing.T) {
testcases := []struct {
name string