From 5237064ba724fc1a84dd5118020969f5f2a80dc5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 4 May 2021 16:49:03 -0700 Subject: [PATCH] libct/int: add TestFdLeaksSystemd 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 --- libcontainer/integration/exec_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go index 0d55dba328b..d8e345f5126 100644 --- a/libcontainer/integration/exec_test.go +++ b/libcontainer/integration/exec_test.go @@ -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 } @@ -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)