Skip to content

Commit d4c6719

Browse files
committed
Add test
Signed-off-by: Buddha Prakash <[email protected]>
1 parent ef4ff6a commit d4c6719

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

libcontainer/cgroups/fs/devices_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ func TestDevicesSetAllow(t *testing.T) {
5656
if value != allowedList {
5757
t.Fatal("Got the wrong value, set devices.allow failed.")
5858
}
59+
60+
// When AllowAllDevices is nil, devices.allow file should not be modified.
61+
helper.CgroupData.config.Resources.AllowAllDevices = nil
62+
if err := devices.Set(helper.CgroupPath, helper.CgroupData.config); err != nil {
63+
t.Fatal(err)
64+
}
65+
value, err = getCgroupParamString(helper.CgroupPath, "devices.allow")
66+
if err != nil {
67+
t.Fatalf("Failed to parse devices.allow - %s", err)
68+
}
69+
if value != allowedList {
70+
t.Fatal("devices policy shouldn't have changed on AllowedAllDevices=nil.")
71+
}
5972
}
6073

6174
func TestDevicesSetDeny(t *testing.T) {

0 commit comments

Comments
 (0)