summaryrefslogtreecommitdiff
path: root/utils/utils_test.go
blob: f34dbdd7e382b01962d0b9642d31775539f49867 (plain)
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
//go:build linux || darwin
// +build linux darwin

package utils

import (
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestCgroupProcess(t *testing.T) {
	val, err := getCgroupProcess("testdata/cgroup.root", true)
	assert.Nil(t, err)
	assert.Equal(t, "/", val)

	_, err = getCgroupProcess("testdata/cgroup.root", false)
	assert.NotNil(t, err)

	val, err = getCgroupProcess("testdata/cgroup.other", true)
	assert.Nil(t, err)
	assert.Equal(t, "/other", val)

	_, err = getCgroupProcess("testdata/cgroup.empty", true)
	assert.NotNil(t, err)
}