...
1 package fs
2
3 import (
4 "strconv"
5 "testing"
6
7 "github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
8 "github.com/opencontainers/runc/libcontainer/configs"
9 )
10
11 const (
12 classidBefore = 0x100002
13 classidAfter = 0x100001
14 )
15
16 func TestNetClsSetClassid(t *testing.T) {
17 path := tempDir(t, "net_cls")
18
19 writeFileContents(t, path, map[string]string{
20 "net_cls.classid": strconv.FormatUint(classidBefore, 10),
21 })
22
23 r := &configs.Resources{
24 NetClsClassid: classidAfter,
25 }
26 netcls := &NetClsGroup{}
27 if err := netcls.Set(path, r); err != nil {
28 t.Fatal(err)
29 }
30
31
32
33
34 value, err := fscommon.GetCgroupParamUint(path, "net_cls.classid")
35 if err != nil {
36 t.Fatal(err)
37 }
38 if value != classidAfter {
39 t.Fatal("Got the wrong value, set net_cls.classid failed.")
40 }
41 }
42
View as plain text