mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-12 09:46:25 +08:00
04041f21ac
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
42 lines
927 B
Go
42 lines
927 B
Go
package fs
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
|
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
|
)
|
|
|
|
const (
|
|
classidBefore = 0x100002
|
|
classidAfter = 0x100001
|
|
)
|
|
|
|
func TestNetClsSetClassid(t *testing.T) {
|
|
path := tempDir(t, "net_cls")
|
|
|
|
writeFileContents(t, path, map[string]string{
|
|
"net_cls.classid": strconv.FormatUint(classidBefore, 10),
|
|
})
|
|
|
|
r := &cgroups.Resources{
|
|
NetClsClassid: classidAfter,
|
|
}
|
|
netcls := &NetClsGroup{}
|
|
if err := netcls.Set(path, r); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// As we are in mock environment, we can't get correct value of classid from
|
|
// net_cls.classid.
|
|
// So. we just judge if we successfully write classid into file
|
|
value, err := fscommon.GetCgroupParamUint(path, "net_cls.classid")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if value != classidAfter {
|
|
t.Fatal("Got the wrong value, set net_cls.classid failed.")
|
|
}
|
|
}
|