mirror of
https://github.com/opencontainers/runc.git
synced 2025-10-23 15:33:16 +08:00

I had pretty convenient input data to miss this bug. Signed-off-by: Alexander Morozov <lk4d4@docker.com>
30 lines
681 B
Go
30 lines
681 B
Go
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))
|
|
}
|
|
}
|