mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-11-03 09:37:34 +00:00
Merge pull request #26207 from giuseppe/fix-flake-kmsg
test: fix race conditions in /dev/kmsg tests
This commit is contained in:
commit
23ded8bcee
1 changed files with 9 additions and 3 deletions
|
|
@ -50,7 +50,10 @@ var _ = Describe("Podman run device", func() {
|
|||
Expect(session).Should(ExitCleanly())
|
||||
if !isRootless() {
|
||||
// Kernel 6.9.0 (2024-03) requires SYSLOG
|
||||
session = podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "/dev/kmsg", "--cap-add", "SYS_ADMIN,SYSLOG", ALPINE, "head", "-n", "1", "/dev/kmsg"})
|
||||
// Do not read any data from the device (thus the -n 0), because there is a rare race condition that happens
|
||||
// when another writes to the ring buffer when the device is already opened and that causes the following test
|
||||
// to fail: https://github.com/containers/podman/issues/23882.
|
||||
session = podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "/dev/kmsg", "--cap-add", "SYS_ADMIN,SYSLOG", ALPINE, "head", "-n", "0", "/dev/kmsg"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitCleanly())
|
||||
}
|
||||
|
|
@ -152,9 +155,12 @@ var _ = Describe("Podman run device", func() {
|
|||
})
|
||||
|
||||
It("podman run cannot access non default devices", func() {
|
||||
session := podmanTest.Podman([]string{"run", "-v /dev:/dev-host", ALPINE, "head", "-1", "/dev-host/kmsg"})
|
||||
// Unlikely to happen but do not read any data from the device (thus the -n 0), because there is a rare
|
||||
// race condition that happens so the test would fail for the rare race condition instead of a failure
|
||||
// reported by open(). More details: https://github.com/containers/podman/issues/23882.
|
||||
session := podmanTest.Podman([]string{"run", "-v", "/dev:/dev-host", ALPINE, "head", "-n0", "/dev-host/kmsg"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Not(ExitCleanly()))
|
||||
Expect(session).To(ExitWithErrorRegex(1, "head: /dev-host/kmsg: (Operation not permitted|Permission denied)"))
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue