Skip to content

Commit 72e67e5

Browse files
author
Ma Shimiao
committed
add cgroup pids test for runtime
Signed-off-by: Ma Shimiao <mashimiao.fnst@cn.fujitsu.com>
1 parent b712995 commit 72e67e5

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

validation/linux_cgroups_pids.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/opencontainers/runtime-tools/cgroups"
7+
"github.com/opencontainers/runtime-tools/validation/util"
8+
)
9+
10+
func main() {
11+
var limit int64 = 1000
12+
g := util.GetDefaultGenerator()
13+
g.SetLinuxCgroupsPath("/test")
14+
g.SetLinuxResourcesPidsLimit(limit)
15+
err := util.RuntimeOutsideValidate(g, func(path string) error {
16+
cg, err := cgroups.FindCgroup()
17+
if err != nil {
18+
return err
19+
}
20+
lpd, err := cg.GetPidsData(path)
21+
if err != nil {
22+
return err
23+
}
24+
if lpd.Limit != limit {
25+
return fmt.Errorf("pids limit is not set correctly, expect: %d, actual: %d", limit, lpd.Limit)
26+
}
27+
return nil
28+
})
29+
30+
if err != nil {
31+
util.Fatal(err)
32+
}
33+
}

0 commit comments

Comments
 (0)