cgroups: don't use d.path for cgroup tests files

d.path() should be used to get the real cgroup path, for temp path,
we can just create one.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
Qiang Huang 2015-03-09 09:32:02 +08:00
parent 606d9064b0
commit a3b0209cc6
2 changed files with 4 additions and 6 deletions

View File

@ -25,7 +25,7 @@ func TestDevicesSetAllow(t *testing.T) {
defer helper.cleanup()
helper.writeFileContents(map[string]string{
"device.deny": "a",
"devices.deny": "a",
})
helper.CgroupData.c.AllowAllDevices = false
@ -35,8 +35,6 @@ func TestDevicesSetAllow(t *testing.T) {
t.Fatal(err)
}
// FIXME: this doesn't make sence, the file devices.allow under real cgroupfs
// is not allowed to read. Our test path don't have cgroupfs mounted.
value, err := getCgroupParamString(helper.CgroupPath, "devices.allow")
if err != nil {
t.Fatalf("Failed to parse devices.allow - %s", err)

View File

@ -6,9 +6,9 @@ Creates a mock of the cgroup filesystem for the duration of the test.
package fs
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/docker/libcontainer/configs"
@ -31,12 +31,12 @@ func NewCgroupTestUtil(subsystem string, t *testing.T) *cgroupTestUtil {
d := &data{
c: &configs.Cgroup{},
}
tempDir, err := ioutil.TempDir("", fmt.Sprintf("%s_cgroup_test", subsystem))
tempDir, err := ioutil.TempDir("", "cgroup_test")
if err != nil {
t.Fatal(err)
}
d.root = tempDir
testCgroupPath, err := d.path(subsystem)
testCgroupPath := filepath.Join(d.root, subsystem)
if err != nil {
t.Fatal(err)
}