Skip to content

Commit 1ab3c03

Browse files
committed
validator: actually test success
Previously we only tested failures, which causes us to miss issues where setting sysctls would *always* fail. Signed-off-by: Aleksa Sarai <[email protected]>
1 parent 2a94c36 commit 1ab3c03

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

libcontainer/configs/validate/validator_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,35 @@ func TestValidateSysctl(t *testing.T) {
202202
}
203203
}
204204

205+
func TestValidateValidSysctl(t *testing.T) {
206+
sysctl := map[string]string{
207+
"fs.mqueue.ctl": "ctl",
208+
"net.ctl": "ctl",
209+
"kernel.msgmax": "ctl",
210+
}
211+
212+
for k, v := range sysctl {
213+
config := &configs.Config{
214+
Rootfs: "/var",
215+
Sysctl: map[string]string{k: v},
216+
Namespaces: []configs.Namespace{
217+
{
218+
Type: configs.NEWNET,
219+
},
220+
{
221+
Type: configs.NEWIPC,
222+
},
223+
},
224+
}
225+
226+
validator := validate.New()
227+
err := validator.Validate(config)
228+
if err != nil {
229+
t.Errorf("Expected error to not occur with {%s=%s} but got: %q", k, v, err)
230+
}
231+
}
232+
}
233+
205234
func TestValidateSysctlWithSameNs(t *testing.T) {
206235
config := &configs.Config{
207236
Rootfs: "/var",

0 commit comments

Comments
 (0)