MCPcopy Create free account
hub / github.com/containerd/cgroups / TestConvertCPUSharesToCgroupV2Value

Function TestConvertCPUSharesToCgroupV2Value

cgroup2/utils_test.go:81–108  ·  view source on GitHub ↗

TestConvertCPUSharesToCgroupV2Value tests the ConvertCPUSharesToCgroupV2Value function. Taken from https://github.com/opencontainers/cgroups/blob/v0.0.5/utils_test.go#L537-L564 (Apache License 2.0)

(t *testing.T)

Source from the content-addressed store, hash-verified

79// Taken from https://github.com/opencontainers/cgroups/blob/v0.0.5/utils_test.go#L537-L564
80// (Apache License 2.0)
81func TestConvertCPUSharesToCgroupV2Value(t *testing.T) {
82 const (
83 sharesMin = 2
84 sharesMax = 262144
85 sharesDef = 1024
86 weightMin = 1
87 weightMax = 10000
88 weightDef = 100
89 unset = 0
90 )
91 cases := map[uint64]uint64{
92 unset: unset,
93
94 sharesMin - 1: weightMin, // Below the minimum (out of range).
95 sharesMin: weightMin, // Minimum.
96 sharesMin + 1: weightMin + 1, // Just above the minimum.
97 sharesDef: weightDef, // Default.
98 sharesMax - 1: weightMax, // Just below the maximum.
99 sharesMax: weightMax, // Maximum.
100 sharesMax + 1: weightMax, // Above the maximum (out of range).
101 }
102 for shares, want := range cases {
103 got := ConvertCPUSharesToCgroupV2Value(shares)
104 if got != want {
105 t.Errorf("ConvertCPUSharesToCgroupV2Value(%d): got %d, want %d", shares, got, want)
106 }
107 }
108}
109
110func TestToResources(t *testing.T) {
111 var (

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…