mirror of
https://github.com/containers/podman.git
synced 2025-06-25 12:20:42 +08:00
tests: simplify --cgroups=disabled test
read the cgroup directly from the container. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -1330,28 +1330,23 @@ USER mail`, BB)
|
|||||||
Skip("Test only works on crun")
|
Skip("Test only works on crun")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trim := func(i string) string {
|
||||||
|
return strings.TrimSuffix(i, "\n")
|
||||||
|
}
|
||||||
|
|
||||||
curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
|
curCgroupsBytes, err := ioutil.ReadFile("/proc/self/cgroup")
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
var curCgroups = string(curCgroupsBytes)
|
curCgroups := trim(string(curCgroupsBytes))
|
||||||
fmt.Printf("Output:\n%s\n", curCgroups)
|
fmt.Printf("Output:\n%s\n", curCgroups)
|
||||||
Expect(curCgroups).ToNot(Equal(""))
|
Expect(curCgroups).ToNot(Equal(""))
|
||||||
|
|
||||||
ctrName := "testctr"
|
container := podmanTest.Podman([]string{"run", "--cgroupns=host", "--cgroups=disabled", ALPINE, "cat", "/proc/self/cgroup"})
|
||||||
container := podmanTest.Podman([]string{"run", "--name", ctrName, "-d", "--cgroups=disabled", ALPINE, "top"})
|
|
||||||
container.WaitWithDefaultTimeout()
|
container.WaitWithDefaultTimeout()
|
||||||
Expect(container).Should(Exit(0))
|
Expect(container).Should(Exit(0))
|
||||||
|
|
||||||
// Get PID and get cgroups of that PID
|
ctrCgroups := trim(container.OutputToString())
|
||||||
inspectOut := podmanTest.InspectContainer(ctrName)
|
|
||||||
Expect(len(inspectOut)).To(Equal(1))
|
|
||||||
pid := inspectOut[0].State.Pid
|
|
||||||
Expect(pid).ToNot(Equal(0))
|
|
||||||
Expect(inspectOut[0].HostConfig.CgroupParent).To(Equal(""))
|
|
||||||
|
|
||||||
ctrCgroupsBytes, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid))
|
|
||||||
Expect(err).ShouldNot(HaveOccurred())
|
|
||||||
var ctrCgroups = string(ctrCgroupsBytes)
|
|
||||||
fmt.Printf("Output\n:%s\n", ctrCgroups)
|
fmt.Printf("Output\n:%s\n", ctrCgroups)
|
||||||
|
|
||||||
Expect(ctrCgroups).To(Equal(curCgroups))
|
Expect(ctrCgroups).To(Equal(curCgroups))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user