Skip to content

Commit

Permalink
add cgroup pids test for runtime
Browse files Browse the repository at this point in the history
Signed-off-by: Ma Shimiao <[email protected]>
  • Loading branch information
Ma Shimiao committed Dec 5, 2017
1 parent cb4d769 commit 04accdb
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions validation/linux_cgroups_pids.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package main

import (
"fmt"

"github.com/opencontainers/runtime-tools/cgroups"
"github.com/opencontainers/runtime-tools/validation/util"
)

func main() {
var limit int64 = 1000
g := util.GetDefaultGenerator()
g.SetLinuxCgroupsPath("/test")
g.SetLinuxResourcesPidsLimit(limit)
err := util.RuntimeOutsideValidate(g, func(path string) error {
cg, err := cgroups.FindCgroup()
if err != nil {
return err
}
lpd, err := cg.GetPidsData(path)
if err != nil {
return err
}
if lpd.Limit != limit {
return fmt.Errorf("pids limit is not set correctly, expect: %d, actual: %d", limit, lpd.Limit)
}
return nil
})

if err != nil {
util.Fatal(err)
}
}

0 comments on commit 04accdb

Please sign in to comment.