host_cgroup_test.go 453 Bytes
Newer Older
“李磊”'s avatar
“李磊” committed
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
package cgroup

import (
	"os"
	"testing"

	"linkfog.com/public/option"
)

func TestSetHostCgroup(t *testing.T) {
	// init test env
	option.HostProc = "/proc/"

	if err := SetHostCgroup(); err != nil {
		t.Fatal(err)
	}

	cgroup, err := GetCgroup(os.Getpid())
	if err != nil {
		t.Fatal(err)
	}

	if IsContainerCgroup(cgroup) {
		t.Fatalf("unexpected: unit test is container cgroup\nhost cgroup:\n%s\nproc cgroup:\n%s\n",
			HostCgroupCfg, cgroup)
	}
}