Skip to content

Commit 432615a

Browse files
author
Ma Shimiao
committed
add cgroup hugetlb test for runtime
Signed-off-by: Ma Shimiao <[email protected]>
1 parent 4a57b0f commit 432615a

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
page := "1GB"
12+
var limit uint64 = 56892210544640
13+
g := util.GetDefaultGenerator()
14+
g.SetLinuxCgroupsPath("/test")
15+
g.AddLinuxResourcesHugepageLimit(page, limit)
16+
err := util.RuntimeOutsideValidate(g, func(path string) error {
17+
cg, err := cgroups.FindCgroup()
18+
if err != nil {
19+
return err
20+
}
21+
lhd, err := cg.GetHugepageLimitData(path)
22+
if err != nil {
23+
return err
24+
}
25+
for _, lhl := range lhd {
26+
if lhl.Pagesize == page && lhl.Limit != limit {
27+
return fmt.Errorf("hugepage %s limit is not set correctly, expect: %d, actual: %d", page, limit, lhl.Limit)
28+
}
29+
}
30+
return nil
31+
})
32+
if err != nil {
33+
util.Fatal(err)
34+
}
35+
}

0 commit comments

Comments
 (0)