File: net_prio_test.go

package info (click to toggle)
runc 0.1.1%2Bdfsg1-2%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,684 kB
  • sloc: ansic: 698; sh: 156; makefile: 71
file content (38 lines) | stat: -rw-r--r-- 782 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// +build linux

package fs

import (
	"strings"
	"testing"

	"github.com/opencontainers/runc/libcontainer/configs"
)

var (
	prioMap = []*configs.IfPrioMap{
		{
			Interface: "test",
			Priority:  5,
		},
	}
)

func TestNetPrioSetIfPrio(t *testing.T) {
	helper := NewCgroupTestUtil("net_prio", t)
	defer helper.cleanup()

	helper.CgroupData.config.Resources.NetPrioIfpriomap = prioMap
	netPrio := &NetPrioGroup{}
	if err := netPrio.Set(helper.CgroupPath, helper.CgroupData.config); err != nil {
		t.Fatal(err)
	}

	value, err := getCgroupParamString(helper.CgroupPath, "net_prio.ifpriomap")
	if err != nil {
		t.Fatalf("Failed to parse net_prio.ifpriomap - %s", err)
	}
	if !strings.Contains(value, "test 5") {
		t.Fatal("Got the wrong value, set net_prio.ifpriomap failed.")
	}
}