File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
libcontainer/configs/validate Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -201,3 +201,38 @@ func TestValidateSysctl(t *testing.T) {
201201 }
202202 }
203203}
204+
205+ func TestValidateSysctlWithSameNs (t * testing.T ) {
206+ config := & configs.Config {
207+ Rootfs : "/var" ,
208+ Sysctl : map [string ]string {"net.ctl" : "ctl" },
209+ Namespaces : configs .Namespaces (
210+ []configs.Namespace {
211+ {
212+ Type : configs .NEWNET ,
213+ Path : "/proc/self/ns/net" ,
214+ },
215+ },
216+ ),
217+ }
218+
219+ validator := validate .New ()
220+ err := validator .Validate (config )
221+ if err == nil {
222+ t .Error ("Expected error to occur but it was nil" )
223+ }
224+ }
225+
226+ func TestValidateSysctlWithoutNETNamespace (t * testing.T ) {
227+ config := & configs.Config {
228+ Rootfs : "/var" ,
229+ Sysctl : map [string ]string {"net.ctl" : "ctl" },
230+ Namespaces : []configs.Namespace {},
231+ }
232+
233+ validator := validate .New ()
234+ err := validator .Validate (config )
235+ if err == nil {
236+ t .Error ("Expected error to occur but it was nil" )
237+ }
238+ }
You can’t perform that action at this time.
0 commit comments