diff --git a/validation/linux_cgroups_blkio.go b/validation/linux_cgroups_blkio.go index 40ae1d016..b5b3e8a7f 100644 --- a/validation/linux_cgroups_blkio.go +++ b/validation/linux_cgroups_blkio.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -22,93 +20,7 @@ func main() { g.AddLinuxResourcesBlockIOThrottleWriteBpsDevice(major, minor, rate) g.AddLinuxResourcesBlockIOThrottleReadIOPSDevice(major, minor, rate) g.AddLinuxResourcesBlockIOThrottleWriteIOPSDevice(major, minor, rate) - err := util.RuntimeOutsideValidate(g, cgroups.AbsCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lbd, err := cg.GetBlockIOData(pid, path) - if err != nil { - return err - } - if *lbd.Weight != weight { - return fmt.Errorf("blkio weight is not set correctly, expect: %d, actual: %d", weight, lbd.Weight) - } - if *lbd.LeafWeight != leafWeight { - return fmt.Errorf("blkio leafWeight is not set correctly, expect: %d, actual: %d", weight, lbd.LeafWeight) - } - - found := false - for _, wd := range lbd.WeightDevice { - if wd.Major == major && wd.Minor == minor { - found = true - if *wd.Weight != weight { - return fmt.Errorf("blkio weight for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, weight, wd.Weight) - } - if *wd.LeafWeight != leafWeight { - return fmt.Errorf("blkio leafWeight for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, leafWeight, wd.LeafWeight) - } - } - } - if !found { - return fmt.Errorf("blkio weightDevice for %d:%d is not set", major, minor) - } - - found = false - for _, trbd := range lbd.ThrottleReadBpsDevice { - if trbd.Major == major && trbd.Minor == minor { - found = true - if trbd.Rate != rate { - return fmt.Errorf("blkio read bps for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, trbd.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio read bps for %d:%d is not set", major, minor) - } - - found = false - for _, twbd := range lbd.ThrottleWriteBpsDevice { - if twbd.Major == major && twbd.Minor == minor { - found = true - if twbd.Rate != rate { - return fmt.Errorf("blkio write bps for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, twbd.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio write bps for %d:%d is not set", major, minor) - } - - found = false - for _, trid := range lbd.ThrottleReadIOPSDevice { - if trid.Major == major && trid.Minor == minor { - found = true - if trid.Rate != rate { - return fmt.Errorf("blkio read iops for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, trid.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio read iops for %d:%d is not set", major, minor) - } - - found = false - for _, twid := range lbd.ThrottleWriteIOPSDevice { - if twid.Major == major && twid.Minor == minor { - found = true - if twid.Rate != rate { - return fmt.Errorf("blkio write iops for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, twid.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio write iops for %d:%d is not set", major, minor) - } - - return nil - }) - + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesBlockIO) if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_cpus.go b/validation/linux_cgroups_cpus.go index 32728a205..048e508de 100644 --- a/validation/linux_cgroups_cpus.go +++ b/validation/linux_cgroups_cpus.go @@ -3,6 +3,7 @@ package main import ( "fmt" + rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -19,12 +20,12 @@ func main() { g.SetLinuxResourcesCPUPeriod(period) g.SetLinuxResourcesCPUCpus(cpus) g.SetLinuxResourcesCPUMems(mems) - err := util.RuntimeOutsideValidate(g, cgroups.AbsCgroupPath, func(pid int, path string) error { + err := util.RuntimeOutsideValidate(g, func(config *rspec.Spec, state *rspec.State) error { cg, err := cgroups.FindCgroup() if err != nil { return err } - lcd, err := cg.GetCPUData(pid, path) + lcd, err := cg.GetCPUData(state.Pid, config.Linux.CgroupsPath) if err != nil { return err } diff --git a/validation/linux_cgroups_hugetlb.go b/validation/linux_cgroups_hugetlb.go index ae1b81d09..bfcd997c2 100644 --- a/validation/linux_cgroups_hugetlb.go +++ b/validation/linux_cgroups_hugetlb.go @@ -3,6 +3,7 @@ package main import ( "fmt" + rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -13,12 +14,12 @@ func main() { g := util.GetDefaultGenerator() g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath) g.AddLinuxResourcesHugepageLimit(page, limit) - err := util.RuntimeOutsideValidate(g, cgroups.AbsCgroupPath, func(pid int, path string) error { + err := util.RuntimeOutsideValidate(g, func(config *rspec.Spec, state *rspec.State) error { cg, err := cgroups.FindCgroup() if err != nil { return err } - lhd, err := cg.GetHugepageLimitData(pid, path) + lhd, err := cg.GetHugepageLimitData(state.Pid, config.Linux.CgroupsPath) if err != nil { return err } diff --git a/validation/linux_cgroups_memory.go b/validation/linux_cgroups_memory.go index 7293d6388..676c30530 100644 --- a/validation/linux_cgroups_memory.go +++ b/validation/linux_cgroups_memory.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -19,38 +17,7 @@ func main() { g.SetLinuxResourcesMemoryKernelTCP(limit) g.SetLinuxResourcesMemorySwappiness(swappiness) g.SetLinuxResourcesMemoryDisableOOMKiller(true) - err := util.RuntimeOutsideValidate(g, cgroups.AbsCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lm, err := cg.GetMemoryData(pid, path) - if err != nil { - return err - } - if limit != *lm.Limit { - return fmt.Errorf("memory limit is not set correctly, expect: %d, actual: %d", limit, *lm.Limit) - } - if limit != *lm.Reservation { - return fmt.Errorf("memory reservation is not set correctly, expect: %d, actual: %d", limit, *lm.Reservation) - } - if limit != *lm.Swap { - return fmt.Errorf("memory swap is not set correctly, expect: %d, actual: %d", limit, *lm.Reservation) - } - if limit != *lm.Kernel { - return fmt.Errorf("memory kernel is not set correctly, expect: %d, actual: %d", limit, *lm.Kernel) - } - if limit != *lm.KernelTCP { - return fmt.Errorf("memory kernelTCP is not set correctly, expect: %d, actual: %d", limit, *lm.Kernel) - } - if swappiness != *lm.Swappiness { - return fmt.Errorf("memory swappiness is not set correctly, expect: %d, actual: %d", swappiness, *lm.Swappiness) - } - if true != *lm.DisableOOMKiller { - return fmt.Errorf("memory oom is not set correctly, expect: %t, actual: %t", true, *lm.DisableOOMKiller) - } - return nil - }) + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesMemory) if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_network.go b/validation/linux_cgroups_network.go index 9cbd0d59b..609c5068b 100644 --- a/validation/linux_cgroups_network.go +++ b/validation/linux_cgroups_network.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -13,34 +11,8 @@ func main() { g := util.GetDefaultGenerator() g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath) g.SetLinuxResourcesNetworkClassID(id) - err := util.RuntimeOutsideValidate(g, cgroups.AbsCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lnd, err := cg.GetNetworkData(pid, path) - if err != nil { - return err - } - if *lnd.ClassID != id { - return fmt.Errorf("network ID is not set correctly, expect: %d, actual: %d", id, lnd.ClassID) - } - found := false - for _, lip := range lnd.Priorities { - if lip.Name == ifName { - found = true - if lip.Priority != prio { - return fmt.Errorf("network priority for %s is not set correctly, expect: %d, actual: %d", ifName, prio, lip.Priority) - } - } - } - if !found { - return fmt.Errorf("network priority for %s is not set correctly", ifName) - } - - return nil - }) - + g.AddLinuxResourcesNetworkPriorities(ifName, prio) + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesNetwork) if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_pids.go b/validation/linux_cgroups_pids.go index 3e1fb780c..0860bc7f5 100644 --- a/validation/linux_cgroups_pids.go +++ b/validation/linux_cgroups_pids.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -12,21 +10,7 @@ func main() { g := util.GetDefaultGenerator() g.SetLinuxCgroupsPath(cgroups.AbsCgroupPath) g.SetLinuxResourcesPidsLimit(limit) - err := util.RuntimeOutsideValidate(g, cgroups.AbsCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lpd, err := cg.GetPidsData(pid, 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 - }) - + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesPids) if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_relative_blkio.go b/validation/linux_cgroups_relative_blkio.go index 4f2b56abd..72b0b2442 100644 --- a/validation/linux_cgroups_relative_blkio.go +++ b/validation/linux_cgroups_relative_blkio.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -22,92 +20,7 @@ func main() { g.AddLinuxResourcesBlockIOThrottleWriteBpsDevice(major, minor, rate) g.AddLinuxResourcesBlockIOThrottleReadIOPSDevice(major, minor, rate) g.AddLinuxResourcesBlockIOThrottleWriteIOPSDevice(major, minor, rate) - err := util.RuntimeOutsideValidate(g, cgroups.RelCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lbd, err := cg.GetBlockIOData(pid, path) - if err != nil { - return err - } - if *lbd.Weight != weight { - return fmt.Errorf("blkio weight is not set correctly, expect: %d, actual: %d", weight, lbd.Weight) - } - if *lbd.LeafWeight != leafWeight { - return fmt.Errorf("blkio leafWeight is not set correctly, expect: %d, actual: %d", weight, lbd.LeafWeight) - } - - found := false - for _, wd := range lbd.WeightDevice { - if wd.Major == major && wd.Minor == minor { - found = true - if *wd.Weight != weight { - return fmt.Errorf("blkio weight for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, weight, wd.Weight) - } - if *wd.LeafWeight != leafWeight { - return fmt.Errorf("blkio leafWeight for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, leafWeight, wd.LeafWeight) - } - } - } - if !found { - return fmt.Errorf("blkio weightDevice for %d:%d is not set", major, minor) - } - - found = false - for _, trbd := range lbd.ThrottleReadBpsDevice { - if trbd.Major == major && trbd.Minor == minor { - found = true - if trbd.Rate != rate { - return fmt.Errorf("blkio read bps for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, trbd.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio read bps for %d:%d is not set", major, minor) - } - - found = false - for _, twbd := range lbd.ThrottleWriteBpsDevice { - if twbd.Major == major && twbd.Minor == minor { - found = true - if twbd.Rate != rate { - return fmt.Errorf("blkio write bps for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, twbd.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio write bps for %d:%d is not set", major, minor) - } - - found = false - for _, trid := range lbd.ThrottleReadIOPSDevice { - if trid.Major == major && trid.Minor == minor { - found = true - if trid.Rate != rate { - return fmt.Errorf("blkio read iops for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, trid.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio read iops for %d:%d is not set", major, minor) - } - - found = false - for _, twid := range lbd.ThrottleWriteIOPSDevice { - if twid.Major == major && twid.Minor == minor { - found = true - if twid.Rate != rate { - return fmt.Errorf("blkio write iops for %d:%d is not set correctly, expect: %d, actual: %d", major, minor, rate, twid.Rate) - } - } - } - if !found { - return fmt.Errorf("blkio write iops for %d:%d is not set", major, minor) - } - - return nil - }) + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesBlockIO) if err != nil { util.Fatal(err) diff --git a/validation/linux_cgroups_relative_cpus.go b/validation/linux_cgroups_relative_cpus.go index 8102b77f9..c3ce36af5 100644 --- a/validation/linux_cgroups_relative_cpus.go +++ b/validation/linux_cgroups_relative_cpus.go @@ -1,8 +1,8 @@ package main import ( - "fmt" - + "github.com/mndrix/tap-go" + rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -19,30 +19,42 @@ func main() { g.SetLinuxResourcesCPUPeriod(period) g.SetLinuxResourcesCPUCpus(cpus) g.SetLinuxResourcesCPUMems(mems) - err := util.RuntimeOutsideValidate(g, cgroups.RelCgroupPath, func(pid int, path string) error { + err := util.RuntimeOutsideValidate(g, func(config *rspec.Spec, state *rspec.State) error { + t := tap.New() + t.Header(0) + cg, err := cgroups.FindCgroup() + t.Ok((err == nil), "find cpus cgroup") if err != nil { - return err + t.Diagnostic(err.Error()) + t.AutoPlan() + return nil } - lcd, err := cg.GetCPUData(pid, path) + + lcd, err := cg.GetCPUData(state.Pid, config.Linux.CgroupsPath) + t.Ok((err == nil), "get cpus cgroup data") if err != nil { - return err - } - if *lcd.Shares != shares { - return fmt.Errorf("cpus shares limit is not set correctly, expect: %d, actual: %d", shares, lcd.Shares) - } - if *lcd.Quota != quota { - return fmt.Errorf("cpus quota is not set correctly, expect: %d, actual: %d", quota, lcd.Quota) - } - if *lcd.Period != period { - return fmt.Errorf("cpus period is not set correctly, expect: %d, actual: %d", period, lcd.Period) - } - if lcd.Cpus != cpus { - return fmt.Errorf("cpus cpus is not set correctly, expect: %s, actual: %s", cpus, lcd.Cpus) - } - if lcd.Mems != mems { - return fmt.Errorf("cpus mems is not set correctly, expect: %s, actual: %s", mems, lcd.Mems) + t.Diagnostic(err.Error()) + t.AutoPlan() + return nil } + + t.Ok(*lcd.Shares == shares, "cpus shares limit is set correctly") + t.Diagnosticf("expect: %d, actual: %d", shares, lcd.Shares) + + t.Ok(*lcd.Quota == quota, "cpus quota is set correctly") + t.Diagnosticf("expect: %d, actual: %d", quota, lcd.Quota) + + t.Ok(*lcd.Period == period, "cpus period is set correctly") + t.Diagnosticf("expect: %d, actual: %d", period, lcd.Period) + + t.Ok(lcd.Cpus == cpus, "cpus cpus is set correctly") + t.Diagnosticf("expect: %s, actual: %s", cpus, lcd.Cpus) + + t.Ok(lcd.Mems == mems, "cpus mems is set correctly") + t.Diagnosticf("expect: %s, actual: %s", mems, lcd.Mems) + + t.AutoPlan() return nil }) diff --git a/validation/linux_cgroups_relative_hugetlb.go b/validation/linux_cgroups_relative_hugetlb.go index 5b888241f..7dad8bb31 100644 --- a/validation/linux_cgroups_relative_hugetlb.go +++ b/validation/linux_cgroups_relative_hugetlb.go @@ -1,8 +1,8 @@ package main import ( - "fmt" - + "github.com/mndrix/tap-go" + rspec "github.com/opencontainers/runtime-spec/specs-go" "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -13,22 +13,40 @@ func main() { g := util.GetDefaultGenerator() g.SetLinuxCgroupsPath(cgroups.RelCgroupPath) g.AddLinuxResourcesHugepageLimit(page, limit) - err := util.RuntimeOutsideValidate(g, cgroups.RelCgroupPath, func(pid int, path string) error { + err := util.RuntimeOutsideValidate(g, func(config *rspec.Spec, state *rspec.State) error { + t := tap.New() + t.Header(0) + cg, err := cgroups.FindCgroup() + t.Ok((err == nil), "find hugetlb cgroup") if err != nil { - return err + t.Diagnostic(err.Error()) + t.AutoPlan() + return nil } - lhd, err := cg.GetHugepageLimitData(pid, path) + + lhd, err := cg.GetHugepageLimitData(state.Pid, config.Linux.CgroupsPath) + t.Ok((err == nil), "get hugetlb cgroup data") if err != nil { - return err + t.Diagnostic(err.Error()) + t.AutoPlan() + return nil } + + found := false 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) + if lhl.Pagesize == page { + found = true + t.Ok(lhl.Limit == limit, "hugepage limit is set correctly") + t.Diagnosticf("expect: %d, actual: %d", limit, lhl.Limit) } } + t.Ok(found, "hugepage limit found") + + t.AutoPlan() return nil }) + if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_relative_memory.go b/validation/linux_cgroups_relative_memory.go index 578aa96dc..090d1425e 100644 --- a/validation/linux_cgroups_relative_memory.go +++ b/validation/linux_cgroups_relative_memory.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -19,38 +17,7 @@ func main() { g.SetLinuxResourcesMemoryKernelTCP(limit) g.SetLinuxResourcesMemorySwappiness(swappiness) g.SetLinuxResourcesMemoryDisableOOMKiller(true) - err := util.RuntimeOutsideValidate(g, cgroups.RelCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lm, err := cg.GetMemoryData(pid, path) - if err != nil { - return err - } - if limit != *lm.Limit { - return fmt.Errorf("memory limit is not set correctly, expect: %d, actual: %d", limit, *lm.Limit) - } - if limit != *lm.Reservation { - return fmt.Errorf("memory reservation is not set correctly, expect: %d, actual: %d", limit, *lm.Reservation) - } - if limit != *lm.Swap { - return fmt.Errorf("memory swap is not set correctly, expect: %d, actual: %d", limit, *lm.Reservation) - } - if limit != *lm.Kernel { - return fmt.Errorf("memory kernel is not set correctly, expect: %d, actual: %d", limit, *lm.Kernel) - } - if limit != *lm.KernelTCP { - return fmt.Errorf("memory kernelTCP is not set correctly, expect: %d, actual: %d", limit, *lm.Kernel) - } - if swappiness != *lm.Swappiness { - return fmt.Errorf("memory swappiness is not set correctly, expect: %d, actual: %d", swappiness, *lm.Swappiness) - } - if true != *lm.DisableOOMKiller { - return fmt.Errorf("memory oom is not set correctly, expect: %t, actual: %t", true, *lm.DisableOOMKiller) - } - return nil - }) + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesMemory) if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_relative_network.go b/validation/linux_cgroups_relative_network.go index 8d1985b3a..3cb75d541 100644 --- a/validation/linux_cgroups_relative_network.go +++ b/validation/linux_cgroups_relative_network.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -13,34 +11,8 @@ func main() { g := util.GetDefaultGenerator() g.SetLinuxCgroupsPath(cgroups.RelCgroupPath) g.SetLinuxResourcesNetworkClassID(id) - err := util.RuntimeOutsideValidate(g, cgroups.RelCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lnd, err := cg.GetNetworkData(pid, path) - if err != nil { - return err - } - if *lnd.ClassID != id { - return fmt.Errorf("network ID is not set correctly, expect: %d, actual: %d", id, lnd.ClassID) - } - found := false - for _, lip := range lnd.Priorities { - if lip.Name == ifName { - found = true - if lip.Priority != prio { - return fmt.Errorf("network priority for %s is not set correctly, expect: %d, actual: %d", ifName, prio, lip.Priority) - } - } - } - if !found { - return fmt.Errorf("network priority for %s is not set correctly", ifName) - } - - return nil - }) - + g.AddLinuxResourcesNetworkPriorities(ifName, prio) + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesNetwork) if err != nil { util.Fatal(err) } diff --git a/validation/linux_cgroups_relative_pids.go b/validation/linux_cgroups_relative_pids.go index f8ec4b145..9aae115ba 100644 --- a/validation/linux_cgroups_relative_pids.go +++ b/validation/linux_cgroups_relative_pids.go @@ -1,8 +1,6 @@ package main import ( - "fmt" - "github.com/opencontainers/runtime-tools/cgroups" "github.com/opencontainers/runtime-tools/validation/util" ) @@ -12,21 +10,7 @@ func main() { g := util.GetDefaultGenerator() g.SetLinuxCgroupsPath(cgroups.RelCgroupPath) g.SetLinuxResourcesPidsLimit(limit) - err := util.RuntimeOutsideValidate(g, cgroups.RelCgroupPath, func(pid int, path string) error { - cg, err := cgroups.FindCgroup() - if err != nil { - return err - } - lpd, err := cg.GetPidsData(pid, 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 - }) - + err := util.RuntimeOutsideValidate(g, util.ValidateLinuxResourcesPids) if err != nil { util.Fatal(err) } diff --git a/validation/test-yaml b/validation/test-yaml new file mode 100755 index 000000000..0974baae3 --- /dev/null +++ b/validation/test-yaml @@ -0,0 +1,7 @@ +#!/bin/sh +cat <