From 432615a089b5eb89595948fcba005bb2284ef9e1 Mon Sep 17 00:00:00 2001 From: Ma Shimiao Date: Tue, 5 Dec 2017 14:42:03 +0800 Subject: [PATCH] add cgroup hugetlb test for runtime Signed-off-by: Ma Shimiao --- validation/linux_cgroups_hugetlb.go | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 validation/linux_cgroups_hugetlb.go diff --git a/validation/linux_cgroups_hugetlb.go b/validation/linux_cgroups_hugetlb.go new file mode 100644 index 000000000..96f67e5fd --- /dev/null +++ b/validation/linux_cgroups_hugetlb.go @@ -0,0 +1,35 @@ +package main + +import ( + "fmt" + + "github.com/opencontainers/runtime-tools/cgroups" + "github.com/opencontainers/runtime-tools/validation/util" +) + +func main() { + page := "1GB" + var limit uint64 = 56892210544640 + g := util.GetDefaultGenerator() + g.SetLinuxCgroupsPath("/test") + g.AddLinuxResourcesHugepageLimit(page, limit) + err := util.RuntimeOutsideValidate(g, func(path string) error { + cg, err := cgroups.FindCgroup() + if err != nil { + return err + } + lhd, err := cg.GetHugepageLimitData(path) + if err != nil { + return err + } + for _, lhl := range lhd { + if lhl.Pagesize == page && lhl.Limit != limit { + return fmt.Errorf("hugepage %s limit is not set correctly, expect: %d, actual: %d", page, limit, lhl.Limit) + } + } + return nil + }) + if err != nil { + util.Fatal(err) + } +}