File: spec_linux_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 (39 lines) | stat: -rw-r--r-- 911 bytes parent folder | download | duplicates (2)
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
39
// build +linux

package specconv

import (
	"strings"
	"testing"

	"github.com/opencontainers/runtime-spec/specs-go"
)

func TestLinuxCgroupsPathSpecified(t *testing.T) {
	cgroupsPath := "/user/cgroups/path/id"

	spec := &specs.Spec{}
	spec.Linux.CgroupsPath = &cgroupsPath

	cgroup, err := createCgroupConfig("ContainerID", false, spec)
	if err != nil {
		t.Errorf("Couldn't create Cgroup config: %v", err)
	}

	if cgroup.Path != cgroupsPath {
		t.Errorf("Wrong cgroupsPath, expected '%s' got '%s'", cgroupsPath, cgroup.Path)
	}
}

func TestLinuxCgroupsPathNotSpecified(t *testing.T) {
	spec := &specs.Spec{}

	cgroup, err := createCgroupConfig("ContainerID", false, spec)
	if err != nil {
		t.Errorf("Couldn't create Cgroup config: %v", err)
	}

	if !strings.HasSuffix(cgroup.Path, "/ContainerID") {
		t.Errorf("Wrong cgroupsPath, expected it to have suffix '%s' got '%s'", "/ContainerID", cgroup.Path)
	}
}