@@ -339,6 +339,57 @@ func TestProcessEnv(t *testing.T) {
339339 }
340340}
341341
342+ func TestProcessEmptyCaps (t * testing.T ) {
343+ if testing .Short () {
344+ return
345+ }
346+ root , err := newTestRoot ()
347+ ok (t , err )
348+ defer os .RemoveAll (root )
349+
350+ rootfs , err := newRootfs ()
351+ ok (t , err )
352+ defer remove (rootfs )
353+
354+ config := newTemplateConfig (rootfs )
355+ config .Capabilities = nil
356+
357+ container , err := factory .Create ("test" , config )
358+ ok (t , err )
359+ defer container .Destroy ()
360+
361+ var stdout bytes.Buffer
362+ pconfig := libcontainer.Process {
363+ Cwd : "/" ,
364+ Args : []string {"sh" , "-c" , "cat /proc/self/status" },
365+ Env : standardEnvironment ,
366+ Stdin : nil ,
367+ Stdout : & stdout ,
368+ }
369+ err = container .Run (& pconfig )
370+ ok (t , err )
371+
372+ // Wait for process
373+ waitProcess (& pconfig , t )
374+
375+ outputStatus := string (stdout .Bytes ())
376+
377+ lines := strings .Split (outputStatus , "\n " )
378+
379+ effectiveCapsLine := ""
380+ for _ , l := range lines {
381+ line := strings .TrimSpace (l )
382+ if strings .Contains (line , "CapEff:" ) {
383+ effectiveCapsLine = line
384+ break
385+ }
386+ }
387+
388+ if effectiveCapsLine == "" {
389+ t .Fatal ("Couldn't find effective caps: " , outputStatus )
390+ }
391+ }
392+
342393func TestProcessCaps (t * testing.T ) {
343394 if testing .Short () {
344395 return
0 commit comments