@@ -36,23 +36,22 @@ func TestCgroupv2CpuStats(t *testing.T) {
3636 period uint64 = 8000
3737 weight uint64 = 100
3838 )
39- max := "10000 8000"
40- res := Resources {
39+
40+ c , err := NewManager ( defaultCgroup2Path , groupPath , & Resources {
4141 CPU : & CPU {
4242 Weight : & weight ,
4343 Max : NewCPUMax (& quota , & period ),
4444 Cpus : "0" ,
4545 Mems : "0" ,
4646 },
47- }
48- c , err := NewManager (defaultCgroup2Path , groupPath , & res )
47+ })
4948 require .NoError (t , err , "failed to init new cgroup manager" )
5049 t .Cleanup (func () {
51- os .Remove (c .path )
50+ _ = os .Remove (c .path )
5251 })
5352
5453 checkFileContent (t , c .path , "cpu.weight" , strconv .FormatUint (weight , 10 ))
55- checkFileContent (t , c .path , "cpu.max" , max )
54+ checkFileContent (t , c .path , "cpu.max" , "10000 8000" )
5655 checkFileContent (t , c .path , "cpuset.cpus" , "0" )
5756 checkFileContent (t , c .path , "cpuset.mems" , "0" )
5857}
@@ -61,8 +60,7 @@ func TestSystemdCgroupCpuController(t *testing.T) {
6160 checkCgroupMode (t )
6261 group := fmt .Sprintf ("testing-cpu-%d.scope" , os .Getpid ())
6362 var weight uint64 = 100
64- res := Resources {CPU : & CPU {Weight : & weight }}
65- c , err := NewSystemd ("" , group , os .Getpid (), & res )
63+ c , err := NewSystemd ("" , group , os .Getpid (), & Resources {CPU : & CPU {Weight : & weight }})
6664 require .NoError (t , err , "failed to init new cgroup systemd manager" )
6765
6866 checkFileContent (t , c .path , "cpu.weight" , strconv .FormatUint (weight , 10 ))
@@ -75,13 +73,12 @@ func TestSystemdCgroupCpuController_NilWeight(t *testing.T) {
7573 var quota int64 = 10000
7674 var period uint64 = 8000
7775 cpuMax := NewCPUMax (& quota , & period )
78- res := Resources {
76+ _ , err := NewSystemd ( "/" , group , - 1 , & Resources {
7977 CPU : & CPU {
8078 Weight : nil ,
8179 Max : cpuMax ,
8280 },
83- }
84- _ , err := NewSystemd ("/" , group , - 1 , & res )
81+ })
8582 require .NoError (t , err , "failed to init new cgroup systemd manager" )
8683}
8784
0 commit comments