Skip to content

Commit

Permalink
libct/int: add TestFdLeaksSystemd
Browse files Browse the repository at this point in the history
Add a test to check that container.Run do not leak file descriptors.

Before the previous commit, it fails like this:

    exec_test.go:2030: extra fd 8 -> socket:[659703]
    exec_test.go:2030: extra fd 11 -> socket:[658715]
    exec_test.go:2033: found 2 extra fds after container.Run

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed May 5, 2021
1 parent 0f4604a commit 5237064
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion libcontainer/integration/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1963,6 +1963,14 @@ func TestCGROUPHost(t *testing.T) {
}

func TestFdLeaks(t *testing.T) {
testFdLeaks(t, false)
}

func TestFdLeaksSystemd(t *testing.T) {
testFdLeaks(t, true)
}

func testFdLeaks(t *testing.T, systemd bool) {
if testing.Short() {
return
}
Expand All @@ -1979,7 +1987,10 @@ func TestFdLeaks(t *testing.T) {
_, err = pfd.Seek(0, 0)
ok(t, err)

config := newTemplateConfig(&tParam{rootfs: rootfs})
config := newTemplateConfig(&tParam{
rootfs: rootfs,
systemd: systemd,
})
buffers, exitCode, err := runContainer(config, "", "true")
ok(t, err)

Expand Down

0 comments on commit 5237064

Please sign in to comment.