mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
merge branch 'pr-2992'
Kir Kolyshkin (3): libct/cg/fs/stats_util_test: use t.Helper libct/cg/fs/memory_test: fix formatting libct/int/testPids: logging nits LGTMs: AkihiroSuda cyphar Closes #2992
This commit is contained in:
@@ -244,7 +244,12 @@ func TestMemoryStats(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expectedStats := cgroups.MemoryStats{
|
||||
Cache: 512, Usage: cgroups.MemoryData{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Limit: 8192}, SwapUsage: cgroups.MemoryData{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Limit: 8192}, KernelUsage: cgroups.MemoryData{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Limit: 8192}, Stats: map[string]uint64{"cache": 512, "rss": 1024}, UseHierarchy: true,
|
||||
Cache: 512,
|
||||
Usage: cgroups.MemoryData{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Limit: 8192},
|
||||
SwapUsage: cgroups.MemoryData{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Limit: 8192},
|
||||
KernelUsage: cgroups.MemoryData{Usage: 2048, MaxUsage: 4096, Failcnt: 100, Limit: 8192},
|
||||
Stats: map[string]uint64{"cache": 512, "rss": 1024},
|
||||
UseHierarchy: true,
|
||||
PageUsageByNUMA: cgroups.PageUsageByNUMA{
|
||||
PageUsageByNUMAInner: cgroups.PageUsageByNUMAInner{
|
||||
Total: cgroups.PageStats{Total: 44611, Nodes: map[uint8]uint64{0: 32631, 1: 7501, 2: 1982, 3: 2497}},
|
||||
|
||||
@@ -25,6 +25,7 @@ func blkioStatEntryEquals(expected, actual []cgroups.BlkioStatEntry) error {
|
||||
}
|
||||
|
||||
func expectBlkioStatsEquals(t *testing.T, expected, actual cgroups.BlkioStats) {
|
||||
t.Helper()
|
||||
if err := blkioStatEntryEquals(expected.IoServiceBytesRecursive, actual.IoServiceBytesRecursive); err != nil {
|
||||
t.Errorf("blkio IoServiceBytesRecursive do not match - %s\n", err)
|
||||
}
|
||||
@@ -59,18 +60,21 @@ func expectBlkioStatsEquals(t *testing.T, expected, actual cgroups.BlkioStats) {
|
||||
}
|
||||
|
||||
func expectThrottlingDataEquals(t *testing.T, expected, actual cgroups.ThrottlingData) {
|
||||
t.Helper()
|
||||
if expected != actual {
|
||||
t.Errorf("Expected throttling data %v but found %v\n", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func expectHugetlbStatEquals(t *testing.T, expected, actual cgroups.HugetlbStats) {
|
||||
t.Helper()
|
||||
if expected != actual {
|
||||
t.Errorf("Expected hugetlb stats %v but found %v\n", expected, actual)
|
||||
}
|
||||
}
|
||||
|
||||
func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats) {
|
||||
t.Helper()
|
||||
expectMemoryDataEquals(t, expected.Usage, actual.Usage)
|
||||
expectMemoryDataEquals(t, expected.SwapUsage, actual.SwapUsage)
|
||||
expectMemoryDataEquals(t, expected.KernelUsage, actual.KernelUsage)
|
||||
@@ -92,6 +96,7 @@ func expectMemoryStatEquals(t *testing.T, expected, actual cgroups.MemoryStats)
|
||||
}
|
||||
|
||||
func expectMemoryDataEquals(t *testing.T, expected, actual cgroups.MemoryData) {
|
||||
t.Helper()
|
||||
if expected.Usage != actual.Usage {
|
||||
t.Errorf("Expected memory usage %d but found %d\n", expected.Usage, actual.Usage)
|
||||
}
|
||||
@@ -107,6 +112,7 @@ func expectMemoryDataEquals(t *testing.T, expected, actual cgroups.MemoryData) {
|
||||
}
|
||||
|
||||
func expectPageUsageByNUMAEquals(t *testing.T, expected, actual cgroups.PageUsageByNUMA) {
|
||||
t.Helper()
|
||||
if !reflect.DeepEqual(expected.Total, actual.Total) {
|
||||
t.Errorf("Expected total page usage by NUMA %#v but found %#v", expected.Total, actual.Total)
|
||||
}
|
||||
|
||||
@@ -645,11 +645,11 @@ func testPids(t *testing.T, systemd bool) {
|
||||
/bin/true | /bin/true | /bin/true | /bin/true | /bin/true | /bin/true | bin/true | /bin/true |
|
||||
/bin/true | /bin/true | /bin/true | /bin/true | /bin/true | /bin/true | bin/true | /bin/true`)
|
||||
if err != nil && !strings.Contains(out.String(), "sh: can't fork") {
|
||||
ok(t, err)
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if err == nil {
|
||||
t.Fatalf("expected fork() to fail with restrictive pids limit")
|
||||
t.Fatal("expected fork() to fail with restrictive pids limit")
|
||||
}
|
||||
|
||||
// Minimal restrictions are not really supported, due to quirks in using Go
|
||||
|
||||
Reference in New Issue
Block a user