github.com/opencontainers/runc@v1.2.0-rc.1.0.20240520010911-492dc558cdd6/libcontainer/cgroups/fs/net_prio_test.go (about) 1 package fs 2 3 import ( 4 "strings" 5 "testing" 6 7 "github.com/opencontainers/runc/libcontainer/cgroups/fscommon" 8 "github.com/opencontainers/runc/libcontainer/configs" 9 ) 10 11 var prioMap = []*configs.IfPrioMap{ 12 { 13 Interface: "test", 14 Priority: 5, 15 }, 16 } 17 18 func TestNetPrioSetIfPrio(t *testing.T) { 19 path := tempDir(t, "net_prio") 20 21 r := &configs.Resources{ 22 NetPrioIfpriomap: prioMap, 23 } 24 netPrio := &NetPrioGroup{} 25 if err := netPrio.Set(path, r); err != nil { 26 t.Fatal(err) 27 } 28 29 value, err := fscommon.GetCgroupParamString(path, "net_prio.ifpriomap") 30 if err != nil { 31 t.Fatal(err) 32 } 33 if !strings.Contains(value, "test 5") { 34 t.Fatal("Got the wrong value, set net_prio.ifpriomap failed.") 35 } 36 }