diff --git a/libcontainer/cgroups/fs/apply_raw.go b/libcontainer/cgroups/fs/apply_raw.go index cd6c0a88..f75dab1b 100644 --- a/libcontainer/cgroups/fs/apply_raw.go +++ b/libcontainer/cgroups/fs/apply_raw.go @@ -240,7 +240,7 @@ func (raw *data) parent(subsystem, mountpoint, src string) (string, error) { if err != nil { return "", err } - relDir, err := filepath.Rel(initPath, src) + relDir, err := filepath.Rel(src, initPath) if err != nil { return "", err } diff --git a/libcontainer/cgroups/fs/apply_raw_test.go b/libcontainer/cgroups/fs/apply_raw_test.go deleted file mode 100644 index 50aff591..00000000 --- a/libcontainer/cgroups/fs/apply_raw_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package fs - -import ( - "path/filepath" - "testing" - - "github.com/opencontainers/runc/libcontainer/cgroups" -) - -func TestCgroupParent(t *testing.T) { - raw := &data{ - cgroup: "", - } - subsystem := "memory" - subPath := "/docker/874e38c82a6c630dc95f3f1f2c8d8f43efb531d35a9f46154ab2fde1531b7bb6" - initPath, err := cgroups.GetInitCgroupDir(subsystem) - if err != nil { - t.Fatal(err) - } - srcPath := filepath.Join(initPath, subPath) - cgPath := "/sys/fs/cgroup/memory" - path, err := raw.parent(subsystem, cgPath, srcPath) - if err != nil { - t.Fatal(err) - } - if path != filepath.Join(cgPath, subPath) { - t.Fatalf("Unexpected path: %s, should be %s", path, filepath.Join(cgPath, subPath)) - } -}